In this post, I’ll take you through how you can create a WIMP stack (regardless of the name!) onto a Windows Azure VM really easy. I’m a guy who likes to configure things graphically, so although you can already create a LAMP stack (Linux, Apache, MySQL, PHP) on a Linux VM on Azure pretty easily, I still love Windows and easy management. In a future post, I’ll also document how to create a WAMP stack (Windows, Apache, MySQL, PHP).
You can host PHP sites much easier on Windows Azure Websites, as there is practically ZERO configuration that you need to do and you get .NET, PHP, node.js and Python support out of the box with FTP and Source Control deployment options baked in.
If you must use MySQL as your database, you can opt for a Database as a Service solution provided by ClearDB through Windows Azure, or you can create a Virtual Machine (Windows or Linux) and use it as a dedicated database.
I’m showing you this tutorial for the sake of completeness and in case you really need to manage everything yourself. But I’m telling you, you are probably better off using Windows Azure Websites + ClearDB.
Create a Windows Server 2012 VM
And in the last step, make sure to open up the FTP and HTTP endpoints in the Load Balancer
Click the checkmark and wait for the machine to be provisioned. About 5 minutes.
Login to the new machine using Remote Desktop
Once the machine is ready and is in the Running state, click on its name (or its row), then click on Connect.
Login with the username and password you specified during creating the VM.
Configure the server by adding Web Server IIS (Internet Information Services) role
The Server Manager window should open by default, but if not, open it.
On the Dashboard, go to Quick start then click on Add roles and features
Click Next, then select “Role-based or feature-based installation”
Leave your server preselected and click Next
Scroll down a bit and check Web Server (IIS) and click on Add Features on the dialog that will popup
Click Next then start the installation process
In a few minutes, IIS should be up and running.
Install PHP and MySQL
You could go ahead and download PHP and MySQL separately and then install/configure them manually, or you could go to the easy route and use the brilliant Microsoft Web Platform Installer, which is what I’ll do.
Open up a browser on the server and download the Microsoft WebPI from here http://www.microsoft.com/web/downloads/platform.aspx
When the website loads, click on Free download and run the downloaded installer
When the installer loads up, search for PHP and then add your preferred PHP version
then search for MySQL and add your preferred version
Click on Install to begin the installation
The installer will ask you to choose a password for MySQL, choose a password
Continue and Accept the Terms and Conditions. Web PI will now download and install PHP and MySQL.
Testing the PHP installation worked
On the server navigate to the default IIS web root (C:\inetpub\wwwroot) and add an index.php file with the following content
Save the file then go to http://wimpstack.cloudapp.net/index.php you should find the PHP information page loading up. Congratulations!
(Optional) Install phpMyAdmin to manage your MySQL database
On the server, open up the phpMyAdmin website and download the latest version, then unzip it as phpmyadmin in C:\inetpub\wwwroot
Following the configuration documentation of phpMyAdmin, create an empty config folder under C:\inetpub\wwwroot\phpmyadmin and make sure to grant Write or Full Control permissions to IUSR user then in a browser, go to http://wimpstack.cloudapp.net/phpmyadmin/setup and follow the setup wizard.
Finish the setup, move the config.inc.php file to the root of the phpmyadmin folder then delete the config folder, and you’re in!
(Optional) Add FTP role
In order to easily manage your server, let’s add an FTP role. Follow the same process you did at the beginning to enable Web Server (IIS) role, but this time, expand the Web Server (IIS) node and check FTP Server
In about 1 minutes, the FTP role will be installed.
Add FTP publishing to the Default Web Site
I’m going to select No SSL for now, since I don’t have a certificate
Enable Basic Authentication and for now, grant the Read Write permissions to our administrator user that we created when the machine was provisioned. You can create a different user and use it here if you want.
Due to the way the Windows Azure network functions, we need to enable Passive FTP so we need to do a few more steps.
1. Get the public IP address of the machine from the portal
2. Setup the local passive FTP data channel ports by running the following lines in a command prompt specifying the low data channel port and the high data channel port
3. Opening those ports (in this example, they are ports 7000,7001,7002) in the Virtual Machine endpoints on the portal
4. Enable stateful FTP filtering on the firewall by running this command in a command prompt
then type in the public IP of the machine that you got from the portal then hit Apply
6. Restart the FTP site for the changes to take effect
And we are ready!
Now I admit this was a rather lengthy post with some workarounds (to enable FTP for example), but the point is, Windows Azure is a very flexible platform and no matter what you are trying to run, you will find multiple ways to do it.
Since I spent sometime customizing this server, I can now "Capture" it and make the image available for future provisioning, meaning that when I want to create another WIMP server, I simply select it from the list and it is provisioned, preconfigured!
How cool is that?
To recap my disclaimer at the top, if you are simply hosting websites running on .NET, PHP, node.js or Python, you are most probably better of using Windows Azure Websites, as all the above is already handled for you. When it comes to the database and you prefer MySQL, you can either use ClearDB, which provide regular backups, redundancy, etc., or you might choose to create your own Windows/Linux server running MySQL, but beware that the management overhead is now on your shoulders.
In another couple of posts, I’ll show you how to create a standalone MySQL server and use it with Windows Azure websites, how to create a WAMP server and how to create a LAMP server. The choice is yours!