• 7 min read

WordPress Troubleshooting Techniques on Azure Websites

WordPress is one of the most commonly used blogging engines and can be quite cumbersome to resolve issues when trying to set it up on Azure Websites. In this blog post, we have addressed some of common issues with WordPress and ways to resolve them.

WordPress is one of the popular Web Applications that is offered with Azure Websites Gallery to build dynamic websites. You may run into some issues with your WordPress websites and might want to troubleshoot them. In this post, we will review some common issues and discuss the best techniques to resolve them.

How do I update PHP INI configuration for my WordPress site?

Your WordPress site may require specific changes to PHP.INI based on requirements for your application such as allowing users to upload a file up to 12 MB which is higher than the default limit 8MB .

You can enable a user-defined PHP configuration, by creating a file called .user.ini at the site root (D:homesitewwwroot folder) and add the following:

upload_max_filesize = 12M

 

Now, restart your website. To verify if your changes were overwritten, create a PHP file called phpinfo.php with the following text and save it in the site root folder.


 

Next, browse this file and search for upload_max_size:

phpinfo

My Media content (uploads folder) is 10GB in size and my Web Application is 1GB in size. Which Tier will give me ample storage ?

The Storage supported for Shared is 1 GB, Basic is 10GB and Standard is 50GB. If you want to make the most of your website storage , you can move all of your media content into the uploads folder to Azure Storage (which costs $0.048 per GB) and use an Azure Storage plugin to manage media content in your WordPress site. This allows you to isolate your media content from your Web Application.

You can also create an Azure CDN endpoint for the Azure Storage account you used to serve your media content. In the plugin settings page, you’ll see a CNAME property setting. This is where you will need to enter the Azure CDN name for example .

How to setup SSL for my WordPress site

Only Standard and Basic Tiers offer SSL support. To add SSL support to your website :

Can I use mod-rewrite on Azure Websites?

Azure Websites use the IIS web server and hence does not work with mod_rewrite which is an Apache module. Url Rewrite module is enabled by default on Azure websites and you can create your rewrite or redirect rules using a web.config.

Open the Web.config file located at the site root (D:homesitewwwroot). If you do not have a Web.config file in the directory, create it.

Copy and paste the following XML section into the system.webServer element:











This rule matches any requested URL; if the URL does not correspond to a file or a folder on a file system, then the rule rewrites the URL to Index.php and determines which content to serve based on the REQUEST_URI server variable that contains the original URL before it was modified by the rule.

To learn more about creating URL rewrite rules ,see 10 URL rewriting Tips and Tricks

How to resolve 404.3 “Mime Type missing” errors when dependent requests on .woff files ?

.woff extension is not enabled by default on Azure Websites. If you are using WordPress or any application that uses .woff files, include a web.config file at the site root folder and add the following under section:



        

Now, restart your website.

How to resolve slow page load time for WordPress site running on Azure ?

If your WordPress site is slow then check for these:

  • Are you running on Free Tier?

If yes, then Free tier is not sufficient for running a production site and hence you need to upgrade to Shared, Basic or Standard Tier. Check out the features supported for each tier and select the appropriate Tier, Azure Websites Pricing per tier.

  • Is your website and database in the same data center?

If your website is setup in say West US and your database is setup in say East US ; then this can impact performance of the website as both these components are in different datacenters and network latency for the database calls can add to your page load time. Make sure your website and database are in the same regions/data centers.

  • Are your using a Free ClearDB MySQL database?

The Free ClearDB MySQL database is not production website. Check out the ClearDB plans for Azure and How to purchase it from the Store.

How do I get diagnostics for PHP errors?

Websites allows you to turn on Webserver diagnostics such as Web Server logging, Detailed Error messages and Failed Request Tracing. To learn more about getting error information, see PHP diagnostics for Azure Websites

Our new Diagnostics as a Service (DaaS for short), attempts to interpret these logs in a way that it either helps me resolve the issue or provides prescriptive guidance. To learn more, DaaS – Diagnostics as a Service for Azure Web Sites

How to enable advanced WordPress Debugging?

WordPress provides various options to debug your WordPress site. WordPress uses a constant WP_DEBUG to turn ON debugging for your WordPress site. By default it is turned OFF in wp-config.php file

define('WP_DEBUG', false);

To enable it, you need to set it to TRUE

define('WP_DEBUG', true);

Note that debugging should be turned be turned OFF after debugging an issue. For more advanced options for debugging WordPress, see Debugging in WordPress.

How do I enable Email service with my WordPress site?

Azure Websites does not support Email/SMTP and hence you would need to purchase SendGrid from the Azure Store. SendGrid offers a Free plan (up to 25,000 emails per month) which might be sufficient for your WordPress site. You can learn about SendGrid Plans for Azure here if the Free plan does not meet your needs.

To learn more, How to Use SendGrid Email Service.

How do I backup and restore my WordPress site?

Azure Websites offers automatic Backup and Restore feature. To learn more check out How to back up your Azure Website and How to restore your Azure Website.

Can I edit my WordPress site online?

Websites comes with an online editor with the goodness of Visual Studio. To learn more, see Edit Azure Website online with Monaco.

How to Fix the Error Establishing a Database Connection in WordPress?

You get this error when WordPress is unable to establish a database connection. The following reasons could be the reason why the issue occurs:

  • Database information in wp-config.php file may be incorrect

Use MySQL Client to access your database with the information in wp-config.php to verify this.

  • Check if both the front end and back end of your WordPress site are returning the different errors

If you are getting a different error on the wp-admin page for instance something like “One or more database tables are unavailable. The database may need to be repaired”, then you need to repair your database. To do this add the following wp-config.php file:

define('WP_ALLOW_REPAIR', true);

Once you have done that, you can see the settings by visiting this page:

The user does not need to be logged in to access this functionality when this define is set. This is because its main intent is to repair a corrupted database, Users can often not login when the database is corrupt. So once you are done repairing and optimizing your database, make sure to remove this from your wp-config.php.

  • wp-config.php file may be corrupted

Retouch wp-config.php file so that the last modified time stamp for the file is changed.

  • If this error occurs intermittently when your site is on high user load

Use Persistent connections adapter plugin for your WordPress site as a best practice always on Azure websites.

  • Check if your Website Service is able to connect to the database

To verify if you can connect to the database, create a new file called testdbconnection.php and paste the following code in it:


Run this page in the browser .If you see “Connected successfully” message than Website service can connect to the database. If you see “Could not connect” message than read the MySQL error to identify the cause of the issue. Contact Azure Support if you still see “Could not connect” message and unable to resolve it.

How to resolve the error “1203 SQLSTATE: 42000 (ER_TOO_MANY_USER_CONNECTIONS)”?

This depends on what MySQL server you are using .

  • If you are using ClearDB MySQL database, it has limitations on max_user_connections for the database based on the database plan you are using. Check out the details here. When you hit the limit you will run into this error, so to resolve this upgrade your database plan.
  • If you are using MySQL Azure VM to host your database for your WordPress site, then edit my.ini (on Windows Machine) or my.cnf (Linux Machine) configuration
max_connections = 250

Setting the max_connections too high will cause MySQL server to crash with an “Out of memory” error. Choose this value carefully depending on the RAM for your MySQL server VM.

How do I resolve a White Screen/Blank page?

If you see a White Screen or a blank page when you access your website, the cause could either be plugin or theme related issue. Try to isolate the theme or plugin causing this issue. Check out the step by step guide here.

How do I resolve a Memory Size Exhausted error ?

The default limit is 128MB. You can increase the Memory limit either using:

  • by adding this to wp-config.php:
    define('WP_MEMORY_LIMIT', '128M');
  • by adding .user.ini at the site root (D:homesitewwwroot) with:
    memory_limit=256M

    Restart your websites.

 

I want to share feedback on a feature or documentation for Azure Websites

You can share your feedback about additional/missing documentation or new/existing features with our engineering team on User voice

Related Links

WordPress Troubleshooting Guide
WordPress Support