If you want to learn writing and executing PHP scripts, you need PHP software to practice it yourself. Here are the steps for installing PHP in your system (Here, Windows 7 (32 bit) has been used).
Go to the download site: http://www.php.net/downloads.php
Download any of the complete source code.
Then click on Windows 5.4.6 binaries and source, download VC9 x86 Non Thread Safe in zip folder.
To run this application, you need Visual C++ package which can be downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=5582.
A webserver is required for executing PHP scripts. You can use Apache or IIS (Internet Information Service).
For downloading Apache, go to http://httpd.apache.org/download.cgi, download the msi installer file.
If you want to use IIS instead of Apache, download IIS from http://www.microsoft.com/en-us/download/details.aspx?id=2299, choose the files according to your system requirements.
After installation of PHP and Apache, you need to do configuration also which is as follows:
1) Go to C:/php/ext
Copy php.ini-development file from your Apache directory to Windows directory and rename it as php.ini and edit the following:
extension_dir = “C:/php/ext”
2) Remove semicolon in the following .dll files:
- php_curl.dll
- php_gd2.dll
- php_mbstring.dll
- php_mysql.dll
- php_mysqli.dll
- php_pdo.dll
- php_pdo_mysql.dll
- php_xmlrpc.dll
3) Go to C:/Program files/Apache Software Foundation/Apache 2.2/conf and open the file httpd.conf with notepad. Find the word DocumentRoot which appears twice in the file, change the paths at both the places as : C:/Program files/Apache Software Foundation/Apache 2.2/conf. Add the following lines in that file:
# PHP5 module
LoadModule php5_module “c:/php/php5apache2_2.dll”
AddType application/x-httpd-php .php
And edit the line : PHPIniDir “C:/php”
Edit ServerRoot C:/Program files/Apache Software Foundation/Apache 2.2
Add index.php at the end of the file as the Directory index as follows:
Directory Index index.html index.php
5)Add C:/php to the environment variable:
Right clicking My computer-> properties-> Remote Settings->Advanced tab-> Environment Variables; choose path variable, edit it and add C:/php at the end. Click ok.
In the same way, configuration is done in IIS also if it’s been used as a webserver.
6) Goto run, type services.msc, stop the IIS service and World Wide Web Publishing Service and restart again. Reboot your system.
7) Open notepad, type <?php phpinfo(); ?> and save it as index.php in C:
C:/Program files/Apache Software Foundation/Apache 2.2/htdocs
Open web browser and type http://localhost/index.php
The page displaying information about PHP will open.
A very good way of installing PHP is using Wampserver which will automatically install PHP and webserver in your system. You can download Wampserver at http://www.wampserver.com/en/, choose the wampserver accordingly.
After installing Wampserver, you will see it is pinned in the task bar at the bottom near the speaker icon, click it and you will see a dialogue box.
Click on localhost and the PHP info page will open.
If this page appears, it shows PHP has been installed correctly.
Now create a PHP code in notepad and save it in c:/wamp/www with the extension .php at the end eg, prog.php. Open the web browser and type http://localhost/prog.php and you will get the result.
Now that you know how to install PHP, continue with the first PHP tutorial where you will learn the basics of PHP. Also, if you have any queries, please leave a comment below.