Overview
Nginx is a high performance web server used as an alternative to the popular Apache web server. WordPress works great on Nginx machines, however, you must adjust certain files to enable site statistics to work as they would on an Apache server.
This article describes how to view your Analog stats after enabling stats in your DreamHost panel.
WordPress stats and Apache
Site statistics are not initially available when running WordPress. When WordPress is running on an Apache server, you can use an .htaccess file to allow the /stats subdirectory to serve your site statistics. See the following article for details:
WordPress stats and Nginx
After making any adjustments to a .conf file, you must restart your VPS or reload your Dedicated Server.
When using Nginx, your .htaccess file does not function. You must add code to another file in order to view your stats. Your Nginx WordPress site has the following two directories, which are described below:
- Your web directory (aka document root)
- Your nginx/example.com directory
In the following examples, username would be your Shell user and example.com your website.
Your web directory (aka document root)
This web directory is where all of your website's files are located:
/home/username/example.com
Your nginx/example.com directory
The nginx directory only contains configuration files for your site:
/home/username/nginx/example.com
View the Nginx configuration file locations article for further details.
Within the /home/username/nginx/example.com directory, create a file titled wordpress.conf and then add the following rule at the very beginning of this wordpress.conf file:
### stats if ($request_uri ~* ^/(stats|failed_auth\.html).*$) { break; }
When you visit example.com/stats, a login prompt displays allowing you to log in and view your site statistics.
Enabling stats and permalinks
WordPress uses 'permalinks' to make the URLs easier to read. When running Nginx, add the following two sections to enable both the site statistics and permalinks to function:
### stats if ($request_uri ~* ^/(stats|doc|failed_auth\.html).*$) { break; } ### permalinks if (!-e $request_filename) { rewrite ^.*$ /index.php last; }
Troubleshooting
If you've enabled a stats user on the Site Statistics page but find that the stats are still not accessible, please contact DreamHost support.