Newb: Please help me with Virtual Hosting SOLVED Hi, I'm hoping some kind soul will get me past this, I think it's something fairly simple... I have tried to follow the various threads here but I'm still messing something up... I'm wanting to host two sites on my Ubuntu Gutsy box, using Apache2, on *one IP address*. The sites are www.p4pixel.com and www.trackrooms.co.uk. At the moment both addresses are showing the p4pixel site... First, I get this from the terminal: Code: smartin@p4pixel:~$ sudo a2ensite [sudo] password for smartin: Which site would you like to enable? Your choices are: default default~ trackrooms Site name? default Site default installed; run /etc/init.d/apache2 reload to enable. smartin@p4pixel:~$ sudo a2ensite Which site would you like to enable? Your choices are: default default~ trackrooms Site name? trackrooms This site is already enabled! smartin@p4pixel:~$ sudo /etc/init.d/apache2 reload * Reloading web server config apache2 7274 [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost 127.0.0.1:443 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Mon Mar 17 14:19:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [ OK ] smartin@p4pixel:~$ I have the following (key?)files: /etc/apache2/apache2.conf /etc/apache2/httpd.conf /etc/apache2/sites-available/default /etc/apache2/sites-available/trackrooms /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/p4pixel /etc/apache2/sites-enabled/trackrooms /etc/apache2/apache2.conf contains rather a lot but at the end I have: Code: # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ # Listen for virtual host requests on all IP addresses NameVirtualHost 127.0.0.1:80 NameVirtualHost 127.0.0.1:443 # Include the virtual host configurations: Include /etc/apache2/sites-enabled/[^.#]* /etc/apache2/httpd.conf contains nothing at all. /etc/apache2/sites-available/default contains: Code: NameVirtualHost * <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> /etc/apache2/sites-available/trackrooms contains: Code: NameVirtualHost * <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/trackrooms <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/trackrooms/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> /etc/apache2/sites-enabled/000-default contains: Code: NameVirtualHost * <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> /etc/apache2/sites-enabled/p4pixel contains: Code: NameVirtualHost * <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> /etc/apache2/sites-enabled/trackrooms contains: Code: NameVirtualHost * <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> Did I miss anything? Thanks in advance! Simon
Please add Code: ServerName www.trackrooms.co.uk ServerAlias trackrooms.co.uk to the www.trackrooms.co.uk vhost and restart Apache.
Falko, Thanks for your help as always... I'm sorry to be dim but do you mean me to add those lines to /etc/apache2/sites-enabled/trackrooms? I did this and the file now looks like this at the end Code: Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ServerName www.trackrooms.co.uk ServerAlias trackrooms.co.uk </VirtualHost> but it hasn't done the trick I'm afraid. I restarted Apache. Simon
/etc/apache2/sites-available/trackrooms and /etc/apache2/sites-enabled/trackrooms is the same file (/etc/apache2/sites-enabled/trackrooms is just a symlink to /etc/apache2/sites-available/trackrooms). What's the output of Code: apache2 -t ?
Falko, Code: smartin@p4pixel:~$ sudo apache2 -t [sudo] password for smartin: [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost 127.0.0.1:443 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts [Thu Mar 20 15:57:31 2008] [warn] NameVirtualHost *:0 has no VirtualHosts Syntax OK smartin@p4pixel:~$ Did I get your earlier lines in the right place? Simon
Please try Code: NameVirtualHost 83.67.10.173:80 <VirtualHost 83.67.10.173:80> at the beginning of your trackrooms vhost configuration.
Falko, Really appreciate your help with this... /etc/apache2/sites-available/trackrooms now looks like this Code: NameVirtualHost * NameVirtualHost 83.67.10.173:80 <VirtualHost 83.67.10.173:80> <VirtualHost *> ServerAdmin [email protected] DocumentRoot /var/www/trackrooms <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/trackrooms/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2's default start page # in /apache2-default/, but still have / go to the right place #RedirectMatch ^/$ /apache2-default/ </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> I have also tried it like this at the top: Code: NameVirtualHost * <VirtualHost *> NameVirtualHost 83.67.10.173:80 <VirtualHost 83.67.10.173:80> ServerAdmin [email protected] But I still get the wrong site at www.trackrooms.co.uk This is abviously more screwed than I thought... Any further ideas...? Please...? Simon
ok in the /etc/apache2/apache2.conf at the bottom add NameVirtualHost * than in EACH VHOST conf file add this <VirtualHost *> ServerName test.lan ... </VirtualHost> than try to load it up if you got two or more VHost without saying servername for EACH site it will not work it just errors up BIG time hope its helps a tab
try this for the Vhost this is an quick edit jop <VirtualHost *> ServerName trackrooms.co.uk ServerAdmin [email protected] DocumentRoot /var/www/trackrooms <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/trackrooms/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/trackrooms_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/trackrooms_access.log combined ServerSignature On </VirtualHost> <VirtualHost *> ServerName p4pixel.com ServerAdmin [email protected] DocumentRoot /var/www/p4pixel <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/p4pixel/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/p4pixel_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/p4pixel_access.log combined ServerSignature On </VirtualHost>
zcworld, Really appreciate you chipping in mate... We must be nearly there now!! I get no errors when restarting apache now: Code: martin@p4pixel:~$ sudo /etc/init.d/apache2 restart * Restarting web server apache2 [ OK ] smartin@p4pixel:~$ but I'm *still* seeing the wrong site at trackrooms.co.uk! Just to recap: Code: Your choices are: default default~ trackrooms trackrooms~ Site name? trackrooms This site is already enabled! smartin@p4pixel:~$ a2ensite Which site would you like to enable? Your choices are: default default~ trackrooms trackrooms~ Site name? trackrooms~ This site is already enabled! smartin@p4pixel:~$ apache2.conf at the end has: Code: # Include the virtual host configurations: Include /etc/apache2/sites-enabled/ # Listen for virtual host requests on all IP addresses NameVirtualHost * # Include the virtual host configurations: Include /etc/apache2/sites-enabled/[^.#]* Trackrooms vHost file: Code: <VirtualHost *> ServerName trackrooms.co.uk ServerAdmin [email protected] DocumentRoot /var/www/trackrooms/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/trackrooms/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/trackrooms_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/trackrooms_access.log combined ServerSignature On </VirtualHost> Default vHost: Code: <VirtualHost *> ServerName p4pixel.com ServerAdmin [email protected] DocumentRoot /var/www/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/p4pixel_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/p4pixel_access.log combined ServerSignature On </VirtualHost> I tweaked this because the site is in the root www folder... What did I mess up? Simon
really im f**Ed i can tell what is it personal if its just an website box and nothing much on it i would of done an reinstall or removed apache and all of its conf files and reinstalled it and went from clean so there is no change of any iffy files being loaded if u get time i will try to install ubuntu 7 in my test mail server box and see if its works this time for me and setup the conf files and post them for you i will or should be around for the next 4 hrs : to about 2:30 am ish lastest lol
Solved! Guys, Thanks for all your help with this one. The Ubuntu forums found the solution http://ubuntuforums.org/showthread.php?t=727000 You probably asked me to add the ServerAlias and I was too dim to do it... (Edit) Sure enough... Falko's first post. Sorry guys, don't know what I did wrong there. Anyway. Sorted. Thanks! Simon