## Nginx 安裝
###實驗環境
1.CentOS6.5系統,阿里云服務器
2.nginx version: nginx/1.10.2
3.PHP 5.3.3 (fpm-fcgi) (built: Aug 11 2016 20:34:52)
###教程地址
* http://blog.csdn.net/keyunq/article/details/45129859?
* http://www.cnblogs.com/xiaoit/p/3991037.html
###安裝位置
默認安裝位置:/etc/nginx/
默認網站目錄:/usr/share/nginx/html
###啟動:
1. /etc/init.d/nginx start # 啟動Nginx服務
2. /etc/init.d/nginx stop # 停止Nginx服務
3. /etc/nginx/nginx.conf # Nginx配置文件位置
### 自己的總結
1. nginx 獨立安裝,安裝位置在/etc/nginx,網站根目錄默認為:/usr/share/nginx/html
2. php獨立安裝,配置文件在/etc/php.ini里面
3. nginx的配置文件在:/etc/nginx/nginx.conf 和 /etc/nginx/conf/default.conf中
4. default.conf是用于配置server服務器的,所以給nginx增加php能力,就在這個文件中配置php的位置
5. default.conf 在/etc/nginx/nginx.conf被引用
6. 通過安裝php-fpm,并在啟動改進程于 127.0.0.1:9000 ,然后在default.conf中配置nginx將php腳本交給phpfpm來處理,從而使得nginx支持php
7. 關鍵配置 default.config
###修改nginx配置文件,添加fastcgi支持
~~~
#vi /etc/nginx/conf/default.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;
????????}
~~~