Tuesday, February 8, 2011

How To: Install PHP to Apache web server

After install apache 2.2 on centos , there is no PHP Module built-in, You have to do the same thing like installing apache, Download the source file , compile and put the modules to the folder that will be picked up by apache. Here is the rough steps,

  • Download and extract the tarball from php.net, http://us.php.net/get/php-5.3.5.tar.gz/from/this/mirror
    • tar –zxvf php-5.3.5.tar.gz
  • go into the uncompressed php folder and run the config
    • ./configure –with-apxs2=/opt/apache/bin/apxs –-prefix=/opt/php
    • if needed, yum install libevent-devel libxml2-devel
  • Compile and Test
    • make && make test
  • Install the module to the modules folder
    • make install
    • this will automatically upate apache’s conf/httpd.conf with
      LoadModule php5_module        modules/libphp5.so
      Add the handler of php manully.
      AddType application/x-httpd-php .php
  • restart the apache daemon

TO test, create a single line file to htdocs/test.php

<?php phpinfo();?>

when access that url , you will get the information of php settings, now you are good to go.
image

No comments:

 
Locations of visitors to this page