Como instalar IIS 8, Mysql 5.5 e PHP 5 no Windows 2012 Server

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

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.

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.

(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\phpmyadminand make sure to grant Write or Full Control permissions to IUSR user then in a browser, go tohttp://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.

Configure FTP

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

netsh advfirewall set global StatefulFtp enable

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

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!

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.

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!

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?

[18-May-2014 06:59:23 America/Los_Angeles] PHP Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in D:homesitewwwrootAdminPanelclassdbclass.php on line 10

[18-May-2014 06:59:23 America/Los_Angeles] PHP Warning: mysql_connect(): An attempt was made to access a socket in a way forbidden by its access permissions.