Apache 2.2.10 + php 4.4.9 ( cgi ) + php5.2.6 ( dso ) Compilation

After Apache Compilation , download php4 and php5 source and untar the same. Go to php4 source dir :-

PHP4 as CGI
==========
cd /usr/local/php-4.4.9
./configure –prefix=/usr/local/php4 –with-mysql=/var/lib/mysql –with-mysql-sock=/var/lib/mysql/mysql.sock
make
make install

edit httpd.conf
==========
uncomment ScriptAlias /cgi-bin/ “/usr/local/apache/cgi-bin/”
cd /usr/local/apache/cgi-bin
ln /usr/local/bin/php php

edit php.conf
=========

Action application/x-httpd-php4 /cgi-bin/php

AddType application/x-httpd-php4 .php4
AddHandler application/x-httpd-php4 .php4

Give include_path in php.ini as  /usr/local/php4/lib/php

PHP 5 as CLI
==========

cd /usr/local/php-5.2.26
./configure –with-apxs2=/usr/local/apache/bin/apxs –enable-ftp
make
make install

Check for LoadModule entry inside httpd.conf :-

LoadModule php5_module        modules/libphp5.so

As the above line says the libphp5.so should be present inside /usr/local/apache/modules/libphp5.so
Add the include path for php5 in php.ini :- /usr/local/lib/php . So finally the include_path in php.ini would look like ( include_path /usr/local/php4/lib/php:/usr/local/lib/php )

If you want you can add Handlers for php5 also , but it will work without that also. Create a sym-link for php5 binary to cgi-bin/php5 , then add the following lines for PHP5 in php.conf :-

Action application/x-httpd-php5 /cgi-bin/php5
AddType application/x-httpd-php5 .php
AddHandler application/x-httpd-php5 .php

Now restart Apache and you should be able to view the php configuration for both distribuitions using respective phpinfo files ( phpinfo5.php & phpinfo.php4 ). Remember to keep .php4 extension for files that should be loaded using php4. But if you want your php files not to be called with .php4 extension then you should be knowing that you can override these server wide settings with your .htaccess file. For eg your site deals only with php4 and you dont want your php files to have a .php4 extension. Then add the following in your .htaccess file :-

Action application/x-httpd-php4 /cgi-bin/php
AddType application/x-httpd-php4 .php
AddHandler application/x-httpd-php4 .php

This should do the trick ;)

Share and Enjoy:
  • Digg
  • Mixx
  • del.icio.us
  • StumbleUpon
  • Facebook
  • TwitThis
  • Technorati
  • Google

Tags:

Leave a Reply