我正在尝试在ubuntu 16.0上安装Nginx和php 7,在此之前我只能在Windows上使用WAMP,我已经成功安装了nginx和php,当我在terminal上运行这个命令时:
curl -I -v http:// localhost /
它显示nginx服务器是可以的,但它不提供PHP文件,一直试图找出这一点了一天知道,我已经在这个网站上search类似的问题,并在互联网上似乎没有任何帮助,这里是我的configuration文件看起来像:
# Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php INFO.PHP index.html index.htm index.nginx-debian.html; server_name 127.0.0.1:80; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # 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; fastcgi_index index.php; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } #server { # listen 80; # listen [::]:80; # # server_name example.com; # # root /var/www/example.com; # index index.html; # # location / { # try_files $uri $uri/ =404; # } #}
任何帮助渲染将不胜感激,问候。
检查php7.0-fpm服务是否正在运行。
systemctl list-units 'php*'当php-fpm状态良好时,结果处于活动状态。 如果你发现php7.0-fpm没有运行,启用它。
systemctl list-units 'php*'并再次检查。
然后试试
curl -v 'http://localhost/index.php'如果你能得到php的结果,你将会检查位置/块的try_files指令。
两个原因。
你正在传递所有的PHP扩展文件到fastcgi_pass unix:/run/php/php7.0-fpm.sock; 即临时创build的套接字。 可能是你php7.0-fpm运行在不同的套接字上。 虽然它是默认端口,但我仍会要求您在此处检查您的监听端口和用户组的configuration。 你可以findphp7-fpm的configuration
/etc/php/7.0/fpm/pool.d/www.conf
仍然有麻烦参考这篇文章