Closed andrebu closed 8 years ago
A lot of good info on the changes I made https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
About root
specifically -- https://www.nginx.com/resources/admin-guide/serving-static-content/
Going to change it from this: -- File: earmilk.com.conf
server {
listen 192.168.102.1:80;
server_name www.earmilk.com;
return 301 $scheme://earmilk.com$request_uri;
rewrite_log on;
}
server {
listen 192.168.102.1:80;
server_name earmilk.com mulwray.earmilk.com;
charset utf-8;
root /home/www-data/earmilk/public;
rewrite_log on;
error_log /var/log/nginx/earmilk.com.error.log;
access_log /var/log/nginx/earmilk.com.access.log;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$args;
index index.php index.html index.htm;
autoindex on;
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Include W3TC's editable nginx.conf file in WordPress root
# include /home/www-data/earmilk/public/nginx.conf;
location ~* \.(png|gif|jpg|jpeg)$ {
error_page 404 http://images.earmilk.com/delivery.png;
proxy_read_timeout 300;
fastcgi_read_timeout 300s;
}
}
location /sxsw-2015 {
root /home/www-data/earmilk/public/microsites/sxsw-2015;
}
location ~ \.php$ {
root /home/www-data/earmilk/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_read_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
#
# Error Handling
#
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Security
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
# Block PHP files in uploads directory.
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# Block PHP files in content directory.
location ~* /wp-content/.*\.php$ {
deny all;
}
# Block PHP files in includes directory.
location ~* /wp-includes/.*\.php$ {
deny all;
}
# Block PHP files in uploads, content, and includes directory.
location ~* /(?:uploads|files|wp-content|wp-includes)/.*\.php$ {
deny all;
}
}
to this:
server {
listen 192.168.102.1:80;
server_name www.earmilk.com;
return 301 $scheme://earmilk.com$request_uri;
rewrite_log on;
}
server {
listen 192.168.102.1:80;
server_name earmilk.com mulwray.earmilk.com;
charset utf-8;
rewrite_log off;
error_log /var/log/nginx/earmilk.com.error.log;
access_log /var/log/nginx/earmilk.com.access.log;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$args;
root /home/www-data/earmilk/public;
index index.php index.html index.htm;
autoindex on;
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Include W3TC's editable nginx.conf file in WordPress root
# include /home/www-data/earmilk/public/nginx.conf;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
proxy_read_timeout 300s;
fastcgi_read_timeout 300s;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
location ~* \.(png|gif|jpg|jpeg)$ {
error_page 404 http://images.earmilk.com/delivery.png;
Adding try_files $uri =404;
to right above include fastcgi_params
New error upon trying a nonexistent *.php file.
2016/03/08 13:29:13 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"
2016/03/08 13:29:15 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"
2016/03/08 13:29:17 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"
2016/03/08 13:29:17 [error] 14415#14415: *11521 open() "/usr/share/nginx/html/404.html" failed (2: No such file or directory), client: 47.20.3.104, server: earmilk.com, request: "GET /SQLiteManager-1.2.4/main.php HTTP/1.1", host: "earmilk.com"
Navigating to
/SQLiteManager-1.2.4/main.php
(or/administrator/index.php
, *.php, etc) leads to "File not found" -- "FastCGI sent in stderr: "Primary script unknown""I suspect incorrect Nginx settings.
Other deets: