yum -y install gcc gcc-c++ openssl-devel zlib-devel pcre pcre-devel rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm
# 切換到下載目錄 cd /usr/local/src
下載源碼包php
wget http://nginx.org/download/nginx-1.6.2.tar.gz # 若是沒有wget目錄 使用:yum install wget 下載wget命令
解壓源碼包html
tar zxvf nginx-1.6.2.tar.gz
切換到解壓目錄mysql
cd nginx-1.6.2
編譯前配置nginx
./configure --prefix=/usr/local/nginx
編譯安裝c++
make && make install
Nginx安裝完畢,啓動命令web
/usr/local/nginx/sbin/nginx
yum -y install php56w-fpm
修改配置讓Nginx將訪問到PHP文件轉發給php-fpm處理sql
vi /usr/local/nginx/conf/nginx.conf
找到php-fpm
location / { root html; index index.html index.htm; }
修改成code
location / { root html; index index.html index.htm index.php; }
而後在service{}裏添加xml
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
/usr/local/nginx/html/爲存放PHP文件的目錄,可修改
啓動php-fpm
service php-fpm start
平滑的重啓Nginx
/usr/local/nginx/sbin/nginx -s reload
安裝PHP經常使用模塊
yum -y install php56w-devel php56w-gd php56w-mbstring php56w-mysql php56w-pdo php56w-xml
設置開機啓動
# 設置MySQL開機啓動 chkconfig mysqld on # 設置php-fpm開機啓動 chkconfig php-fpm on