fir3net
PPS-Firenetbanner-780.5x190-30-03-17

How to perform a basic PHP Installation

Within this article we will be configuring a basic php installation using Apache.
Note : The steps are based upon the CentOS 5 distro.

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

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001