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

来源:互联网 发布:淘宝app的开发 编辑:程序博客网 时间:2024/05/01 06:18

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

0 0