To install php on Centos enter following command:

yum install php

To install php-mysql:

yum install php-mysql

Locate working php.ini:

php -i | grep 'Configuration File'

Create file phpinfo.php in web accessible directory, for example /var/www/html:

nano /var/www/html/phpinfo.php

Add following to the file and save it:


// Show all information, defaults to INFO_ALL


Now you can display php details using url http://YourIP/phpinfo.php

If you want to recompile php you can copy your current php settings under "Configure Command" in http://YourIP/phpinfo.php

Download source of your current php version, cd to the extracted folder and execute:

./configure --with-apxs2=/usr/bin/apxs2 --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config --with-pgsql=/usr --with-tidy=/usr --with-curl=/usr/bin --with-curlwrappers --with-openssl-dir=/usr --with-xpm-dir=/usr --with-pdo-pgsql=/usr --with-pdo-mysql=/usr --with-xsl=/usr --with-ldap --with-xmlrpc --with-iconv-dir=/usr --with-snmp=/usr --enable-exif --enable-calendar --with-bz2=/usr --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-freetype-dir=/usr --enable-zip --with-pear

This is an example command, you should edit components according to your needs. After configuring is accomplished, enter:

make install

Installing php5.5 with yum:

rpm -Uvh
yum install php55w-devel php55w-mbstring php55w-mcrypt php55w-gd php55w-mysql php55w-xml


Using pecl

The next example shows how to use pecl for configure oci8 for Oracle.

Install php packages needed for Oracle:

rpm -Uvh
yum install php55w php55w-opcache  php55w-devel  php55w-pear

check installed packahes should be like this:

yum list installed | grep php
 php55w.x86_64                    5.5.13-2.w6                         @webtatic  
 php55w-cli.x86_64                5.5.13-2.w6                         @webtatic  
 php55w-common.x86_64             5.5.13-2.w6                         @webtatic  
 php55w-devel.x86_64              5.5.13-2.w6                         @webtatic  
 php55w-gd.x86_64                 5.5.13-2.w6                         @webtatic  
 php55w-mcrypt.x86_64             5.5.13-2.w6                         @webtatic  
 php55w-opcache.x86_64            5.5.13-2.w6                         @webtatic  
 php55w-pear.noarch               1:1.9.4-7.w6                        @webtatic

Install Developmnet tools (we need c++ complier to use pecl) :

yum groupinstall "Development tools" 

Install oci8. take a lok into a oracle home directory:

   -bash: /u01/app/oracle/product/11.2.0/xe: is a directory 

copy the value of oracle home directory and paste when prompted on the next step:

 pecl install oci8

After your should add "" to php.ini

Check if oci8 installed correctly with "php -i" command:

php -i | grep oci8
 oci8.connection_class => no value => no value
 oci8.default_prefetch => 100 => 100 => Off => Off
 oci8.max_persistent => -1 => -1
 oci8.old_oci_close_semantics => Off => Off
 oci8.persistent_timeout => -1 => -1
 oci8.ping_interval => 60 => 60
 oci8.privileged_connect => Off => Off
 oci8.statement_cache_size => 20 => 20


Sample php mailing script:

$to = "";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "";
$headers = "From:" . $from;
echo "Mail Sent.";

Was this answer helpful?

 Print this Article

Also Read


How to install squid with tor [NOTE: According to AUP/TOS you can use private proxy...


ConfigServer Security & Firewall (CSF) is a powerful iptables configuration tool....


 First of all make sure you have the ports 20-21 opened in your firewall. If not, you...

Squid with authentication on Centos 6

How to install Squid with authentication on Centos 6 >>Get VPS with current...

php increase max file size upload

For increase maximum size of uploads file you should set only one setting in php.ini. Set...