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
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018
- Cisco – What is BGP ORF (Outbound Route Filtering)? - March 5, 2018
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:
AlphaPrep Practice Tests - Free Trial