Delen via


Creating a WIMP Stack (Windows Server, IIS, MySQL, PHP) on Windows Azure

Introduction

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).

Disclaimer: 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.

Let’s start

Create a Windows Server 2012 VM

image

image

image

And in the last step, make sure to open up the FTP and HTTP endpoints in the Load Balancer

image

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.

image

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.

image

On the Dashboard, go to Quick start then click on Add roles and features

image

Click Next, then select “Role-based or feature-based installation”

image

Leave your server preselected and click Next

image

Scroll down a bit and check Web Server (IIS) and click on Add Features on the dialog that will popup

image

Click Next then start the installation process

image

In a few minutes, IIS should be up and running.

image

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 https://www.microsoft.com/web/downloads/platform.aspx

When the website loads, click on Free download and run the downloaded installer

image

When the installer loads up, search for PHP and then add your preferred PHP version

image

then search for MySQL and add your preferred version

image

Click on Install to begin the installation

The installer will ask you to choose a password for MySQL, choose a password

image

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

 <?php
 phpinfo();
 ?>

Save the file then go to https://wimpstack.cloudapp.net/index.php you should find the PHP information page loading up. Congratulations!

image

(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 https://wimpstack.cloudapp.net/phpmyadmin/setup and follow the setup wizard.

image

image

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!

image

(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

image

In about 1 minutes, the FTP role will be installed.

Configure FTP

Add FTP publishing to the Default Web Site

image

I’m going to select No SSL for now, since I don’t have a certificate

image

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.

image

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

image

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

 cd %windir%system32/inetsrv
 appcmd set config /section:system.ftpServer/firewallSupport /lowDataChannelPort:7000 /highDataChannelPort:7002

3. Opening those ports (in this example, they are ports 7000,7001,7002) in the Virtual Machine endpoints on the portal

image

4. Enable stateful FTP filtering on the firewall by running this command in a command prompt

 netsh advfirewall set global StatefulFtp enable

5. Configure the FTP server to allow Passive FTP. Open FTP Firewall support
image

then type in the public IP of the machine that you got from the portal then hit Apply

 image

6. Restart the FTP site for the changes to take effect

image

And we are ready!

image

Closing

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!

Note: This post is cross posted to my new blog at https://sabbour.me/

Comments

  • Anonymous
    November 14, 2013
    nice blog and great information about Creating a WIMP Stack (Windows Server, IIS, MySQL, PHP) on Windows Azure and <a href="www.datasparc.com/mysql-manager-and-mysql-gui-tools.html"> mysql manager </a> .

  • Anonymous
    March 02, 2014
    I have followed your tutorial, however opening the ports in the firewall with the command did not work, i had to manually allow them. Yet, Directory Listenig (command LIST response 150 opening BINARY mode data connection.) results in a timeout and can't retreive directory content. any idea how to fix that?

  • Anonymous
    March 02, 2014
    Found the error. You have to open Port 20 in the Azure Endpoint.

  • Anonymous
    May 18, 2014
    The comment has been removed

  • Anonymous
    May 21, 2015
    The comment has been removed

  • Anonymous
    June 19, 2015
    Just install Visual C++ Redistributable x64 and it should work www.microsoft.com/.../details.aspx

  • Anonymous
    July 14, 2015
    One small typo: cd %windir%system32/inetsrv should be cd %windir%/system32/inetsrv