Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP on dual Apache ports (vHosts)

Status
Not open for further replies.

csteinhilber

Programmer
Aug 2, 2002
1,291
US
I'm developing two sites concurrently (eventually to be housed at different hosts with different directory structures), and on my development Win2K machine I have Apache 1.3.20 set to listen to 2 ports (80, and then 8080 as a VHost) each with a different docroot. I can get Apache to serve HTML pages just fine on both ports (from the appropriate docroots). But both sites also use PHP (4.0.6), and I can't get PHP to work on the VHost (port 8080). It works fine on the "main" port (80).

In httpd.conf, I have:

Code:
Listen 80
Listen 8080
    :
Port 80
    :
LoadModule php4_module c:/php/sapi/php4apache.dll
    :
ServerName dev.cstein
    :
DocumentRoot "C:/home/[URL unfurl="true"]wwwroot/proj1"[/URL]
    :
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps
    :
<VirtualHost _default_:8080>
    DocumentRoot &quot;C:/users/account/html/proj2&quot;
    Options Indexes FollowSymLinks Includes
</VirtualHost>

Anyone have any pointers on how I might be able to get PHP to process on both ports? Right now I don't even know if it's an Apache config or PHP config problem.

Thanks much!
-Carl
 
Perhaps I didn't ask the question correctly [wink]

If one was to try to set up multiple sites (presumably Virtual Hosts) with different document roots on a single instance of Apache, and have PHP (and mySQL) active on all sites, what would the proper configuration settings for Apache and PHP be?

Since I don't have the flexibility of setting up new DNS names for each site, I'm guessing it has to be a port-based VHost solution.

Anyone? Anyone?
 
These settings should work for you:
Listen 80
Listen 8080
:
Port 80
:
LoadModule php4_module c:/php/sapi/php4apache.dll
AddModule mod_php4.c
:
ServerName localhost
:
DocumentRoot &quot;C:/home/ :
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps
:
<VirtualHost _default_:80>
DocumentRoot &quot;C:/home/ # Various options here
</VirtualHost>
<VirtualHost _default_:8080>
DocumentRoot &quot;C:/users/account/html/proj2&quot;
Options Indexes FollowSymLinks Includes
</VirtualHost>
Apache sometimes doesn't work if the first virtual host doesn't have the same settings as those in the global settings. //Daniel
 
Thanks Daniel!

That seems to have solved the problem!
Much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top