环境:Centos 6.6
[root@Centos ~]# /etc/init.d/iptables status iptables: Firewall is not running. [root@Centos ~]# getenforce Disabled [root@Centos ~]#
安装Nginx:
[root@Centos ~]# yum -y remove httpd [root@Centos ~]# yum -y install nginx [root@Centos ~]# chkconfig nginx on
安装Mysql:
[root@Centos ~]# yum -y install mysql mysql-server mysql-devel [root@Centos ~]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf [root@Centos ~]# chkconfig mysqld on [root@Centos ~]# /etc/init.d/mysqld start [root@Centos ~]# mysqladmin -uroot password "redhat" [root@Centos ~]# mysql_secure_installation
安装PHP及其依赖包:
[root@Centos ~]# yum -y install php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php-cli php-pdo php-tidy php-pecl-memcache php-eaccelerator [root@Centos ~]# chkconfig php-fpm on
配置Nginx:
[root@Centos ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak [root@Centos ~]# cd /etc/nginx/conf.d/ [root@Centos conf.d]# cp default.conf default.conf.bak [root@Centos conf.d]# grep -v ‘#‘ /etc/nginx/nginx.conf|grep -v ^$ |head -2 user nginx nginx; worker_processes 5; [root@Centos ~]# [root@Centos conf.d]# grep -v ‘#‘ default.conf |grep -v ^$ server { listen 80; server_name 192.168.31.160; include /etc/nginx/default.d/*.conf; location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~ ^(.+.php)(.*)$ { root /var/www/html; fastcgi_split_path_info ^(.+.php)(.*)$; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } [root@Centos conf.d]#
配置PHP:
[root@Centos ~]# cd /etc/php-fpm.d/ [root@Centos php-fpm.d]# grep nginx www.conf user = nginx group = nginx [root@Centos php-fpm.d]# [root@Centos ~]# cd /var/www/html/ [root@Centos html]# cat info.php <?php phpinfo(); ?> [root@Centos www]# chown nginx:nginx html/ -R [root@Centos ~]# /etc/init.d/php-fpm start Starting php-fpm: [ OK ] [root@Centos ~]# [root@Centos ~]# /etc/init.d/nginx start Starting nginx: [ OK ] [root@Centos ~]#
本文出自 “鹏城-酱油瓶” 博客,谢绝转载!
原文地址:http://yfshare.blog.51cto.com/8611708/1774955