All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Need some help with with Nginx and Wordpress URL rewrites
I don't really understand why, but let me put it this way:
Both servers run:
mysql:
10.1.7-MariaDB-1~wheezy-log, 10.1.7-MariaDB-1~jessie-log
php5-fpm:
PHP 5.6.13-0+deb8u1 (cli) (built: Sep 8 2015 12:13:31) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies and PHP 5.6.13-0+deb8u1 (cli) (built: Sep 7 2015 13:38:37) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
nginx:
nginx version: nginx/1.9.5 and nginx version: nginx/1.9.5
server 1: dacentec $10/y ovz server
debian 7, was upgraded to jessie manually, runs nginx mainline 1.9.5 since webstack installation and wordpress rewrite/custom urls work perfectly fine. Sometimes the webserver is really slow in reloading urls and initially it had 504 gateway timeout errows from nginx(php5-fpm errors).
server 2: kidechire €2/m server
debian 8 from online.net, ran nginx stable 1.8.0 since webstack install and while the stack installed nicely and wordpress appears to works nicely, posts get a blank empty page with custom urls. Pages work for some reason.
I upgraded from stable to mainline, but that doesn't change anything. I've been trying to get this working for hours now and I've tried old configs from google and none of them work.
server 1 config for location:
server { listen 80; root /home/username/www/poolname; index index.php index.html index.htm; server_name sub.rootdomain1.com; location / { try_files $uri $uri/ /index.php; } location ~* /(?:uploads|files)/.*\.php$ { deny all; } # Deny access to hidden files location ~* /\. { deny all; access_log off; log_not_found off; } location ~ \.php$ { try_files $uri =404; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_pass unix:/home/username/www/run/poolname.php5-fpm.sock; fastcgi_read_timeout 300; } location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { expires 365d; } rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last; rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last; }
server 2:
server { listen 80; # listen [::]:80; root /home/username/www/poolname2; index index.php index.html index.htm; server_name rootdomain2.com www.rootdomain2.com; location / { try_files $uri $uri/ /index.php; # try_files $uri $uri/ /index.php?q=$uri&$args; } include /home/username/www/poolname2/nginx.conf; location ~ \.php$ { try_files $uri =404; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass unix:/home/username/www/run/poolname2.php5-fcgi.sock; } }
On server 2, there's an https self signed subdomain running for rootdomain2.com and owncloud's working perfectly in a subdirectory.
Both servers are running latest wordpress(4.3.1) and the same caching plugin,
w3 total cache Plugin Version: 0.9.4.1
.
I can't figure out why server 1 is working and why server 2 is not.
There's really no major differences between the 2 config files.
location / { try_files $uri $uri/ /index.php; # try_files $uri $uri/ /index.php?q=$uri&$args; }
Server 2 doesn't work with
try_files $uri $uri/ /index.php;
, or
try_files $uri $uri/ /index.php?q=$uri&$args;
, or
try_files $uri $uri/ /index.php?q=$args;
or
try_files $uri $uri/ /index.php?q=$uri;
.
This topic https://wordpress.org/support/topic/wordpress-permalinks-on-nginx suggests:
location / { try_files $uri $uri/ /index.php?q=$request_uri; }
which doesn't work either. Wordpress' doc about nginx http://codex.wordpress.org/Nginx#General_WordPress_rules suggests:
location / { try_files $uri $uri/ /index.php?$args; }
also leads to empty pages.
I don't understand. Is it php sucking with rewrite urls or nginx?
I used vultr's https://www.vultr.com/docs/setup-up-nginx-php-fpm-and-mariadb-on-debian-8 guide initially, and it works with server 1.
Vultr's wordpress guide with lemp https://www.vultr.com/docs/how-to-install-wordpress-on-a-lemp-configuration is 6 months old.
They recommended turning allow_url_fopen Off, but I've turned it back on server1(one plugin needed it) and on server 2 as well.
Now that I've posted this, I've noticed server 1 is running php5-fpm.sock and server 2 with php5-fcgi.sock. I don't understand the difference between the two, but will alter settings on server 2 to swap the unix sock paths to fpm now.
^Changing fcgi text to fpm didn't change anything either.
Both servers run fpm on pm = static and ph.max_children = 2, since they get low amount of traffic only.
Comments
Sounds like you are in over your head, maybe someone will be nice enough to throw you a life preserver.
I was until I realised I should use nginx's error log, which pointed out php parse errors in my theme's single.php file, so I retrieved a copy from the working server's theme single.php file and now my server's working fine.