I can’t seem to get php working with nginx…
I’ve used the LEMP 1 click deploy and tried doing it on my own, and tried following countless tutorials out there.
Here is my config for this vhost
server {
listen 80;
server_name SERVER.COM;
return 301 https://$host$request_uri;
location /.well-known {
alias /var/www/DIR/.well-known;
}
}
server {
listen 443;
server_name SERVER.COM;
ssl_certificate /etc/letsencrypt/live/SERVER.COM/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/SERVER.COM/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
location / {
root /var/www/SERVER.COM/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location /monit/ {
rewrite ^/monit/(.*) /$1 break;
proxy_ignore_client_abort on;
proxy_pass http://localhost:2812;
}
}
All I am trying to do is to get a simple phpinfo to run. I see the request served in the access logs, nothing in the error logs
Relevant info
php/xenial,now 1:7.0+35ubuntu6 all [installed]
php-apcu/xenial,now 5.1.3+4.0.10-1build1 amd64 [installed]
php-common/xenial,now 1:35ubuntu6 all [installed,automatic]
php-curl/xenial,now 1:7.0+35ubuntu6 all [installed]
php-fpm/xenial,now 1:7.0+35ubuntu6 all [installed]
php-mcrypt/xenial,now 1:7.0+35ubuntu6 all [installed]
php-mysql/xenial,now 1:7.0+35ubuntu6 all [installed]
php7.0/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 all [installed,automatic]
php7.0-cli/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-common/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-curl/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-fpm/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-json/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-mcrypt/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-mysql/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-opcache/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
php7.0-readline/xenial-updates,xenial-security,now 7.0.15-0ubuntu0.16.04.4 amd64 [installed,automatic]
nginx/xenial-updates,xenial-security,now 1.10.0-0ubuntu0.16.04.4 all [installed]
nginx-common/xenial-updates,xenial-security,now 1.10.0-0ubuntu0.16.04.4 all [installed,automatic]
nginx-core/xenial-updates,xenial-security,now 1.10.0-0ubuntu0.16.04.4 amd64 [installed,automatic]
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
@madbuda
Unless you have a specific need, you shouldn’t be clustering the
location
blocks are you currently are. You need to separate/
from others.So you’re
location
blocks should look like this:Though I would organize the configuration a little more, which I’ve done for you below.
After changing the configuration, you’ll need to reload or restart NGINX.