Forum Moderators: phranque

Message Too Old, No Replies

Two Apaches

Need help accessing the right one

         

chrisjoha

1:55 pm on Oct 17, 2005 (gmt 0)

10+ Year Member



Hi, I've just completed an installation where I have PHP4 running as a module on localhost:8080 and PHP5 running as a module on localhost. It works as a charm except I don't know how to access the different setups without the portnumber - is this possible? I tried setting up a DNS to point to 111.000.222.333:8080 but as I found out, that is not a valid dns address (with the portnumber included). So... is there a way to do this without appending the portnumber? I was thinking like php4.example.com and php5.example.com, not www.example.com:8080 and www.example.com? :)

jdMorgan

6:16 pm on Oct 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Generally, in order to access two instances of Apache, you'll need to use either a unique port or a unique IP address. In the first instance, you tell Apache to listen to a specific port, and in the second, you bind each instance to a different network adapater (IP address).

Jim

chrisjoha

8:27 am on Oct 18, 2005 (gmt 0)

10+ Year Member



Well, I have one setup with listen: 80 and one with listen: 8080 but how can I access them without specifying the port number? I don't think I fully understood your post.

Markus Klaffke

1:02 pm on Oct 18, 2005 (gmt 0)

10+ Year Member



No you cannot.

It is always

www.example.com

oder

www.example2.com:8080

There is only one possibility: Your provider installs a redirect to port 8080 for that specific domain. This way your users can access the second domain via

www.example2.com

but this slows down speed and costs money. Subdomains are not possible.

Maybe there are other solutions, but i donīt know.

chrisjoha

5:24 am on Oct 25, 2005 (gmt 0)

10+ Year Member



Finally this forum is back on track :) Well, thanks for the answer. If I cannot do it - then can someone suggest another way to have php4 and php5 both run as a module on the same machine?

chrisjoha

8:03 am on Oct 28, 2005 (gmt 0)

10+ Year Member



Isn't there anyone who have succeeded with this?

chrisjoha

1:39 pm on Nov 4, 2005 (gmt 0)

10+ Year Member



Yes there is! :) I have finally accomplished this and thought I'd share if someone else is interested. The answer is pretty simple actually. I did the following:

Imagine your servers ip is 111.0.0.111

Install Apache/php5
Make a copy of the httpd.conf and edit it for PHP4
PHP5-config file should have


Listen 111.0.0.111:80
...
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
...
NameVirtualHost 111.0.0.111:80

The second one should have


Listen 127.0.0.1:8080 # Or whatever port you'd like
...
NameVirtualHost 127.0.0.1:8080

Then comes the trick - Let's say you want www.example.com to be php5 enabled and www2.example.com to be php4 enabled. You do it by making the php5 enabled server pass requests for php4 enabled server onto the other instance:

PHP5-config:


<VirtualHost 111.0.0.111:80>
ServerName www.example.com
DocumentRoot d:\www_docs
</VirtualHost>

<VirtualHost 111.0.0.111:80>
ServerName www2.example.com
ProxyPass / http://127.0.0.1:8080/
</VirtualHost>

PHP4-config:


<VirtualHost 127.0.0.1:8080>
ServerName www2.example.com
DocumentRoot d:\www_docs
</VirtualHost>

Now stick info.php containing phpinfo(); in d:\www_docs and watch the magic going on at www.example.com/info.php and www2.example.com/info.php :)

So easy, so very useful, and totally awesome :D

jdMorgan

4:11 pm on Nov 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad to hear you stuck with it and got it working!

(I would have never guessed this solution)

Thanks for posting it.

Jim