View previous topic :: View next topic |
Author |
Message |
ezekiel61 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 15 Feb 2005 Posts: 36
|
Posted: Tue Apr 05, 2005 4:53 pm Post subject: Apache 2 with PHP5 and PHP4? |
|
|
I need to have multiple versions of PHP running for new and old web applications. So I searched and found a thread that kinda beats around the bush. I have an idea, but I don't want to do it on my production server until I"ve talked it out with a few of you for feasibility.
1. Can we just emerge both mod_php4 and mod_php5 and add the directives in /etc/conf.d/apache for "-D PHP4 -D PHP5". Then let the apache module files handle it:
Code: |
# Load the module first
<IfModule !sapi_apache2.c>
LoadModule php4_module modules/libphp4.so
</IfModule>
# Load the module first
<IfModule !sapi_apache2.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
|
2. Handle it via the vhosts file?
Not saying this will work, trying to get feedback to see if anyone has gotten something like this to work? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SilverOne Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 10 Nov 2003 Posts: 161
|
Posted: Fri Apr 29, 2005 11:14 pm Post subject: |
|
|
I'm interested in this as well.
I, too, have a production server that I don't want to put at too much risk with this.
I've got several virtual domains for others, and a couple for myself.
Now I want to develop PHP5 scripts on that server, but I don't want to upgrade everybody's PHP version.
So I'm looking to try running both PHP5 and PHP4 on the same (web-)server.
Either one of 2 situations will suit me:
- scripts with .php or .php4 will be run by php4 and scripts with .php5 will be run by php5
- all .php/.php4/.php5 scripts on domains x,y,z will be run by php5, all scripts on other domains will be run by php4
(though if both we're possible I'd choose to allow only .php5 on domains x,y,z to be run by PHP5)
How does one go about this?
I searched the forum but all I got was threads about conflicts, and not much about getting it to work. We can't be the only 2 who'd want this?
Thanks for any tips!
EDIT: I'm running apache 2 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
ezekiel61 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 15 Feb 2005 Posts: 36
|
Posted: Sat Apr 30, 2005 3:16 pm Post subject: |
|
|
I haven't spent much time on this since I originally posted. I did find an apache project called XAMPP at http://www.apachefriends.org/en. This is a Windows Apache project. However, if you install it they claim to run both PHP4 and PHP5 along with other Apache projects such as Tomcat and Cocoon. I suppose if one were to install this and check out how they setup their htttpd.conf file we could figure this out... as of right now I don't have the time to do it. I'll update if I get any progress. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SilverOne Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 10 Nov 2003 Posts: 161
|
Posted: Sat Apr 30, 2005 11:41 pm Post subject: |
|
|
From what I gathered they we're using some third-party add-on.
I've also seen people modify the PHP5 modules source (to get different handle names) or use it as CGI.
The option that is also offered (and appeals to me most) is running 2 apache daemons on the same machine.
I would like to know how I can do this within reasonable hacking distance of regular portage-based system maintenance though.
(preferably I'd like to be able to update any and all software via portage, including any second installation of Apache).
I'll take a look at this in the coming days... |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
rsevero n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 01 Sep 2004 Posts: 33
|
Posted: Sun May 01, 2005 11:34 am Post subject: PHP5 as FastCGI |
|
|
I've installed PHP5 as FastCGI. mod_php(4) got untouched.
It isn't optimal but it's working for me right now. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SilverOne Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 10 Nov 2003 Posts: 161
|
Posted: Sun May 01, 2005 11:42 am Post subject: Re: PHP5 as FastCGI |
|
|
rsevero wrote: | I've installed PHP5 as FastCGI. mod_php(4) got untouched.
It isn't optimal but it's working for me right now. |
I heard there we're security and other problems with running PHP as CGI (including access to some server variables)
I therefore concluded this method was not a true companion to PHP4.... (I want to be able to switch back and forth from PHP4 to 5, in order to test existing scripts.).
Is there a list of differences between mod_php and cgi_php?
I'm still thinking about the 2 apache daemons, I'll post a separate thread for this. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
arut8ur n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 28 Jul 2003 Posts: 16
|
Posted: Sun May 01, 2005 12:06 pm Post subject: |
|
|
Hi
I have the same Problem, need to run PHP4 and PHP5 on the same server.
What I did is to run 2 apache instances on different IPs with the same configuration.
So I can access the same VHosts with www.mydomain (PHP4) and php5.mydomain (PHP5),..
Now I can check the same project-code against PHP4 an PHP5.
To do this I did the following:
Setup a new IP addres for my NIC.
You can do this easily if you are using /etc/conf.d/net to setup your IP Addrsses, I am using DHCP so I used this entry in /etc/conf.d/local.start "ifconfig eth0 add 172.25.0.9"
Now I installed PHP5 from source, because the Portage ebuild for PHP5 are outdated. For PHP4 I am using the portage ebuilds.
After comiling PHP5 I copied the modules (libphp5.so, libphp5.la) to /usr/lib/apache2/modules.
Now I copied /etc/apache2/conf/modules.d/70_mod_php.conf to /etc/apache2/conf/modules.d/71_mod_php5.conf and modified it for PHP5.
Now I copied /etc/conf.d/apache2 /etc/conf.d/apache2_php5 and change the some values:
Code: | APACHE2_OPTS="-D SSL -D PHP5 -D LDAP -D AUTH_LDAP"
STARTUPERRORLOG="/var/log/apache2_php5/startuperror.log"
PIDFILE=/var/run/apache2_php5.pid |
Now I copied /etc/init.d/apache2 to /etc/init.d/apche2_php5.
In my /etc/apache/conf/apache2.conf I configured the IP Addresses with
Code: | <IfDefine PHP4>
Listen 172.25.0.7:80
</IfDefine>
<IfDefine PHP5>
Listen 172.25.0.9:80
</IfDefine> |
This Setup is not perfect, because the Program apachectl is not written for two apache instances on one server, but normally you dont have to restart them to often
Hope this will be helpful to you,.. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
pi314 Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/6171471713f3e34326ac90.gif)
Joined: 31 Jul 2003 Posts: 136 Location: Germany
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
drax_ n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/2564842954379224032de1.gif)
Joined: 18 Mar 2005 Posts: 32 Location: France
|
Posted: Tue Jul 12, 2005 11:11 am Post subject: |
|
|
Hi, sorry to be a little late, but here we go.
I also needed to run PHP4 and PHP5 alongside each other. I've managed it, and exposed it in other threads, and also on my website.
The way I set it up, is mod_php4 (apache handler) and php5 as FastCGI since php4 was the "testing version" and php5 the definite version. I have combined the use of php CGI's with mod_suexec, which is IMO, alot more secure than mod_php (in a webhosting environnement ie: multiple users using the same server).
This might not be your case (only you or trusted people use the server, not anyone else), and don't forget when PHP is used as a CGI, an external executable is called, and might therefor create more processing overhead, than mod_php would. (I have yet to benchmark both of them
Anyway, if you're interested I trying my setup, you can read my post/tutorial. The whole tutorial is far from complete, but the PHP section contains the information you are looking for.
Having both mod_php4 and mod_php5 would probably require hacking the source code, and is (IMO) not viable, in an environnment which emerges world on a daily basis (this again, might not be your case). |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
SilverOne Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 10 Nov 2003 Posts: 161
|
Posted: Tue Jul 12, 2005 12:45 pm Post subject: |
|
|
Last week I suddenly made the plunge and installed PHP5 along side PHP4
I used a different approach, using two apache daemons to run on different ports.
This has one advantage over the above solution: I do not need to rename files to test them with PHP5
(other than that drax_' solution seems to have more advantages )
I don't have time to make a nice how-to at the moment, but here is what I did in a nutshell:
(note, it is not for the faint-hearted, and I'm putting it down by memory, so I hope it is correct. Use the following instructions ONLY on testing machines. I do not accept responsibility if you mess up your system. These instructions are by no means guaranteed to work)
- phpinfo() on the current install, and note the compile-time directives to PHP4
- download the php5 source
- "construct" the compile options for php5 using the options used for php4 and the help at './configure --help'
-> Add the following options:
--with-config-file-path=/etc/php/apache2-php5-shadow
--libdir=/usr/lib/php5-shadow
--program-suffix=5-shadow
(these will make sure that it doesn't get in the way of the currently installed php4 versions of the cgi, mod_php and cli interpreters, and it's not likely that gentoo's ebuild voor php5 will use these names )
- make a backup of your system before continuing (as you should always do!!) (especially apache2.conf + commonapache2.conf / httpd.conf)
- compile and install using 'make' and 'make install'
- recover the changes in httpd.conf by copying the backup over it (the install script "helps" you by changing it)
- make a copy of httpd.conf (or apache2.conf + commonapache.conf) to httpd_php5shadow.conf (or apache2_php5-shadow.conf and commonapache_php5-shadow.conf)
inside the configuration files you just copied change the following settings :
(note: I changed them, and it worked, it might not be the minimum required, I did not check)
- Listen 80 --> Listen 81 (or another port if preferred)
- Listen 443 --> Listen 444 (note: I did not test ssl functionality, this might not work)
(depending on configuration) - change Include conf/commonapache2.conf --> Include conf/commonapache2_php5-shadow.conf
- Include conf/modules.d/70*.conf --> Include conf/modules.d/71_mod_php5-shadow.conf
- PidFile /var/run/apache2.pid --> PidFile /var/run/apache2_php5-shadow.pid
- ErrorLog logs/error_log --> ErrorLog logs/error_log_php5-shadow
- ServerName <name>:80 --> ServerName <name>:81
- Next: make a copy of the current mod_php configuration file and call it 71_mod_php5-shadow.conf
- Edit it to change the loadmodule directive to "LoadModule php5_module extramodules/libphp5-shadow.so"
- and optionally add the .php5 file extension: "AddType application/x-httpd-php .php5"
- change the ifDefine statement to check for PHP5
- browse through commonapache2_php5-shadow.conf to see wether anything needs changing (I did not change anything)
Now you need to start (and optionally kill) the second apache daemon by hand. I use:
- apache2 -f /etc/apache2/conf/apache2.conf.php5-shadow -e debug -DSSL -DPHP5 -X
This will start a single httpd server process, and it will not background, use this to test the configuration
by pointing your browser at: http://www.yourdomainname.tld:81
(or use a different port depending on your choice earlier)
if it all seems to work (call a php file with phpinfo() in it, to check)
you can use this command to launch the httpd service in the background:
(press ctrl+c to quit this server first)
- apache2 -f /etc/apache2/conf/apache2.conf.php5-shadow -e debug -DSSL -DPHP5
(which is the same command without the -X flag)
If you need to kill it now, you will need to kill each apache process by hand (or risk shutting down the main apache server on port 80) or reboot the entire machine.
I hope this helps someone, if there are any questions / remarks, I'll come back and clarify (and enhance readability of this post )
NOTE: I'll say it again, also have a look at drax_'s solution (one post up). It seems to be cleaner and better suited for most needs. I'll probably use the same solution later on when I want to force all my sites to default to PHP5 (and allow the users to opt for php4)
(I run a couple of vhosts and I don't want to force PHP5 on anyone yet, my solution is geared towards a testing ground for my vhosts) |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
andreask Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 09 Sep 2003 Posts: 282 Location: Aachen, Germany
|
Posted: Mon Sep 05, 2005 9:40 am Post subject: |
|
|
ezekiel61 wrote: | I haven't spent much time on this since I originally posted. I did find an apache project called XAMPP at http://www.apachefriends.org/en. This is a Windows Apache project. However, if you install it they claim to run both PHP4 and PHP5 along with other Apache projects such as Tomcat and Cocoon. I suppose if one were to install this and check out how they setup their htttpd.conf file we could figure this out... as of right now I don't have the time to do it. I'll update if I get any progress. |
Please note that XAMPP is not meant for production use and should really only be used in a development environment:
XAMPP README wrote: | As mentioned before, XAMPP is not meant for production use but only for developers in a development environment. The way XAMPP is configured is to be open as possible and allowing the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal. |
http://www.apachefriends.org/en/xampp-linux.html#381 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
andreask Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
Joined: 09 Sep 2003 Posts: 282 Location: Aachen, Germany
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|