Ubuntu16.04 LNMP (PHP7.0+Mysql5.7+Nginx1.10)
3.configer:
然後改配置檔案,php的配置檔案不用改就能用,nginx的配置檔案不行,預設情況下是不支援php CGI的,所以得改一下:
vim /etc/nginx/sites-available/default
找到
#
#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;
#}
改成
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/php/php7.0-fpm.sock;
}
大概意思就是所有以 .php 積極結尾的檔案都傳給php7.0-fpm去處理,處理完了把結果發給nginx,然後再由nginx發給客戶機
然後重啟一下服務:
systemctl restart nginx
systemctl restart php7.0-fpm
systemctl restart mysql
就好啦預設的網站根目錄在/var/www/html/(可以通過nginx的配置檔案裡root 的那行改)
題主要是想搭wordpress之類的話,要把index.php當做主頁的
就是把nginx配置檔案中的
index index.html index.htm index.nginx-debian.html;
改成 index.php