Ubuntu16.04 LNMP (PHP7.0+Mysql5.7+Nginx1.10)

1. system update:

apt-get update
apt-get upgrade


2.install softwares:

sudo apt-get install nginx php7.0-fpm mysql-server-5.6 php7.0-mysql


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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章