服务器环境为:Ubuntu 16.04.1 LTS
- 安装PHP7.0
apt-get install php
php 相关扩展
apt-get install php7.0-cli php7.0-common php7.0-curl php7.0-gd php7.0-mysql libxml2 libxml2-dev build-essential openssl libssl-dev libcurl4-gnutls-dev libjpeg-dev libpng-dev libmcrypt-dev libreadline6 libreadline6-dev libgd-dev libxslt-dev
查看扩展 :
php -m
- 配置php.ini
cd /etc/php/7.0/fpm
vim php.ini
找到
;cgi.fix_pathinfo=1
修改为
cgi.fix_pathinfo=0
- 修改Nginx配置文件
cd /etc/nginx/sites-available
vim default
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
- 重启nginx
service nginx restart
- 输入域名访问
domain_or_ip
如果想部署多个站点,可以拷贝default 文件到
/etc/nginx/conf.d/
cp /etc/nginx/sites-available/default /etc/nginx/conf.d/demo.conf
参考链接: