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

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

vi /etc/sysconfig/iptables

//在2二端口的下壹行增添

-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

//此时提示运转失败,未有配置文件

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然后重启生效

二、关闭SELINUX(笔者未有操作此项,以为不用管)

vi /etc/selinux/config

#SELINUX=enforcing      #注释掉

#SELINUXTYPE=targeted    #注释掉

SELINUX=disabled        #增加

shutdown -r now  #重启系统

[root@localhost ~]# service mysqld start

[root@localhost ~]# service mysqld start

3、配置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软件包

三、配置第2方yum源(CentOS私下认可的正经源里未有nginx软件包)

yum install wget    #安装下载工具wget

wget   #下载atomic yum源

mysql安装配备,lnmp环境搭建。sh ./atomic  #安装

yum check-update  #更新yum软件包

 

 

四.设置开辟包和库文件
[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进度和ipv6 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)

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
//设二、3、伍品级开机运转

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

一.停歇防火墙
[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 6.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

地面浏览器输入:1九二.16八.1.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();
?>

5.卸载已安装的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
//设二、叁、伍等第开机运营

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

澳门金沙国际 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、FastCGI方式
[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、法斯特CGI情势
[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();
?>

一3.测试nginx是不是解析php
输入:192.168.1.105/info.php
呈现php分界面表达解析成功

一3.测试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

相关文章