Friday, June 20, 2008

server admin: installing apache, mysql and php in windows XP

I recently attended the first Joomla! Day Philippines and got a nice looking shirt. I've been wanting to experiment with it (Joomla, not the shirt) but I just couldn't find time because of lesson plans and other school related stuff. Since we'll be having a faculty day tomorrow at the Ateneo, I opted to spend my time today to document the steps I went through in creating my WAMP (Windows, Apache, MySQL, PHP) server.

The guys at the seminar recommended one-click packages such as WAMP and XAMPP but I think I'd prefer manual configuration of each component to have more background on how they work. But if your just installing this server for local web development, I suggest the two packages above. As for me, I just want to feel how each component is configured so I opted for separate installations.

Here are the steps I went through:

1. Install the Apache server

1.1. Download the latest MSI installer (e.g. apache_2.2.8-win32-x86-openssl-0.9.8g) from httpd.apache.org. You can also download the ZIP file of all source files but you still have to compile them.

1.2. Double click on the installation package. The installation is pretty straight forward except at the point where it asks you the Server information.

1.3. Input the appropriate server information. Since, I don't have a DNS at home, I'm using the actual IP address of my computer. However, for most cases, you just want to type in "localhost" for the fields:

1.4. Modify where you want to install Apache. For my case, since I want to put all server applications in one location, I created a C:\Server folder and installed Apache in a folder inside it named "Apache".

1.5. Test your installation by going to your server's address using your browser: "http://192.168.0.198/" or "http://localhost/". A page with text "It Works!" should appear.

1.6. Configure your installation. Apache configuration is written in a file called "httpd.conf". To modify it, go to Start-> All Programs -> Apache HTTP Server 2.2 -> Configure Apache Server.
Here are the lines I modified:

a. I moved the folder where Apache will look for html files to C:/www so that when I uninstall apache, files that I am currently working on will not be mistakenly deleted.
# rod: DocumentRoot "C:/Server/Apache/htdocs"
DocumentRoot "C:/www"
b. # rod: Listen 80
Listen: 192.168.0.198:80
c. # rod: <Directory "C:\Server/Apache/htdocs">>
<Directory "C:\www">
1.7. Test your modifications by creating a simple page and placing it in your new DocumentRoot folder.

2. Install and configure the MySQL Database server

2.1. Download the latest installation package from mysql.com.

2.2. Extract the installation package and double click on "Setup.exe".

2.3. Select custom installation. I selected this option because I want to modify where I want MySQL to be installed, otherwise you ought to use typical installation. I installed in "C:\Server\MySQL5\"

2.4. Finish the installation but make sure that "Configure the MySQL Server now" checkbox is checked.

2.5. Select the following configurations (these are basically default unloess otherwise noted):
- Detailed Configuration
- Server Machine
- Multifunctional Database
- Decision Support (DSS)/OLAP
- Enable TCP/IP Networking
- Enable Strict Mode
- Standard Character Set
- Install as Windows Service
- Include Bin Directory in Windows PATH (not default)

2.6. Input your root account password and execute the configuration:

2.7. Test the installation by running mysql: Start->All Programs->MySQL->MySQL Server 5.0->MySQL Command Line Client. We should be able to see the following in the command prompt after inputting the root password.

3. Install the PHP engine

3.1. Download the latest version of PHP from www.php.net. I downloaded the ZIP version. I came across one tutorial which said that using the ZIP file has advantages when you want to uninstall PHP. Instead of actually uninstalling it, all you have to do is delete the unzipped files.

3.2. Unzip the files. For my case, I unzipped all files in "C:\Server\PHP5". This step already completes the installation of the PHP engine. However, we still need to inform Apache that we have a PHP engine and how to locate it. The next steps will cover this problem.

3.3. Open the Apache configuration file "httpd.conf" found in "C:\Server\Apache\conf\"

3.4. Add the following lines:

LoadModule php5_module "c:\Server\PHP5\php5apache2_2.dll"
PHPIniDir "c:\server\PHP5"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

3.5. Go to "C:\Server\PHP5\" and rename "php.ini-recommended" to "php.ini"

3.6. Open the file.

3.7. Locate the line: extension_dir = "./" .

3.8. Change to: extension_dir "C:\Server\PHP5\ext\".

3.9.
Find the line that reads: ;extension=php_mysql.dll Delete the ; so that the line now reads: extension=php_mysql.dll.

3.10. Open the directory "C:\Server\MySQL5\bin".

3.11. Find the file "libmysql.dll" and copy it to "C:\Windows\System32".

3.12. Test our PHP installation by creating a file containing <?PHP phpinfo() ?> in the DocumentRoot and opening it on our browser. The output should look like something like this:

-- fin

Up next, in this server administration series:

managing your database using phpmyadmin
using the MySQL command line client (for CIE 122)
implementing a file upload system (for my CE 21 class)
installing apache, mysql and php in linux
installing Joomla!
installing the wordpress engine to your server
installing tWiki into your server
installing an ftp server
installing a mail server
enabling ruby on rails on your WAMP or LAMP server

No comments: