標籤:
這裡只是從無到有的搭建一個最基本的環境,能夠讓nginx伺服器運行PHP程式即可,進階的配置我以後會補上。 nginx自動安裝:sudo apt-get install nginx 啟動:sudo /etc/init.d/nginx start 停止:service nginx stop 訪問:瀏覽器訪問localhost,成功說明nginx安裝沒問題: 安裝php和mysql:sudo apt-get install php5-cli php5-cgi mysql-server php5-mysql 安裝spawn-fcgi:sudo apt-get install spawn-fcgi 啟動spawn-fcgi:spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi 修改nginx設定檔:在/etc/nginx/nginx.conf中找相應的設定檔,例如/etc/nginx/sites-enabled/default找到index index.html index.htm index.php index.nginx-debian.html;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
}
添加與PHP相關的內容,修改後重啟nginx; sudo /etc/init.d/nginx restart 在nginx設定檔的root對應的路徑下,添加index.php,通過localhost/index.php訪問,能夠正常訪問即可
<?phpphpinfo();
index.php
效果:
ubuntu15.10簡單搭建nginx+php+mysql