Web developers wants to run Apache and PHP on their machine for a convenient way for script testing. This will allow them to eliminate or decrease bugs before they put it in the cloud. This post will teach you how to install Apache, PHP5 and PostgreSQL.
NOTE: There is a software bundle called WAPP that automatically configures Apache, PHP and PostreSQL to work side-by-side but software bundles usually have disadvantages and sometimes will not give the users the full capabilities of the softwares involved.
How To Install PostgreSQL:
1. Visit PostreSQL’s download page and download the binary installer of the version you prefer to use. The latest is PostgreSQL v.9.0
2. After downloading, run the installer.
3. A wizard will guide you throughout the installation process. Let the fields have default values(recommended for beginners).
How To Install Apache:
1. Visit Apache.org and download the Win32 Binary Installer(MSI Installer) for any Apache version you want. The la version is Apache 2.2.x.
2. A wizard will guide you through the installation process. In the Server Information part, enter localhost. In the last field, enter your email address. (See image for more info)
3. Select the option All Users, on Port 80, as a Service. This will allow Apache to run in the backround. Click Next
4. Finish all the dialog boxes with default options unchanged. Click Install to finish the Apache installation. Don’t be alarmed if Windows Command Prompt open and close several times. This is normal.
5. After the installation, open a web browser and type the url http://localhost. You should see a page that say that Apache is working.
You’re done installing Apache!
How To Install PHP5
1. Go to the PHP download page. Choose the package you want to download. I recommend using the Thread Safe version. You can choose the binary installer for Windows but I will use the zip package in this tutorial.
2. Create a folder PHP in your hard disk for PHP. I strongly recommend using C:/PHP.
3. Unzip all the files in the directory you created. The PHP folder will now contain several other folders and about 30 files.
4. In the PHP folder, locate the file called php.ini-development. Make a copy of it and rename the copy php.ini
5. Open the php.ini file with any text editor.
6. Configure the following:
Enable Short Open Tags
Search the line: short_open_tag = Off and change it to short_open_tag = On
Go to the Error Handling ang Logging Section and locate error_reporting = E_ALL & ~E_NOTICE and change it to error_reporting = E_ALL
This will ensure that your PHP is robust.
Go to the Path and Directories Section and locate extension_dir = “./” and change it to extension_dir = “C:\php\ext\”
NOTE: Change the path to where you extracted the PHP files.
Go to the Dynamic Extensions Section. You will see a long list of titled Windows Extensions. You can enable these extra features any time by removing the semicolon from the beginning of the line for the extension you want. Here’s a list of important extensions:
;extension=php_mysql.dll and ;extension=php_mysqli.dll and add these two lines extension=php_pdo.dll and extension=php_pdo_mysql.dll– for mySQL
;extension=php_pdo_pgsql.dll and ;extension=phppgsql.dll -for PostgreSQL
Go to the Module Setting Section. Edit only for Mail Function
Change SMTP = localhost to SMTP = smtp.yahoo.com
Note: Change smtp.example.com to your appropriate outgoing address. For instance, your email address is email@example.com, your outgoing address is probably smtp.yahoo.com. Remove the semicolon from the beginning of the line
sendmail_from = then put the necessary email address.
Last, locate this line
;session.save_path = “/tmp”
Remove the semicolon from the beginning of the line and change the setting in quotes to
session.save_path = “C:\Windows\Temp”
7. Save and close php.ini
Add PHP to your environment variables:
1. Open the Windows Contol Panel(Start -> Settings -> Control Panel). Double Click the System icon. Select the Advanced tab and click Environment Variables
2. In the System Variables pane at the bottom of the dialog box, highlight Path and click Edit
3. A smaller dialog box will open. Edit the Variable value field. Insert the path where you placed your PHP folder. Click OK
4. Create a System Variable with variable name PHPRC. The variable value is the path to your PHP folder.
5. Click OK to close all the dialog boxes.
Configure Apache to work with PHP
1. Locate and open the Apache configuration file httpd.conf using a script editor. The file is located in C:\Program Files\Apache Software Foundation\Apache2.2\conf (for Apache 2.2)
2. Find the list of items that being with LoadModule. At the end of the list, add
LoadModule php5_module “C:/php/php5apache2_2.dll” (for Apache 2.2)
LoadModule php5_module “C:/php/php5apache2.dll” (for Apache 2.0)
3. Locate this line
DirectoryIndex index.html and replace it with
DirectoryIndex index.html index.php
4. Find the AddType commands and add
AddType application/x-httpd-php .php
5. At the end of httpd.conf file add
PHPIniDir “C:/PHP” Note: Change path accordingly
Restart the Apache Web Server
How To Test Your PHP Installation:
1. Create a php file containing
<?php phpinfo(); ?>
2. Save the file as index.php. Place it in the htdocs folder located in your Apache folder.(eg. C:\Program Files\Apache Software Foundation\Apache2.2\htdocs)
3. Open your web browser and type in the url http://localhost/index.php. If PHP installation was successful, this would display all the information about your PHP installation.
Congratulations! You’re done with the tutorial!
Happy Coding! Let’s be PHP(Positively Happy People)!
Email me if you have questions or you need assistance: