Within this article we will be configuring a basic php installation using Apache.
Note : The steps are based upon the CentOS 5 distro.
Table of Contents
Install Apache / PHP
First of all you will need to install Apache and php via yum.
yum install httpd php
Edit php.ini
Within /etc/php.ini ensure the following settings are configured by either un-commenting them or by changing the appropriate value.
short_open_tag = On
magic_quotes_gpc = On
register_globals = On
session.save_path = “/var/lib/php/session”
Edit http.conf
Edit the Apache configuration to ensure the following configuration settings are set.
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
AddType applications/x-httpd-php .php
AddType applications/x-httpd-php-source .phps
ServerName ‘hostname’
Restart Apache
/etc/init.d/httpd restart
Create PHP Script
Create a small php script and save it within the directory /var/www/html/. A small example is shown below.
Note : When creating php scripts all code should be enclosed within php tags such as <?php [syntax] ?>.
<?php
phpinfo();
?>
Execute Script
To confirm that the installation and configuration was successful run the test PHP script.
http://[server address]/[testscript name].php
- NETCONF & YANG: Automate Network Configs via Python - April 2, 2026
- Palo Alto – How to Configure Your Next-Generation Firewall - April 2, 2026
- How to Harden Linux SSH: Keys, Fail2ban & Ciphers - March 1, 2026
Want to become a PHP expert ?
Here is our hand-picked selection of the best courses you can find online:
The Complete Web Development Bootcamp course
PHP for Beginners course
Write PHP like a Pro course
and our recommended certification practice exams:
Delta Practice Tests