logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache 2.2 on multiple ports
Author
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Thu 22 Mar '07 20:34    Post subject: Apache 2.2 on multiple ports Reply with quote

Hi all, am new here and have a noob question. I hope someone can help me.

i'm configuring 2.2 to run (for example):

Port 80: Serves D:/Webserver/Live
Port 81: Serves D:/Webserver/Test

I've got my whole https.conf below (without the comments to save space)

As it stands, both ports point to the Live codebase, nbothing points to test. If I remove the documentroot outside fo the visrtualhost directives, I get a 403 on both ports.

Code:
PHPIniDir "C:\\PHP\\"
ThreadsPerChild 250
MaxRequestsPerChild  0
ServerRoot "C:/Program Files/Apache2.2"

LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule php5_module "C:\\PHP\\php5apache2_2.dll"


ServerAdmin webmaster@<MYDOMAIN>.com
ServerName <MYIP>:80

DocumentRoot "D:/Webserver/Live"


<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Satisfy all
</Directory>


<Directory "D:/Webserver/Live">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>


<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
</FilesMatch>

ErrorLog logs/error.log

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog logs/access.log common
</IfModule>

<IfModule alias_module>

</IfModule>

   #!c:/program files/perl/perl


DefaultType text/plain

<IfModule mime_module>

    TypesConfig conf/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php
</IfModule>


<IfModule ssl_module>
      SSLRandomSeed startup builtin
      SSLRandomSeed connect builtin
</IfModule>

<VirtualHost <MYIP>:80>
      ServerName <MYIP>:80
      DocumentRoot "D:/Webserver/Live"
</VirtualHost>

<VirtualHost <MYIP>:81>
      ServerName <MYIP>:81
      DocumentRoot "D:/Webserver/Test"
</VirtualHost>

      Listen 80
      Listen 81


If anyonw could please point me in the right direction, I'd appreciate it!

Thanks in advance.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 23 Mar '07 14:26    Post subject: Reply with quote

You need to set permission for the doc roots inside the vhost container.

Code:

<VirtualHost <MYIP>:80>
      ServerName <MYIP>:80
      DocumentRoot "D:/Webserver/Live"
<Directory "D:/Webserver/Live">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost <MYIP>:81>
      ServerName <MYIP>:81
      DocumentRoot "D:/Webserver/Test"
<Directory "D:/Webserver/test">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>
Back to top
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Fri 23 Mar '07 21:41    Post subject: Reply with quote

Thanks for the reply!

Unfortunately, although there were no errors restarting the server, the server is now not responding on either port.
The output of the -S is:

Code:
VirtualHost configuration:
<MYIP>:80       <MYIP> (C:/Program Files/Apache2.2/conf/httpd.conf:490)
<MYIP>:81       <MYIP> (C:/Program Files/Apache2.2/conf/httpd.conf:501)
Syntax OK
Back to top
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Sat 24 Mar '07 12:38    Post subject: Reply with quote

OK MY stupidity... Sorry, I deleted the Listen statements

Having replaced them and restarted, both ports are functioning but still pointing to the same codebase (Live)
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Sat 24 Mar '07 14:32    Post subject: Reply with quote

The setup you have should work if the IP address in your browser request exactly matches <MYIP>.

For example: if <MYIP> is 192.168.1.123, then a request to http://192.168.1.123:81/ should reach your second vhost.
A request to http://localhost:81/ won't match the IP address because it uses 127.0.0.1 instead of 192.168.1.123.

Maybe what you want is this:
Code:
Listen 80
Listen 81

<VirtualHost _default_:80>
     DocumentRoot "D:/Webserver/Live"
     <Directory "D:/Webserver/Live">
         Options Indexes FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
</VirtualHost>

<VirtualHost _default_:81>
     DocumentRoot "D:/Webserver/Test"
     <Directory "D:/Webserver/Test">
         Options Indexes FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all
     </Directory>
</VirtualHost>

Note that the IP addresses have been replaced with "_default_", and that no ServerName directives are needed inside the <VirtualHost> blocks.

Make sure you do not have a NameVirtualHost directive, and that you have exactly one ServerName directive which is outside the <VirtualHost> blocks.

Only the port number - 80 or 81 - distinguishes the two vhosts.


-tom-
Back to top
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Sat 24 Mar '07 16:55    Post subject: Reply with quote

Thanks, I'll give it a try. For the record, I am using my full corect IP for <MYIP>

I'm sure you can understand that I'd prefer not to post my IP for the world to see Smile

To clarify, Do i still need to specify docroot, etc... OUTside the virtualhost directives?
Back to top
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Sun 25 Mar '07 14:34    Post subject: Reply with quote

THANK YOU!

Don't Ask me why using __default__ worked and using the IP didn't but it now works. Thank you SO much for your help. I've been banging my head against this for a fortnight now.

If you're anywhere in south-west UK, I'll buy you a beer Smile
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Sun 25 Mar '07 17:34    Post subject: Reply with quote

I'm glad it's working for you.

re:"Do i still need to specify docroot, etc... OUTside the virtualhost directives?"
    I don't think you need to - but it is a good idea anyway, in case a request can somehow bypass your two <VirtualHost> blocks.
re: "..._default_ worked and using the IP didn't ..."
    Is the <MYIP> address you used the same one shown by typing ipconfig in a command-prompt window?
    If your external IP address is different from your IP address inside a firewall, Apache will only see your "inside" IP address.
    Also, the name "localhost" uses a different IP address - 127.0.0.1 - which won't match <MYIP>.

-tom-
Back to top
Basiclife



Joined: 22 Mar 2007
Posts: 6

PostPosted: Sun 25 Mar '07 19:08    Post subject: Reply with quote

In place of <MYIP> I was originally using my external IP address as this would be the address passed across in the HOST statement of the header. I did start trying to use my internal 192.168.1.x one afterwards and again no joy.

possibly the fact that it's being NAT'd is causing problems? ie it needs to be for both internal/external so default catches both?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Mon 26 Mar '07 9:30    Post subject: Reply with quote

Code:

Listen 80
Listen 81

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin your@something.com
    DocumentRoot C:/bla
    ServerName yourdom.tld
    ServerAlias www.yourdom.tld
    ErrorLog C:/logs/error.log
    CustomLog C:/logs/access.log common
<Directory "C:/bla">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

NameVirtualHost *:81
<VirtualHost *:81>
    ServerAdmin your@something.com
    DocumentRoot C:/bla2
    ServerName yourdom2.tld
    ServerAlias www.yourdom2.tld
    ErrorLog C:/logs/error2.log
    CustomLog C:/logs/access2.log common
<Directory "C:/bla2">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>
Back to top


Reply to topic   Topic: Apache 2.2 on multiple ports View previous topic :: View next topic
Post new topic   Forum Index -> Apache