Wednesday, January 2, 2008

How-to Create a Windows Vista IIS7 MySQL PHP Web Server


Introduction
This guide shows you how to create a Windows Vista powered web server using IIS7, MySQL, and PHP (WIMP). I know, I know, a WIMP server doesn’t sound too appealing. Trust me, this server is far from a wimp and will blow your socks off if you provide the right hardware.
Note: This is a generic WIMP server that’s capable of running
WordPress, PHPbb, and other popular PHP and MySQL powered web sites. You might have to change a few things to get your WIMP server running just right depending on your usage.
The Limitations
Before you go too far you need to know that IIS7 running on Windows Vista is full featured with a few limitations.
Before you right this type of server off because it’s limited you need to realize if you ever reach one of the limitations you’ll have so much traffic you could probably buy an actual server with one day’s pay from the web site.
The Limitations
Request Execution Limit: IIS7 running on Windows Vista Basic, Starter, Home, and Home Premium have a Request Execution Limit of 3. Vista Ultimate is limited to 10. Request Execution Limit is how many simultaneous pages the web server can give out at one time. That means Vista Basic, Starter, and Home editions can serve up to 259,200 pages per day and Ultimate can serve up to 864,000 pages per day!
FTP: FTP is very limited. You can only download files as anonymous. No uploading via FTP to your web server. If this is a problem, check out the
FileZilla FTP Server.
Install IIS7
First thing first, we need to install a web server.
Open the Control Panel in classic view.
Double-click Programs and Features.
Click Turn Windows features on or off on the left.
Check off Internet Information Services.
Expand Internet Information Services, World Wide Web Services, Application Development Features, and then check off ISAPI Extensions। ISAPI will be needed later when we install PHP.





Click OK to install IIS7.
When the Windows Features box disappears IIS7 is installed and should be running. Test IIS7 by going to http://localhost in your web browser। You should see an IIS7 test page like the screenshot below.



The root of the default web site is located at C:\inetpub\wwwroot. Your web site goes there.
Install PHP
Now that we have a web server we need support for PHP. In this example I’m installing PHP 5.2.4.
Create a folder called php in the root of the C: drive.
Download the Windows Binaries Zip package from
http://www.php.net/downloads.php.
Extract the files and save them in the php folder you just created.
Copy C:\php\php.ini-dist and save it on your desktop so we can work with it.
Rename php.ini-dist you just copied on your desktop to php.ini.
Right-click php.ini and select Edit.
Search for extension=php_mysql.dll and uncomment it by deleting the ; in front of it. This allows php to login a MySQL database.
Now move up in the php.ini code and look for extension_dir = “./”. Change “./” to “C:\php\ext”. This shows php where to load the extension=php_mysql.dll extension you just uncommented.
Save php.ini.
Copy php.ini and save it in C:\Windows.
Open the IIS Manager by typing IIS Manager in the Start Menu’s search box and click Internet Information Services (IIS) Manager in the search results.
Double-click Handler Mappings.
Click Add Script Map located on the right.
Fill out the Add Script Map window like the screen shot below.


Click OK to save the changes.
Click Yes in the window that asks you if you want to enable this ISAPI extension.
Click the back button in the IIS Manager and then double-click Default Document.
Type index.php, with a space behind , in the File names list.
Click Apply on the top right of IIS Manager.
Now you need to copy libmysql.dll from C:\php and save it in C:\WINDOWS\System32. Thanks for the fix Oruba.
Lets test to make sure php is installed and running correctly.
Open notepad.
Type < ? phpInfo() ?> in the blank document.
Note: Remove the space between < ? in < ? phoInfo() ?>. I had to add the space so the command doesn’t execute on this page.
Save it as test.php on your desktop and then move it to C:\inetpub\wwwroot.
Note: A common mistake when saving test.php is to save it as test.php.txt. Don’t forget to select All files under Save as type and then name the file test.php in notepad.
Go to http://localhost/test।php। You should get a php information page similar to the screen shot below.
Install MySQL
Before we can install MySQL we need to disable UAC in Windows Vista।


Open the Control Panel in classic view.
Click User Accounts.
Click Turn User Account Control on or off.
Uncheck Use User Account Control and then click OK.
Restart your computer.
Note: You can turn UAC back on after everything has been installed and working.
Now we can install MySQL. In this example I’m going to install MySQL Community Edition 5.0.45.
Download the Windows ZIP/setup.exe version
http://dev.mysql.com/downloads/mysql/5.0.html#win32.
Unzip it and save setup.exe on your desktop.
Run Setup.exe.
The welcome window will popup। Click Next.


Since this is a general guide on creating a WIMP server leave Typical selected and click Next.

Let MySQL install in its default directory by simply clicking Install in this window.

Click Next to move through a few advertisements.
Leave Configure the MySQL Server now checked and click Finished.

Click Next at the welcome window.

I’m assuming that you don’t need to configure any advanced MySQL settings. If you did you probably wouldn’t need this guide or you should leave this job to an expert. Select Standard Configuration and then click Next.

Leave Install As Windows Service, the service name MySQL, and Launch MySQL Automatically checked and click Next.

Type the MySQL administrator (root) password twice and then click Next.

This part is VERY important. Hold your mouth just right, cross your fingers and click Execute to configure MySQL. If you did it just right you should get 4 check marks when it’s done.

Note: If you get a Connection Error, click Retry and it should work. This is caused by a slower computer not starting the MySQL service fast enough.
Click Finished.
Now that you have MySQL installed and running lets install the GUI Tools to make managing databases easy.
Download the GUI Tools (Windows x86) at
http://dev.mysql.com/downloads/gui-tools/5.0.html.
Install it just like any other software.
Click Start, All Programs, MySQL, MySQL Administrator.
Fill in the fields just like the screen shot below.

Remember: Root’s password is the one you set when you installed MySQL.
Once MySQL Administrator is open, you can create a new database by clicking Catalogs and then right-clicking under test and select Create Schema.

Give it a name and there you go!

Open Port 80
Now that you have a working WIMP lets open it up to the world। All internet (HTTP) traffic passes through port 80. Let’s open port 80 to the world.


Search for firewall in the search box in the Start Menu and click Windows Firewall in the search results.
Click the Exceptions tab in the Windows Firewall Settings window.

Click the Add port button.
Type HTTP as the name and 80 as the port number.

Adjust Vista for Web Server Performance
Because Windows Vista is not meant to be a server out of the box its priorities are backwards when it’s being used as a web server. Windows Vista prioritizes programs like Word before background services like IIS7 to give the end user the best experience possible. Since we’re configuring Windows Vista as a web server background services need to be Vistas priority instead of programs.
Let’s set Windows Vista’s services as a higher priority than programs to squeeze the most speed out of it as we can.
Right-click Computer in the Start Menu and then select Properties.
Click Advanced system settings.
Click Settings under Performance in the Advanced tab of the System Properties window.
Click the Advanced tab in the Performance Options window.
Select Background services.
Click OK and then restart your computer।


Hardware
A web server with low to modest traffic doesn’t have to be a powerful machine to get the job done। Any modern PC with at least 1GBs of RAM (2GBs recommended for MySQL) will do fine. If you become one of the fortunate ones who receives enough traffic to need a high performance web server here are a few hardware tips.


Memory: If you’re expecting any kind of modest traffic (many thousands of hits per day) memory is very important. 2GBs is a good start but 3 or 4 are better.
IIS7: A powerful processor(s) and a good amount of memory are important.
MySQL: A fast hard drive and lots of memory are important for a MySQL database.

No comments: