Monday, 4 June 2012

Install and Configure PHP on CentOS

Install and Configure PHP on CentOS

PHP

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.  For more information on PHP, visit their website at www.php.net.

Version

This documentation was written for PHP 5.1.6 but may be usefull with other versions.

How to install PHP

  1. Run the yum install command   
yum install php

How to configure PHP

Increase PHP script memory limit

In the /etc/php.ini file replace memory_limit = 16M with memory_limit = 128M



Increase PHP script max execution time

In the /etc/php.ini file replace max_execution_time = 30 with max_execution_time = 120


Increase PHP script max upload size

In the /etc/php.ini file replace max_upload_size = 2M with max_upload_size = 50M
In the /etc/php.ini file replace post_max_size = 8M with post_max_size = 50M


Create the /usr/share/phpinfo folder

mkdir /usr/share/phpinfo


Create the /usr/share/phpinfo/index.php file with the following text:

<?php
  phpinfo();
?>


Change permissions on the index.php file

 chmod 0755 /usr/share/phpinfo/index.php 



Create the /etc/httpd/conf.d/phpinfo.conf file with the following text:

# phpinfo - PHP utility function for displaying php configuration
#
# Allows only localhost by default

Alias /phpinfo /usr/share/phpinfo
<Directory /usr/share/phpinfo/>
   order deny,allow
   deny from all
   allow from 127.0.0.1
</Directory>


Restart Apache Server

service httpd stop

service httpd start

Test

Visit localhost/phpinfo in your web browser. You should see the infamous phpinfo output. If the address bar changes to something other than http://localhost/phpinfo/, than something went wrong while following the instructions and your browser has interpreted this as a search. Try following the instruction again.

























Further Reading:

  1. Install and configure CentOS on VMware Workstation
  2. Install VMware Tools
  3. Add external HDD to the VM
  4. Update CentOS
  5. Install and Configure the Yum Priorities plug-in
  6. Install and Configure the EPEL Repository
  7. Install and Configure the Remi Repository
  8. Install and Configure Apache HTTP Server 
  9. Installing and Configuring LAMP on CentOS
     



No comments :

Post a Comment