• PHP Video Tutorials

PHP - Installation



You can start learning the basics of programming in PHP with the help of any of the online PHP compilers freely available on the Internet. This will help in getting acquainted with the features of PHP without installing it on your computer. Later on, install a full-fledged PHP environment on your local machine.

One such online PHP compiler is provided by Tutorialpoint’s "Coding Ground for Developers". Visit https://www.tutorialspoint.com/codingground.htm, enter PHP script and execute it.

PHP Installation

However, to be able to learn the advanced features of PHP, particularly related to the web concepts such as server variables, using backend databases, etc., you need to install the PHP environment on your local machine.

In order to develop and run PHP Web pages, you neeed to install three vital components on your computer system.

  • Web Server − PHP will work with virtually all Web Server software, including Microsoft's Internet Information Server (IIS), NGNIX, or Lighttpd etc. The most often used web server software is the freely available Apache Server. Download Apache for free here − https://httpd.apache.org/download.cgi

  • Database − PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database. Download MySQL for free here − https://www.mysql.com/downloads/

  • PHP Parser − In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser.

Although it is possible to install these three components separately, and configure the installation correctly, it is a little complex process, particularly for the beginners. Instead, using any all-in-one packaged distribution that contains precompiled Apache, MySQL and PHP binaries is convenient.

XAMPP Installation

There are many precompiled bundles available both in open-source as well as proprietary distributions. XAMPP, from Apache Friends (https://www.apachefriends.org/) is one of the most popular PHP enabled web server packages. We shall be using XAMPP in this tutorial.

XAMPP is an easy to install Apache distribution that contains Apache, MariaDB, PHP and Perl. The letter X in the acronym indicates that it is a cross-platform software, available for use on Windows, Linux and OS X. Note that XAMPP includes MariaDB, which is a fork of MySQL, with no difference in its functionality.

To download the respective installer for your operating system, visit https://www.apachefriends.org/download.html, and download one of the following −

Using the installer on Windows is a completely wizard based installation. All you need to provide is an administrator access and the location of the installation directory which is "c:\xampp" by default.

To install XAMPP on Linux, use the following steps −

Step 1 − Change the permissions to the installer −

chmod 755 xampp-linux-*-installer.run

Run the installer −

sudo ./xampp-linux-*-installer.run

XAMPP is now installed below the "/opt/lamp" directory.

Step 2 − To start XAMPP simply call this command −

sudo /opt/lampp/lampp start

You should now see something like this on your screen −

Starting XAMPP ...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.
Ready. Apache and MySQL are running.

You can also use a graphical tool to manage your servers easily. You can start this tool with the following commands −

cd /opt/lampp
sudo ./manager-linux.run (or manager-linux-x64.run)

Step 3 − To stop XAMPP simply call this command −

sudo /opt/lampp/lampp stop

You should now see something like this on your screen −

Stopping XAMPP ...
LAMPP: Stopping Apache...
LAMPP: Stopping MySQL...
LAMPP stopped.

Also, note that there is a graphical tool that you can use to start/stop your servers easily. You can start this tool with the following commands −

cd /opt/lampp
sudo ./manager-linux.run (or manager-linux-x64.run)

If you are using OS X, follow these steps −

  • To start the installation, Open the DMG-Image, and double-click the image to start the installation process.

  • To start XAMPP simply open XAMPP Control and start Apache, MySQL and ProFTPD. The name of the XAMPP Control is "manager-osx".

  • To stop XAMPP simply open XAMPP Control and stop the servers. The name of the XAMPP Control is "manager-osx".

  • The XAMPP control panel is a GUI tool from which the Apache server, and MySQL can be easily started and stopped.

PHP Installation 2

Press the Admin button after starting the Apache module. The XAMPP homepage appears like the one shown below −

PHP Installation 3

PHP Parser Installation

Before you proceed it is important to make sure that you have proper environment setup on your machine to develop your web programs using PHP.

Type the following address into your browser's address box.

http://127.0.0.1/info.php

If this displays a page showing your PHP installation related information then it means you have PHP and Webserver installed properly. Otherwise you have to follow given procedure to install PHP on your computer.

This section will guide you to install and configure PHP over the following four platforms −

Apache Configuration

If you are using Apache as a Web Server then this section will guide you to edit Apache Configuration Files.

Just Check it here − PHP Configuration in Apache Server

PHP.INI File Configuration

The PHP configuration file, php.ini, is the final and most immediate way to affect PHP's functionality.

Just Check it here − PHP.INI File Configuration

Windows IIS Configuration

To configure IIS on your Windows machine you can refer your IIS Reference Manual shipped along with IIS.

You now have a complete PHP development environment on your local machine.

Advertisements