How to setup PHP on your machine?

After knowing the basic concepts of PHP, the next thing which comes to your mind is “Ok so how do I install PHP on my machine?”, so before proceeding further all you need is a proper environment setup on your machine.

Well this article will guide you for the same.

Installing PHP with Apache

Apache is the web server which is developed and maintained by Apache Software Foundation. It is available for various operating system like UNIX, LINUX, WINDOWS etc.

Steps for installing PHP with Apache Sever

  1. Download the Apache Windows MSI Installer from http://httpd.apache.org/download.cgi
  2. Download the PHP Windows Zip package from http://php.net/downloads.php
  3. Execute the file downloaded for Apache , while installing Apache server it will ask to fill the information. The typical setup will use the default port 80.
  4. Select typical set up
  5. Choose the destination folder for the server. By default it will be C:Program FilesApache Software Foundation
  6. Select finish to complete the installation.

After this the Apache server needs to be configured as following.

  1. Open httpd.conf file for editing on any editor like notepad. httpd.conf  will be in sub directory called conf in your directory of apache. Alternatively , a shortcut may be found in the start menu under the Apache HTTP Server folder.
  2. Change the DocumentRoot  to point to the location of the root document folder.
  3. In the default httpd.conf file , this is found on the line 149 and if the defaults were used during installation , it would point to “C:Program FilesApache Software FoundationApache 2.2htdocs”
  4. Change the directory path to match the one used in previous step . That can be found on line 177 of the default httpd.conf file. Add  index.php to the Directory Index. This is found on line 212 of the default http.conf file.
  5. Append the following lines to the end of the httpd.conf file:
    1. LoadMoudle php_module
    2. AddType application/x-httpd-php.php
    3. PHPIniDir “C:php”
  6. Save and Close.

Installing PHP

  1. Unzip the PHP files to C:php
  2. Copy C:phpphp-ini-recommended.ini  and rename it as C:phpphp.ini
  3. Uncomment the windows include_path from line 506
  4. Update the doc_root to match the one that was set up in the httpd.conf file on line 513.
  5. Update the extension_dir on line 520 to “C:phpext”
  6. Uncomment php_gd2.dll extension on line 637.
  7. Uncomment mysql.dll extension on line 651.
  8. Update the session.save_path to the windows temporary files directory ( i.e C:Temp).
  9. The PHP Directory needs to be added to the path environment variables
  10. Open the control panel
  11. Open System > Advanced > Environment Variables
  12.  Append C:php to the end of Path System Variables list and click OK.
  13. Restart Apache.

Well that’s it you are now ready with your PHP

To test PHP go to root directory , create a new php file on it and type following code in it.


Save it as prog.php and run it.

There are other ways available to install PHP

The other and simplest technique to install and use PHP, Apache & MySQL is to use the tool like  WAMP , LAMP , XAMPP

WAMP is an acronym for Windows (OS), Apache (web-server), MySQL (database), PHP (language).

LAMP is an acronym for Windows (OS), Apache (web-server), MySQL (database), PHP (language).

XAMPP is an acronym for X(any Operating System), Apache(Web server), MySQL Database, PHP Language and PERL.

Here we will cover how to install XAMPP the process for WAMP & LAMP are almost similar.

Installing XAMPP

XAMPP is a control panel developed and programmed by Apache. It contains different services like Apache, PHP, MySQL, Fillezilla

Steps

  1. Download latest version of XAMPP from http://www.apachefriends.org/en/xampp-windows.html
  2. Double click on the file which you have downloaded
  3. You will get a installation wizard where it will ask where you want to install your XAMPP , by default it will be C: drive , so if you want to change the installation drive you can change it
  4. After that click on install button and it will start extracting files.
  5. Once all the files are extracted this will configure all the necessary setting and file paths automatically, which we have done manually for previous installation. Press any key to continue after that
  6. Well that’s it you have successfully installed XAMPP which will allow you to develop and execute PHP scripts on your computer.
  7. To Start Services , go to Windows>All Programs > Select XAMPP
  8. Click on XAMPP control panel start the required services
  9. Open the browser type http://localhost.
  10. Its done enjoy learning PHP now.

 

Share this Article on Social Media

Get Updates, Scripts & Other Tutorials to Directly to your Email

Over 20000+ Happy Readers already subscribed. (We don't send spam email). Every email subscriber can get our latest updates and download our 100+ scripts.

Comments