I have not been writing any blog posts for a while. That was because for the past two years I have been busy working in a team that develops the Windows Azure Web Sites – a scalable web hosting platform in Windows Azure.
Now that the Windows Azure Web Sites (WAWS) is publicly available I decided to try to move my site from private hosting to Windows Azure. My site uses WordPress (with MySql database), PHP 5.3, WinCache object and user cache, URL rewriting and many WordPress plugins. With all these different technologies (many of which are not developed by Microsoft), I thought it would be a good test of how WAWS is capable of running web sites that use open source technologies. Plus I expect that my site will be more reliable and available, comparing to my previous private hosting.
I was pleasantly surprised that the migration from private hosting to WAWS hosting was relatively quick and simple. The site has been running successfully in a Shared compute mode for a while now and none of the site’s functionality has been lost or altered. In this post I’ll explain the steps I took to move my site to WAWS hosting. Hopefully it will be useful to those who are planning to migrate their WordPress based site to WAWS.
1. Signing up and creating an empty site
The sign up process is straightforward and quick. If you have not signed up before then you can get a 90-days free trial, where you can try all the WAWS hosting options for free. Once you complete the sign up process you will end up at the Windows Azure Management Portal and start creating sites. In my case I started by creating an empty free web site http://ruslany.azurewebsites.net. It takes only a few seconds to create a new site.
2. Creating a MySql database
WAWS works in partnership with ClearDb to provide MySql databases. If you have a relatively small web application with light traffic then the free MySql database provided in Windows Azure should be enough for you. You can create the database by going to the Linked Resources page and adding a new Linked Resource:
My site’s database was bigger than 20 Mb in size, so I had to purchase the Venus Service Plan on the ClearDB site.
3. Importing data to a MySql database
WAWS provides a web management interface for SQL Azure databases. But not for MySql databases. That was not a problem however, because there is a well known web application for administering MySql – phpMyAdmin. To import the content of my blog I created a new site under my subscription (10 free sites are allowed per subscription) and installed phpMyAdmin there. phpMyAdmin provides a simple way of importing MySql content into a database:
Unfortunately, phpMyAdmin is not yet available in the Windows Azure Web Application Gallery, so I had to install it manually by following the quick install guide.
Important thing to note about importing data using phpMyAdmin. Import requires uploading a sql file to the server. If the sql file is big, you may run into the PHP limit for maximum allowed size of uploaded file. It is possible to increase the limit by following instructions at Configuring PHP in Windows Azure Websites with .user.ini Files.
4. Point WordPress to new database
Once database import is complete, it is necessary to reconfigure WordPress to use new database. The configuration is stored in wp-config.php file. Change the DB_NAME, DB_USER, DB_PASSWORD, DB_HOST variables to the values provided by ClearDB.
5. Uploading the site content
There are several ways to publish content in WAWS:
In order to simplify publishing, I recommend to set the publishing password to something you can remember. Otherwise you’ll have to use the randomly generated password that WAWS provided for your site.
FTP was good enough for my needs. The FTP host name and user name are available in the site dashboard page. You can use any FTP client. Filezilla works pretty well for uploading large content.
5. Configuring custom domains
After I uploaded content I just browsed to http://ruslany.azurewebsites.com/ and the site was up and running. Obviously I did not want to use this domain for my site, so the next step was to associate http://ruslany.net/ with this site.
Free sites in WAWS are not allowed to have custom domains, so I had to upgrade my site to “Shared” compute mode. Apart from custom domains support, there are other benefits of this mode: less restrictive usage quotas and no outgoing bandwidth limit.
Configuring custom domain is a straightforward process described in Windows Azure documentation. It is a good idea to associate both A record and the WWW CName with a site. In my case for example both http://ruslany.net and http://www.ruslany.net/ are associated with the site:
There are a couple of minor limitations that still need to be fixed in WAWS:
- An old version of Wincache extension is used which causes failures when upgrading plugins.
- It would be nice to have phpMyAdmin available in the Web Application Gallery.
Other than that I am pretty happy with how my site is running in Windows Azure Web Sites so far. WAWS is capable and flexible enough to support all the custom configuration settings that my site uses.
- Wincache object and user caches work well. They reduce load on the MySql database and make the response time faster.
- URL rewriting is fully supported, so my site is still optimized for search engines and has pretty permalinks.
- All the plugins work without problems.
As I find out more tips and tricks about hosting web sites in Windows Azure Web Sites I will write about them in this blog.