Results 1 to 16 of 16
  1. #1
    Join Date
    Jul 2009
    Posts
    57

    Apache2 with php4 and php5

    Hello,


    I am looking to work both php4 and php5 with Apache2 in plain server. I have tried most of the links but ended up with no luck
    Can you guys tell me how to work on it.
    Thanks in advance.

  2. #2
    Join Date
    Feb 2008
    Location
    Houston, Texas, USA
    Posts
    3,262
    What have you done so far and what issues are you encountering?

    Regards
    Joe
    UNIXy - Fully Managed Servers and Clusters - Established in 2006
    Server Management - Unlimited Servers. Unlimited Requests. One Plan!
    cPanel Varnish Plugin -- Seamless SSL Caching (Let's Encrypt, AutoSSL, etc)
    Slow Site or Server? Unable to handle traffic? Same day performance fix: joe@unixy

  3. #3
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    How do you want each php running? As apache or CGI module?
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  4. #4
    Join Date
    Jul 2009
    Posts
    57
    Thanks for responding Joe
    1. Compiled php4 and php5 in various locations with Apache2.
    2. Need php4 server wide.
    3. Need php5 for particular folder.
    4. Add the following to httpd.conf
    <Directory /home/user/public_html>
    AddHandler php-script .php
    Action php-script /cgi-bin/php5
    </Directory>
    5. cp /usr/local/php5/bin/php /home/user/public_html/
    6. restart apache


    After all these steps I am unable to work php5 in that particular folder.
    Where I am going wrong ??
    Thanks in advance.

  5. #5
    Join Date
    Jul 2009
    Posts
    57
    Quote Originally Posted by david510 View Post
    How do you want each php running? As apache or CGI module?
    Thanks for responding

    I need to run php5 as cgi and php4 as apache.

  6. #6
    Join Date
    Jul 2009
    Posts
    57
    Quote Originally Posted by UNIXy View Post
    What have you done so far and what issues are you encountering?

    Regards
    Joe
    Thanks for responding Joe
    1. Compiled php4 and php5 in various locations with Apache2.
    2. Need php4 server wide.
    3. Need php5 for particular folder.
    4. Add the following to httpd.conf
    <Directory /home/user/public_html>
    AddHandler php-script .php
    Action php-script /cgi-bin/php5
    </Directory>
    5. cp /usr/local/php5/bin/php /home/user/public_html/
    6. restart apache


    After all these steps I am unable to work php5 in that particular folder.
    Where I am going wrong ??
    Thanks in advance.

  7. #7
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Add this to the httpd.conf file.
    Code:
    <Directory /home/user/public_html>
    Action application/x-httpd-php5 "php"
    AddHandler application/x-httpd-php5 .php5
    </Directory>
    Make a file named test.php5 in the webroot and check.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  8. #8
    Join Date
    Jul 2009
    Posts
    57
    Quote Originally Posted by david510 View Post
    Add this to the httpd.conf file.
    Code:
    <Directory /home/user/public_html>
    Action application/x-httpd-php5 "php"
    AddHandler application/x-httpd-php5 .php5
    </Directory>
    Make a file named test.php5 in the webroot and check.
    Thanks David
    My info.php show php version4 and info.php5 show "Your browser sent a request that this server could not understand" - error log "Invalid URI in request GET /info.php5 HTTP/1.1"

    Where I am going wrong ??
    Thanks in advance.

  9. #9
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Add the following line too along with the previous lines.

    AddType application/x-httpd-php5 .php5

    Restart apache after that.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  10. #10
    Join Date
    Jul 2009
    Posts
    57
    Quote Originally Posted by david510 View Post
    Add the following line too along with the previous lines.

    AddType application/x-httpd-php5 .php5

    Restart apache after that.
    Thanks David.
    info.php is showing php version 4 and info.php5 shows "<? phpinfo(); ?>".
    I am trying to run appli under /usr/local/apache2/htdocs/demo as php5 and php4 as server wide.
    Please Help.

  11. #11
    Join Date
    Jul 2009
    Posts
    57
    Hello,

    I am still not getting an clear idea how to make it work.
    "Php4 as Apache mod and Php5 as CGI" / "php4 as server wide and php5 for particular directory". can any one post me the clean steps how to make it work in plain server.

    Thanks in advance.

  12. #12
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Quote Originally Posted by minim View Post
    Thanks David.
    info.php is showing php version 4 and info.php5 shows "<? phpinfo(); ?>".
    I am trying to run appli under /usr/local/apache2/htdocs/demo as php5 and php4 as server wide.
    Please Help.
    Try adding these lines in httpd.conf file and restart apache.

    Code:
    <Directory /usr/local/apache2/htdocs/demo>
    Action application/x-httpd-php5 php
    AddType application/x-httpd-php5 .php5
    AddHandler application/x-httpd-php5 .php5
    </Directory>
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  13. #13
    Join Date
    Jul 2009
    Posts
    57
    Quote Originally Posted by david510 View Post
    Try adding these lines in httpd.conf file and restart apache.

    Code:
    <Directory /usr/local/apache2/htdocs/demo>
    Action application/x-httpd-php5 php
    AddType application/x-httpd-php5 .php5
    AddHandler application/x-httpd-php5 .php5
    </Directory>
    Thanks David. I tried like the above post but no luck
    I have to run the application as .php and not as ".php5, so pls advice me and Please let me know the modules which should be included while compiling php5 with apache2.

  14. #14
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    Compile php5 as follows.
    Code:
    wget http://us.php.net/get/php-5.2.11.tar.gz/from/us.php.net/mirror
    tar -zxf php-5.2.11.tar.gz
    cd php-5.2.11
    ./configure --prefix=/usr/local/php5 --add_the_remaining_options_from_php4_expect_apxs
    make
    make install
    Now run the following command
    Code:
    /usr/local/php5/bin/php-cgi  -v
    It should show as cgi.

    Now add the following lines on top of the httpd.conf file
    Code:
    ScriptAlias /php5/ /usr/local/php5/bin/
    Action application/x-httpd-php5 /php5/php-cgi
    <Directory "/usr/local/php5/bin/">
        Allow from all
    </Directory>
    Save httpd.conf file and restart apache.

    Open a .htaccess file inside the folder where you need php5 and add the following code to it. Make sure .htaccess support is enabled in your apache configuration.

    Code:
    AddHandler application/x-httpd-php5 .php
    Make a phpinfo.php file in this directory and see what is shows when taken in browser. It should be php5.

    See what it shows when the .htaccess line is commented. It should be php4 then.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  15. #15
    Join Date
    Jan 2008
    Location
    St. John's, NL
    Posts
    2,201
    Sounds like you may want the Concurrent DSO patch during EasyApache so that you can run both together as DSOs. A bit of advice though: if you are running a shared server, do not make PHP4 default. It is old, unsupported, and insecure.
    Cpanel/WHM • PHP • Perl • Ruby • Full Time Support
    LCWSoft - Canada web hosting (based in Newfoundland) since 2007
    Servers based in the US and Canada (Uptime Report)

  16. #16
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    OP said this in his first post. Seems he has a server without a control panel.

    Code:
    I am looking to work both php4 and php5 with Apache2 in plain server
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

Similar Threads

  1. dual php4 & php5 forcing script to use php5
    By acctman in forum Programming Discussion
    Replies: 1
    Last Post: 09-09-2009, 11:22 PM
  2. Replies: 1
    Last Post: 07-16-2008, 06:28 AM
  3. php4 and php5 togethor on apache2 (centos 4.5)
    By dinks in forum Hosting Security and Technology
    Replies: 7
    Last Post: 07-05-2007, 12:35 AM
  4. run php4 for .php4 files and php5 for .php [httpd.conf]
    By SexualChocolate in forum Hosting Security and Technology
    Replies: 2
    Last Post: 01-29-2007, 09:29 AM
  5. PHP4 + Apache2 + Windows Error
    By Kakashi in forum Hosting Security and Technology
    Replies: 0
    Last Post: 07-19-2006, 12:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •