A high performance web server, Nginx is used as an alternative to the popular Apache web server. WordPress works smoothly on Nginx machines, but in order to get site statistics to work similar to Apache, you need to adjust some files. In this article, you will be able to view your Analog stats after enabling stats in your MilesWeb panel.
WordPress Stats and Apache
You won’t see the site statistics initially available when running WordPress. But when WordPress runs on an Apache server, you can view the /stats subdirectory to serve your site statistics, using an .htaccess file.
WordPress Stats and Nginx
After modifying the .conf file, you need to restart your VPS or reload your Dedicated server.
When you use Nginx, your .htaccess file does not work. Therefore, you need to add code to another file for viewing your stats. Your Nginx WordPress site comprises of two directories:
It is the actual web directory (or document root):
/home/username/example.com
It is nginx/example.com directory which should include all config files:
/home/username/nginx/example.com
In this /home/username/nginx/example.com directory, create a file names as wordpress.conf. At the start of this wordpress.conf file, add the below rule:
### stats if ($request_uri ~* ^/(stats|failed_auth\.html).*$) { break; }
Now after visiting example.com/stats, a login prompt gets displayed permitting you to log in and check your site statistics.
Steps to Enable Stats and Permalinks
Permalinks are used by WordPress to make the URLs easily readable. Add the below two sections while running Nginx to obtain both site statistics as well as permalinks to function:
### stats if ($request_uri ~* ^/(stats|doc|failed_auth\.html).*$) { break; } ### Permalinks if (!-e $request_filename) { rewrite ^.*$ /index.php last; }
Troubleshooting
In case you have enabled a stats user on the Site Statistics page but if stats are still not accessible, please contact MilesWeb support.