In this section we will Install PHP for developing our example applications.
PHP 5.0. Installation
PHP is an open source software and is available under PHP and General Public License (GPL) at free of cost. It can be downloaded from its official website http://www.php.net/downloads.php
But before installing, first lets us know about the system requirement, PHP installation, its configuration and customization.
To run the code of PHP, it requires a web server, a Relational Database Management System (RDBMS), a Web browser and a Text Editor.
In computer configuration, modern normal PCs are adequate proficient while in older, the configuration must be equal to or above like 128 MB RAM, 2 GB hard disk drive and Pentium IV processor for running PHP properly.
System Requirements for PHP Install
For properly running PHP code, you will need some basic software a Relational Database Management System (RDBMS), a web browser, a Text Editor, a Web server for compiling and running PHP and PHP itself compatible to the operating system.
A different configuration of PHP is required to run on different platforms like PHP 5.0 for Windows, PHP 5.0 for Linux and PHP 5.0 for Mac OS X.
Now, it depends upon you, which version of PHP do you want to install. PHP for all the above three OS X is available on its official website www.php.net
and can be downloaded from it without paying the license fee.
You can choose a PHP-compatible Web server such as Apache or Internet Information Server (IIS) for compiling and running PHP scripts. The IIS can be installed from the MS Windows OS CD while Apache is available freely and can be downloaded from its official website: httpd.apache.org/download.cgi
In RDBMS, you can select either SQLite or MySQL. SQLite can be downloaded from http://www.sqlite.org/download.html
while MySQL can be downloaded from http://www.mysql.com
A Web browser such as IE, Mozilla, and Safari so on can be downloaded and installed from their official websites. Install browser compatible to your operating system.
In text editor, you can opt one among EditPlus, Notepad, Emacs, vi, BBEdit. Usually EditPlus is a better option and available on both free and paid categories. Text Editor will be used for writing codes in PHP.
All the above-mentioned software can be downloaded on a single computer. For installing on a network computer, install all of your server software on one server and use another networked computer as your client machine.
PHP Installing on Windows
Install PHP 5.0 as well as other necessary software in the chronological order; first install and test MySQL, then install and test Apache Web Server, then a text editor and finally install PHP 5.0 or above version and integrate it to Apache web server.
Download & Unpack
Download and install PHP for Windows from http://windows.php.net/download/ Here you will find all the updated versions from novice to newest 5.x.x Windows Binaries zip package that will work on Apache.
My file was named: php-5.3.0.zip
In my case, I unzipped to:
it to php.ini
Edit your php.ini
Open php.ini in a text editor and find doc_root, now change it to point to whatever your Apache DocumentRoot is set to. I set the path: doc_root = "C:\public_html"
Now, scroll down about 7 more lines and change the extension_dir from extension_dir = "./" to the location of the ext directory after you unzipped PHP. As I did:
extension_dir = "C:\php\ext"
If you want to test it on web server, i recommend (this is optional) you search and change the ‘error reporting’ to give you info on any error, notice, or bad coding. If you want to enable this type of stuff, search for error_reporting for and change:
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT
error_reporting = E_ALL | E_NOTICE | E_STRICT
Editing Apache Conf File
Open httpd.conf in the text editor like notepad (recommended) and add the following lines:
LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
Please note that the changes should be held in both C:/php parts to the directory you had installed.
Find Apache httpd.conf configuration file from Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File".
[OPTIONAL] Editing Apache Conf File (part 2)
If you want to get apache automatically look for an index.php, search httpd.conf for DirectoryIndex (about line 212) and add the files you want apache to look for when a directory is loaded (if it doesn't find any of these files, it displays folder contents). It may looks like:
DirectoryIndex index.php index.html default.html
For testing PHP on Apache Server, first restart it if it is already running. Now, create a test.php file in your your Apache "DocumentRoot" folder. Type these 3 lines in your test.php file and then load the file in your browser like http://localhost/test.php:
Unlike other software, PHP comes with no documents in the PHP package; the users will have to download those separately. The download can be found on: http://www.php.net/download-docs.php