I'm having a lot of trouble getting my Nginx Website showing up correctly.
I've been getting 404
errors, and now i'm getting a Connection Refused
error.
This is my Nginx configuration
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
It includes two other folders, conf.d is empty, and sites-enabled including Symbolic links to my Vhost configuration which is the following.
server {
listen 80;
listen [::]:80;
root /var/www/subdomain.mydomain.com;
index index.php;
server_name subdomain.mydomain.com www.subdomain.mydomain.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri =404;
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;
}
location ~/\.ht {
deny all;
}
}
The Root folder referenced does exist and contains an index.php file which right now just echoes out a string.
The nginx error logs show only the following:
2016/11/24 22:35:40 [notice] 8834#8834: signal process started
2016/11/24 22:38:30 [notice] 8890#8890: signal process started
2016/11/24 23:13:48 [notice] 10108#10108: signal process started
2016/11/24 23:14:16 [notice] 10141#10141: signal process started
PHP-FPM is installed and the sock exists in the directory specified and FPM is in fact running, either way doesn't seem to be a PHP issue.
This leaves the configuration itself or permissions perhaps?
Like i said, my project is located in the /var/www directory
Permission for which look like this
drwxr-sr-x 2 www-data www-data 4096 Nov 24 23:31 subdomain.mydomain.com
The index file inside of it:
-rw-rw-r-- 1 myusername www-data 25 Nov 24 23:50 index.php
The sites are running in an AWS Instance.
I've already allowed port 80 in the security groups and access is set to be allowed from anywhere.
If anyone can help me out i'd very much appreciate it as i'm on my 3rd hour trying to figure this out… 🙁
Best Answer
You don't need
try_files
in yourlocation ~ \.php$
section. You just pass processing directly to the PHP-FPM process there.