0

Ok, the problem is presented like this:

  • I have a single IP (123.123.123.123)
  • I have multiple domains
  • I work with subdomains for testing

So basically I need to host www.example.com, wwww.example2.com as well as subdomains for a couple of development users user1.example.com and user2.example2.com. On top of that www.example.com will also need to use port 443.

I've seen a lot of things suggested and none of them seem to work. Maybe I just need the blanks filled in here that will actually work?

Listen ???
NameVirtualHost ???
<VirtualHost ???>
    DocumentRoot /home/user1/example.com
    ServerName user1.example.com
    ErrorLog logs/user1.example.com-error_log
    CustomLog logs/user1.example.com-access_log common from all
    <Directory "/home/user1/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost ???>
    DocumentRoot /home/user2/example.com
    ServerName user2.example.com
    ErrorLog logs/user2.example.com-error_log
    CustomLog logs/user2.example.com-access_log common from all
    <Directory "/home/user2/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost ???>
    DocumentRoot /home/www/example.com
    ServerName www.example.com
    ErrorLog logs/www.example.com-error_log
    CustomLog logs/www.example.com-access_log common from all
    <Directory "/home/www/example.com/public">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# Entry for 443
<VirtualHost 67.23.39.254:443>
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
    SSLCertificateFile /etc/httpd/conf/ssl/example/www.example.com.crt
    SSLCertificateKeyFile /etc/httpd/conf/ssl/example/example.key
    SSLCertificateChainFile /etc/httpd/conf/ssl/example/gd_bundle.crt
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    DocumentRoot /home/www/example.com
    ServerName www.example.com
</VirtualHost>

Then the same sort of thing for example2.com. Example2.com may use a different ssl cert than example.com, which I know will probably require a second IP address, but maybe someone here can advise.

Tomas
  • 101
  • 1

1 Answers1

1

Probably easies way will be to use * as IP for virtualhosts, example:

Listen 80
Listen 443
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName user1.example.com
  # config for user1.example.com here as in your config...
</VirtualHost>
# repeat lines above as many times as you need

# For SSL:
<VirtualHost 123.123.123.123:443>
....
</VirtualHost>
rombarcz
  • 131
  • 3
  • @romke Yeah, I've tried that and all I get is the Apache Test Page. It's like my DocumentRoot and Directory directives are just being ignored. – Tomas Apr 26 '11 at 17:20
  • Really strange thing, in testing I removed all but one virtualhost, got rid of the NameVirtualHost, added the IP to the and I get this error when restarting apache... Starting httpd: [Tue Apr 26 13:39:47 2011] [warn] VirtualHost XXX.XXX.XXX.XXX:80 overlaps with VirtualHost XXX.XXX.XXX.XXX:80, the first has precedence, perhaps you need a NameVirtualHost directive – Tomas Apr 26 '11 at 17:42
  • NameVirtualHost must have EXACTLY same value as VirtualHost, e.g. when you have `` then you have to have `NameVirtualHost 123.45.67.89:80` BEFORE all VirtualHosts definitions – rombarcz Apr 26 '11 at 18:45
  • Yeah, still not working... I'm about to yank the rest of my hair out here. I had everything working last night before I tried adding the 2nd subdomain user2 and I forgot to back up my file. Now I can't even get a single entry to work. I either get a blank page or I get the Apache Test Page. Very frustrating. – Tomas Apr 26 '11 at 19:23
  • Are you putting correct domains in ServerName? Do you have apache config in single file or in several? Check again order of directives, Listen and NameVirtualHost should be before any virtualhost definitions. Blank page? what logs are saying about it? check each time both access and error logs in your defined files but also in default apache location... – rombarcz Apr 26 '11 at 19:33
  • I decided to just start fresh so I removed httpd and reinstalled and some things are working again so I must have messed some setting in the config somewhere that I didn't know. I will test your above solution on this fresh install and if it works, perfect, thanks. – Tomas Apr 26 '11 at 19:57