hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fedora (Apache 2)
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fedora (Apache 2)

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-29-2006, 03:34 PM
Serberus Serberus is offline
New Member
 
Join Date: Mar 2004
Location: Herts, UK
Posts: 1
Lightbulb

Run PHP4 (module) & PHP5 (fastcgi) simultaneously on Fedora (Apache 2)


I've spent a few hours compiling information from around the net to get PHP4 & PHP5 working simultaneously. I thought I'd write up what I had to do and hope this can help others. This isn't rocket science but at least this consolidates the information I had to search for...

Note: This is not a set up you might use for a sharing hosting scenario, this is just for my colo server where Apache runs under a 'www' user, and friends I host don't have SSH. For a more secure set up you'd probably want to use suphp / SuExec etc.

I'm assuming you've already got PHP4 happily running as an Apache module. These instructions only cover installing FastCGI, PHP5 & configuration.

Grab a copy of FastCGI & mod_fastcgi, extract these and install. (I can't provide the correct links because I've currently got under 5 posts)

Code:
cd /usr/src/
wget fastcgi.com/dist/fcgi-2.4.0.tar.gz
wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar xzf fcgi-2.4.0.tar.gz
tar xzf mod_fastcgi-2.4.2.tar.gz
cd fcgi-2.4.0
./configure && make && make install
cd ../cd mod_fastcgi-2.4.2
It's documented on fastcgi.com (fastcgi.com/mod_fastcgi/INSTALL) to perform the following... HOWEVER:
Code:
<mod_fastcgi_dir>$ apxs -o mod_fastcgi.so -c *.c
<mod_fastcgi_dir>$ apxs -i -a -n fastcgi mod_fastcgi.so
... this did not work for me (not sure if those are instructions for Apache 1.3.x), so I had to do this:
Code:
cp Makefile.AP2 Makefile
make && make install
If you were successful you'll see 'mod_fastcgi.so' in your Apache modules dir. In my case:
Code:
ls -l /usr/local/apache2/modules/
-rw-r--r--  1 root root    8440 Feb 28  2005 httpd.exp
-rwxr-xr-x  1 root root  345172 Apr 29 16:54 mod_fastcgi.so
-rwxr-xr-x  1 root root  140451 Feb  6  2005 mod_rewrite.so
Check that this line exists in your httpd.conf (typically it should be found near the top with other LoadModule statements):
Code:
LoadModule fastcgi_module modules/mod_fastcgi.so
Now we need to configure FastCGI.
Code:
mkdir -p /tmp/fcgi_ipc/dynamic
chmod -R 777 /tmp/fcgi_ipc/
Next edit your httpd.conf and add the following.

In my conf file I added this line in the 'ScriptAlias' section just below the ServerSignature directive.

This line is optional but if you choose not to include it, apache will check the document root of the current site - this gives you per site configuration of Fast CGI; for me it was overkill and I only needed one file to define these settings so I aliased it and put the config file in apache's cgi-bin dir.
Code:
ScriptAlias /php5.fcgi "/usr/local/apache2/cgi-bin/php5.fcgi"
Above my 'AddIcon' directives I added the following to configure FastCGI. The bottom line is optional, see the documentation for explanation of these settings - I borrowed these from here: timdorr.com/archives/2006/02/php4_and_php4_s.php
Code:
# FastCGI directives
<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  FastCgiIpcDir /tmp/fcgi_ipc/
  FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240 -pass-header HTTP_AUTHORIZATION
</IfModule>
Add these lines below your PHP4 'AddType' directives to bind the .php5 file extension to your FastCGI config script 'php5.fcgi':
Code:
AddHandler application/x-httpd-php5 .php5
Action     application/x-httpd-php5 /php5.fcgi
Next create your 'php5.fcgi' and add the following:
Code:
#!/bin/sh
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/local/php5/bin/php
Make sure 'php5.fcgi' has the correct permissions & user/group so Apache can access it. Apache runs under 'www' on my box, please specify the appropriate user & group.
Code:
chown www:www php5.fcgi
chmod 755 php5.fcgi
Now it's time to install PHP5. It's probably worth matching your PHP4 configure line which can be found on the phpinfo() page. To find out the available configure options type './configure --help'. Whats important are the configure switches I've shown and that you specify a prefix path to install PHP5.
Code:
cd /usr/src
wget uk.php.net/get/php-5.1.2.tar.bz2/from/this/mirror
tar xjf php-5.1.2.tar.bz2
cd php-5.1.2
./configure --with-config-file-path=/usr/local/php5/php.ini --prefix=/usr/local/php5 --enable-fastcgi --enable-discard-path --enable-force-cgi-redirect ...your switches...
make && make install
cp php.ini-dist /usr/local/php5/php.ini
You can check the installation was successful:
Code:
/usr/local/php5/bin/php -v
You should see:
Code:
PHP 5.1.2 (cgi-fcgi) (built: Apr 29 2006 17:40:57)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
Now restart apache. Then create a phpinfo() page with the extension .php5 (eg. phpinfo.php5 - don't forget to remove this once you've confirmed PHP5 is running successfully!)

If this hasn't worked check the modules Apache has loaded, specifically mod_action.
Code:
/usr/local/apache2/bin/apachectl -l
Hopefully you've now got PHP5 running along side PHP4!

Sources of reference:
www fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
plone.org/documentation/tutorial/plone-apache/fastcgi
wiki.rubyonrails.com/rails/pages/RailsOnFedora
timdorr.com/archives/2006/02/php4_and_php4_s.php
www howtoforge.com/apache2_with_php5_and_php4_p2

Reply With Quote


Sponsored Links
  #2  
Old 09-20-2006, 06:31 AM
henmar henmar is offline
New Member
 
Join Date: Sep 2006
Posts: 0
I have fedora 4 installed in my and it has php5 as default installation. But i want php4 aslo to be installed. So can i follow the above procedure to run both.
thanks

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Weekend Reading: Top Web Hosting News from the Week of October 8-12, 2012 Web Hosting News 2012-10-13 13:26:54
Google Launches Open Source Apache HTTP Server Module mod_pagespeed Web Hosting News 2012-10-12 12:01:56
Colocation America to Support Fedora Linux Project with Dedicated Server Web Hosting News 2012-08-17 09:49:26
Control Panel cPanel Launches New Apache Configuration Script Web Hosting News 2011-12-28 19:41:39
Oracle is the Latest Vendor to Apply Patch for Apache Killer Flaw Web Hosting News 2011-09-19 14:43:58


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?