Ubuntu 搭建php7+Nginx

2018-10-11  本文已影响0人  LeslieLiang

1. 下载安装php7.0、php7.0-fpm及其他常用模块

sudo apt-get install -y php7.0
sudo apt-get install -y php7.0-fpm
sudo apt-get install -y php-zip
sudo apt-get install -y php-dompdf
sudo apt-get install -y php-xml
sudo apt-get install -y php-mbstring
sudo apt-get install -y php-curl
sudo apt-get install -y php-mysql

2. 下载安装Nginx(1.10.3)

sudo apt-get install -y nginx

3. 配置Nginx

# Add index.php to the list if you are using PHP
index.php index index.html index.htm index.nginx-debian.html;

server项中找到关于php的配置并启用

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;
        }

4. 测试服务器

sudo /etc/init.d/nginx restart
sudo /etc/init.d/php7.0-fpm restart
<?php
phpinfo();
?>

FAQ

listen 8080 default_server;
listen [::]:8080 default_server;
root /var/www/html;
# display_errors = Off
displau_errors = On
# error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL | E_STRICT
上一篇 下一篇

猜你喜欢

热点阅读