Php

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:

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>

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
make install

Installing php5.5 with yum:

rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
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 http://mirror.webtatic.com/yum/el6/latest.rpm
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:

 $ORACLE_HOME
   -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 "extension=oci8.so" to php.ini

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

php -i | grep oci8
 oci8
 oci8.connection_class => no value => no value
 oci8.default_prefetch => 100 => 100
 oci8.events => 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:

<?php
$to = "user@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "anotheruser@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

Was this answer helpful?

 Print this Article