ubuntu里安装php,并配置nginx请求php-fpm
安装php
apt-get install php
安装完成后需要把php的配置加入到nginx.conf里
首先我们需要把php-fpm的监听端口查出来写到nginx.conf里:
打开php-fpm.conf配置文件查看listen
打开nginx.conf配置文件:
需要把nginx的用户改为 user:www-data
我的这个是;/run/php/php7.0-fpm.sock ;应该写:
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
有的端口号为:127.0.0.1:9000:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param APPLICATION_ENV production;
include fastcgi_params;
}
修改完成后:重启nginx和php-fpm重新查看网址就OK