Search code examples
phpwordpressnginxwp-adminwordpress-admin

wp-admin does not show dashboard


I have been attempting to get this issue fixed for some time now and have not found an answer which works. I have been working on a wordpress site for the intranet here at work (identifying information has been removed). I got the correct dns names from our network person and got everything created in nginx. Up until now, I have been accessing wp via the ip address.

The issues I have been two-fold. The first is that I can select a permalink structure, but the only one that works reliably is the plain structure. If any other structure is selected, wp-admin infinitely redirects to itself.

To make things a bit more interesting, if I select the plain structure, wp-admin does not show the login page when logged out, nor does it show the dashboard when logged in. Instead, it shows the homepage for the site.

Things I have tried:

  1. change permalinks to plan: works, but wp-admin does not show the dashboard
  2. remove .htaccess files: these don't exist in my configuration as I am using nginx, I also did a grep through the file structure just in case and there are no .htaccess files.
  3. update the siteurl/home in the database: wp is now accessible through the hostname provided in dns

I have taken the liberty of including my nginx site configuration for your perusal.

Any help in getting this working will be greatly appreciated.

server {
       listen 80;
       listen [::]:80;

       server_name intranet.company.com;

       root /var/www/intranet/;

       access_log /var/log/nginx/intranet/access.log;
       error_log /var/log/nginx/intranet/error.log;

       location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                 allow all;
                 log_not_found off;
                 access_log off;
        }

        index index.php;

        location ~ /\. {
                 deny all;
        }

        location ~* /(?:uploads|files)/.*\.php$ {
                 deny all;
        }

        location / {
                 try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
                 fastcgi_intercept_errors on;
                 fastcgi_pass unix:/run/php/php7.2-fpm.sock;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
                 expires max;
                 access_log off;
        }
}

Edit

After further testing, it would appear that wordpress is not showing the sub-directories properly. There is definitely something going sideways with the wordpress configs and it would appear that nginx is working properly.

Edit 2

After yet more testing, the site works perfectly fine when accessing it via the ip address. wp-admin redirects properly to the login page as expected and to the dashboard when logged in.

Edit 3

Upon further inspection, it would appear that the site is redirecting static files to directories. There is a readme.html file in the root of my wordpress installation when I access it via the dns name, or the ip address, wordpress redirects the file name to a directory. It then gives me the home page once again instead of an error or any other indication that something has gone wrong. I have also enabled the debug log, which has also been of no help.


Solution

  • So, after some digging around and thinking on the issue, it would appear that WordPress expects to be the default virtual site. I experimented with this theory and it turned out correct. Once I re-enabled the default site and pointed it at the WordPress directory, it began working as expected.

    The thing to note here is that the virtual site file MUST use "_" as the server_name and MUST include "default_server" in the listen line(s).