感想:本來覺得應該很簡單的事,卻足足搞了二、三個小時,有時候,真的要試過一遍才知道啊!!
一、安裝 nginx
- 下載 nginx key 並新增
wget -qO - http://nginx.org/keys/nginx_signing.key | sudo apt-key add - - 在 /etc/apt/sources.list 增加 nginx 的 repo
deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx - sudo apt-get update && sudo apt-get install nginx
二、安裝 php5-fpm (可以順便把其他套件一併裝上)
- sudo apt-get install php5-fpm php5-curl php5-mysql php5-xcache php5-gd php5-cli
- 修改 /etc/nginx/config.d/default.conf (註:php能不能執行就看它了)
a.加上 index.php
index index.php index.html index.htm;b.取消 php 區段的註解
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name
include fastcgi_params;
}
c. 修改 fastcgi_param 後的參數
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name改成
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;d.最後,把 nginx 和 php5-fpm 重新啟動一次就OK囉!
$ sudo service nginx restart有圖有真相
$ sudo service php5-fpm restart
0 意見:
張貼留言