mysql安装配置,lnmp环境搭建

By admin in 美高梅手机版4858 on 2019年4月13日

 

 

1.关闭防火墙
[root@CentOS ~]#
chkconfig iptables off

一、配置防火墙,开启80端口、330陆端口

vi /etc/sysconfig/iptables

//在2二端口的下1行添加

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
//(允许80端口通过防火墙)

-A INPUT -m state –state NEW -m tcp -p tcp –dport 330陆 -j ACCEPT
//(允许330六端口通过防火墙)

//保存退出,重启防火墙使配置生效

/etc/init.d/iptables restart

注:作者在Ali云ecs上操作时,主机未有设置iptables

yum -y install iptables

service iptables start

mysql安装配置,lnmp环境搭建。//此时提示运营失败,未有陈设文件

vi /etc/sysconfig/iptables

//写入以下内容

# Firewall configuration written by system-config-firewall

# Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

-A INPUT -j REJECT –reject-with icmp-host-prohibited

-A FORWARD -j REJECT –reject-with icmp-host-prohibited

COMMIT

//保存退出,service iptables start 此时开发银行成功

[root@localhost ~]#  yum install -y mysql-server mysql mysql-devel

[root@localhost ~]#  yum install -y mysql-server mysql mysql-devel

2.关闭selinux
vi /etc/sysconfig/selinux
//将SELINUX=enforcing修改为disabled然后重启生效

2、关闭SELINUX(小编未有操作此项,感觉不用管)

vi /etc/selinux/config

#SELINUX=enforcing      #注释掉

#SELINUXTYPE=targeted    #注释掉

SELINUX=disabled        #增加

shutdown -r now  #重启系统

[root@localhost ~]# service mysqld start

[root@localhost ~]# service mysqld start

三、配置CentOS 6.0 第2方yum源(CentOS默许的专业源里没有nginx软件包)
[root@CentOS ~]# yum install wget
//下载wget工具
[root@CentOS ~]# wget
//下载atomic yum源
[root@CentOS ~]# sh ./atomic
//安装提醒输入时输yes
[root@CentOS ~]# yum check-update
//更新yum软件包

三、配置第二方yum源(CentOS私下认可的正式源里没有nginx软件包)

yum install wget    #安装下载工具wget

wget   #下载atomic yum源

sh ./atomic  #安装

yum check-update  #更新yum软件包

 

 

4.安装开发包和库文件
[root@CentOS ~]# yum -y install ntp make openssl openssl-devel pcre
pcre-devel libpng
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd
gd-devel zlib zlib-devel
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt
libmcrypt-devel libxml2
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33
curl curl-devel

4、安装nginx

yum -y install nginx      #安装nginx,依据提示,输入Y安装即可成功安装

service nginx start    #启动

chkconfig nginx on    #设为开机运营

/etc/init.d/nginx  restart  #重启

rm -rf /usr/share/nginx/html/*  #剔除ngin暗许测试页

注:笔者在Ali云ecs上操作时,安装完后唤醒运营失利

centos6.5环境

修改nginx配置文件后,重启报错:

nginx: [emerg] socket() [::]:80 failed (97: Address family not
supported by protocol)

解决办法:

vi /etc/nginx/conf.d/default.conf

listen      80 default_server;

listen      [::]:80 default_server;

改为:

listen      80;

#listen      [::]:80 default_server;

重复开动nginx即可,网上说的这种kill掉nginx进度和ipv陆 on的方法不适用

mysql> grant all privileges on *.* to ‘root’@’%’ identified by
‘password’ with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to ‘root’@’%’ identified by
‘password’ with grant option;
Query OK, 0 rows affected (0.00 sec)

伍.卸载已设置的apache、mysql、php
[root@CentOS ~]# yum remove httpd
[root@CentOS ~]# yum remove mysql
[root@CentOS ~]# yum remove php

5、安装MySQL

yum -y install mysql mysql-server mysql-devel

service mysqld start

chkconfig –levels 235 mysqld on

//登六MySQL删除空用户,修改root密码

mysql>select user,host,password from mysql.user;

mysql>drop user ”@localhost;

mysql>update mysql.user set password = PASSWORD(‘*********’)
where user=’root’;

mysql>flush privileges;

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

美高梅手机版4858,mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

6.安装nginx
[root@CentOS ~]# yum install nginx
[root@CentOS ~]# service nginx start
[root@CentOS ~]# chkconfig –levels 235 nginx on
//设二、三、5级别开机运行

6、安装PHP

//安装重视库

yum -y install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap
php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt
php-mssql php-snmp php-soap

//安装php和所需组件使PHP帮忙MySQL、法斯特CGI形式

yum -y install  php-tidy php-common php-devel php-fpm php-mysql

service php-fpm start

chkconfig –levels 235 php-fpm on

 

 

7.安装mysql
[root@CentOS ~]# yum install mysql mysql-server mysql-devel
[root@CentOS ~]# service mysqld start
[root@CentOS ~]# chkconfig –levels 235 mysqld on
[root@CentOS ~]# mysqladmin -u root password “123456”
//为root用户安装密码
[root@CentOS ~]# service mysqld restart
//重启mysql

7、配置nginx支持php

//将陈设文件改为备份文件

mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak

//由于原配置文件要本人去写因而能够使用私下认可的布署文件作为配置文件

cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

//修改nginx配置文件,添加fastcgi援助

vi /etc/nginx/nginx.conf

//加入index.php

index index.php index.html index.htm;

//将以下代码注释去掉,并修改成nginx暗中认可路径

location ~ \.php$ {

root          /usr/share/nginx/html;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME 
/usr/share/nginx/html$fastcgi_script_name;

include        fastcgi_params;

}

转载

转载

8.安装php
[root@CentOS ~]# yum install php lighttpd-fastcgi php-cli php-mysql
php-gd php-imap php-ldap
php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql
php-snmp php-soap
php-tidy php-common php-devel php-fpm
//安装php和所需组件使PHP协助MySQL、法斯特CGI情势
[root@CentOS ~]# service php-fpm start
[root@CentOS ~]# chkconfig –levels 235 php-fpm on

8、配置php

//编辑文件php.ini

[root@CentOS ~]# vi /etc/php.ini

//在Ali云ECS主机上操作时发现session不可用,如下处理

//依据php-fpm的session配置新闻(tail /etc/php-fpm.d/www.conf)

//修改php.ini中的session目录如下

session.save_path = “/var/lib/php/session”

//并且session目录的全数者要设为php-fpm的process user,小编那里是apache

ps -ef | grep php-fpm

chown root:apache /var/lib/php/session

//在文件末尾添加

cgi.fix_pathinfo = 1

壹.关门防火墙
[root@CentOS ~]# chkconfig iptables off

1.闭馆防火墙
[root@CentOS ~]# chkconfig iptables off

9.配置nginx支持php
[root@CentOS ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
//将配置文件改为备份文件
[root@CentOS ~]# cp /etc/nginx/nginx.conf.default
/etc/nginx/nginx.conf
//由于原配置文件要和谐去写由此得以应用暗中认可的配置文件作为配置文件
//修改nginx配置文件,添加fastcgi支持
[root@CentOS ~]# vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME 
/usr/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
//将以上代码注释去掉,并修改成nginx默许路径

9、重启nginx php-fpm

service nginx restart

service php-fpm restart

2.关闭selinux
vi /etc/sysconfig/selinux 
//将SELINUX=enforcing修改为disabled然后重启生效

2.关闭selinux
vi /etc/sysconfig/selinux 
//将SELINUX=enforcing修改为disabled然后重启生效

10.配置php
//编辑文件php.ini,在文书末尾添加cgi.fix_pathinfo = 1
[root@CentOS ~]# vi /etc/php.ini

拾、测试注明

//如nginx自定义项目目录,要给读和执行权限

vi /usr/share/nginx/html/info.php

//保存退出

叁、配置CentOS 六.0 第一方yum源(CentOS暗中同意的正规化源里未有nginx软件包)
[root@CentOS ~]# yum install wget
//下载wget工具
[root@CentOS ~]# wget
//下载atomic yum源
[root@CentOS ~]# sh ./atomic
//安装提醒输入时输yes
[root@CentOS ~]# yum check-update
//更新yum软件包

三、配置CentOS 陆.0 第一方yum源(CentOS暗许的规范源里未有nginx软件包)
[root@CentOS ~]# yum install wget
//下载wget工具
[root@CentOS ~]# wget
//下载atomic yum源
[root@CentOS ~]# sh ./atomic
//安装提醒输入时输yes
[root@CentOS ~]# yum check-update
//更新yum软件包

11.重启nginx php-fpm
[root@CentOS ~]# service nginx restart
[root@CentOS ~]# service php-fpm restart

1一:测试nginx是不是解析php

本地浏览器输入:192.16八.一.105/info.php

体现phpinfo界面  环境搭建成功

四.装置开发包和库文件
[root@CentOS ~]# yum -y install ntp make openssl openssl-devel pcre
pcre-devel libpng 
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd
gd-devel zlib zlib-devel 
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt
libmcrypt-devel libxml2 
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33
curl curl-devel

4.安装开发包和库文件
[root@CentOS ~]# yum -y install ntp make openssl openssl-devel pcre
pcre-devel libpng 
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd
gd-devel zlib zlib-devel 
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt
libmcrypt-devel libxml2 
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33
curl curl-devel

12.建立info.php文件
[root@CentOS ~]# vi /usr/share/nginx/html/info.php
<?php
   phpinfo();
?>

伍.卸载已安装的apache、mysql、php
[root@CentOS ~]# yum remove httpd
[root@CentOS ~]# yum remove mysql
[root@CentOS ~]# yum remove php

伍.卸载已安装的apache、mysql、php
[root@CentOS ~]# yum remove httpd
[root@CentOS ~]# yum remove mysql
[root@CentOS ~]# yum remove php

一三.测试nginx是还是不是解析php
输入:192.168.1.105/info.php
彰显php界面表明解析成功

6.安装nginx
[root@CentOS ~]# yum install nginx
[root@CentOS ~]# service nginx start
[root@CentOS ~]# chkconfig –levels 235 nginx on
//设贰、3、伍级别开机运行

6.安装nginx
[root@CentOS ~]# yum install nginx
[root@CentOS ~]# service nginx start
[root@CentOS ~]# chkconfig –levels 235 nginx on
//设2、3、5级别开机运行

美高梅手机版4858 1

7.安装mysql
[root@CentOS ~]# yum install mysql mysql-server mysql-devel
[root@CentOS ~]# service mysqld start
[root@CentOS ~]# chkconfig –levels 235 mysqld on
[root@CentOS ~]# mysqladmin -u root password “123456”
//为root用户设置密码
[root@CentOS ~]# service mysqld restart
//重启mysql

7.安装mysql
[root@CentOS ~]# yum install mysql mysql-server mysql-devel
[root@CentOS ~]# service mysqld start
[root@CentOS ~]# chkconfig –levels 235 mysqld on
[root@CentOS ~]# mysqladmin -u root password “123456”
//为root用户安装密码
[root@CentOS ~]# service mysqld restart
//重启mysql

8.安装php
[root@CentOS ~]# yum install php lighttpd-fastcgi php-cli php-mysql
php-gd php-imap php-ldap 
php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql
php-snmp php-soap 
php-tidy php-common php-devel php-fpm
//安装php和所需组件使PHP支持MySQL、法斯特CGI格局
[root@CentOS ~]# service php-fpm start
[root@CentOS ~]# chkconfig –levels 235 php-fpm on

8.安装php
[root@CentOS ~]# yum install php lighttpd-fastcgi php-cli php-mysql
php-gd php-imap php-ldap 
php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql
php-snmp php-soap 
php-tidy php-common php-devel php-fpm
//安装php和所需组件使PHP接济MySQL、FastCGI情势
[root@CentOS ~]# service php-fpm start
[root@CentOS ~]# chkconfig –levels 235 php-fpm on

9.配置nginx支持php
[root@CentOS ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
//将配备文件改为备份文件
[root@CentOS ~]# cp /etc/nginx/nginx.conf.default
/etc/nginx/nginx.conf
//由于原配置文件要团结去写由此得以选拔暗中同意的布署文件作为配置文件
//修改nginx配置文件,添加fastcgi帮助
[root@CentOS ~]# vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
//将以上代码注释去掉,并修改成nginx暗中同意路径

9.配置nginx支持php
[root@CentOS ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
//将配置文件改为备份文件
[root@CentOS ~]# cp /etc/nginx/nginx.conf.default
/etc/nginx/nginx.conf
//由于原配置文件要和谐去写因而得以应用暗中同意的配置文件作为配置文件
//修改nginx配置文件,添加fastcgi补助
[root@CentOS ~]# vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
//将以上代码注释去掉,并修改成nginx暗中认可路径

10.配置php
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
[root@CentOS ~]# vi /etc/php.ini

10.配置php
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
[root@CentOS ~]# vi /etc/php.ini

11.重启nginx php-fpm
[root@CentOS ~]# service nginx restart
[root@CentOS ~]# service php-fpm restart

11.重启nginx php-fpm
[root@CentOS ~]# service nginx restart
[root@CentOS ~]# service php-fpm restart

12.建立info.php文件
[root@CentOS ~]# vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>

12.建立info.php文件
[root@CentOS ~]# vi /usr/share/nginx/html/info.php
<?php
phpinfo();
?>

1三.测试nginx是还是不是解析php
输入:192.168.1.105/info.php
呈现php界面表达解析成功

一三.测试nginx是不是解析php
输入:192.168.1.105/info.php
来得php界面表明解析成功

File not found.

File not found.

vim /etc/nginx/fastcgi_params

vim /etc/nginx/fastcgi_params

fastcgi_param SCRIPT_FILENAME    
$document_root$fastcgi_script_name;

fastcgi_param SCRIPT_FILENAME    
$document_root$fastcgi_script_name;

 

 

service nginx restart

service nginx restart

service php-fpm restart

service php-fpm restart

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有