How to set up PHP environment to execute PHP code

Setting up PHP

Setting up PHP to run web pages at your computer system is not very hard these days. We will explain traditional and latest ways where you will need to install just an application to set up all components.

Traditionally it needs 3 vital components to be installed to run your PHP web pages.

Components required setting up PHP

Following components are required to install PHP to be able to start development.

Web Server

Web Server – PHP works with almost all Web Servers software, including Microsoft’s Internet Information Server (IIS), however, commonly used is freely available Apache Server. Download Apache from their official website here: http://httpd.apache.org/download.cgi

Database

PHP works with almost every database software that includes Oracle, MS SQL Server, Sybase, however, most commonly used is freely available MySQL database.

You can download MySQL for free from the official website here: http://www.mysql.com/downloads/

PHP Parser

To be able to process PHP script code, a parser has to be installed to generate HTML output. This will be sent to the Web Browser.

The next section will lead you how to install PHP parser on your computer.

PHP Parser Installation

Before you proceed to develop PHP programs, it is important to ensure that you have the proper environment set up on your development machine.

To check that –>

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

http://localhost/info.php

OR

http://[your ip]/info.php

If this shows a page that displays the PHP installation related information, that means you have PHP and Web server installed correctly.

Otherwise, follow the instructions below:

Install and configure PHP

This part will show you how to install and configure PHP on the following platforms:

Install PHP on Linux or Unix with Apache Web Server

Install PHP on Mac OS X with Apache Web Server

Install PHP on Windows NT/2000/XP with IIS Web Server

Install PHP on Windows NT/2000/XP with Apache Web Server

Configuration of Apache Web Server

If you are planning to use Apache as a Web Server then this section will help you to modify Apache Configuration Files.

PHP Configuration in Apache Server

Looking up PHP.INI File

The php.ini is the file that contains PHP configuration parameters. To learn about php.ini file go to its chapter by the link below:

PHP.INI File Configuration

Windows IIS Configuration:

To configure IIS on your Windows OS, you may refer your IIS Reference Manual shipped along with IIS.

Easy Installation with Solution Stack

As mentioned earlier, the easiest way to install and run PHP code can be a Solution Stack like XAMPP that stands for (Cross Platform Apache, MySQL, PHP, and Peril). You can download XAMPP from the official website https://www.apachefriends.org/index.html/.

After downloading and installing the package, all required components will be installed including Apache, MySQL, and PHP.

Note, you can search and install other Solution Stacks as well.