Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 3rd June 2008, 06:55 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Help setting up VirtualHost

Hi all,

I know this is probably going to sound such a newbie question but I've been googling my answer for 2 days and still can't set it up correctly.

Okay, I am on a home network behind a wireless router. My IP is 192.168.0.3. I've set up FC 9 (with Apache2) so that I can write/develop and test my websites/scripts but want to do it under different directories and from different host addresses.

In the httpd.conf I have the following set up as a VirtualHost;

Quote:
NameVirtualHost 192.168.0.3:80

<VirtualHost 192.168.0.3:80>
ServerAdmin root@localhost
ServerName webone
DocumentRoot /home/kevin/www/
ErrorLog /home/kevin/www/log/error-log
CustomLog /home/kevin/www/log/error-log common
<Directory "/home/kevin/www/">
Options Indexes FollowSymLinks Includes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And in the /etc/hosts.conf I got,

Quote:
order hosts,bind

192.168.0.3 webone
So, the basics of it I want to put webone in the browser that then serves pages from /home/kevin/www

However all I get is the webone .com. au so it goes externally.

I'm totally at a loss with this one. someone please help.
Reply With Quote
  #2  
Old 3rd June 2008, 07:35 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
Humm....

I think what i do is similar to what you want to achieve; so here goes:

I tend to have a local domain for each project I'm working on. The domains are in the following format: local.<projectname>.com

So i have a virtual host for each project. Here's my httpd.conf:

Code:
NameVirtualHost *

<VirtualHost *>
   ServerName localhost
   DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
        ServerName projectone.local.com
        DocumentRoot /home/jon/www/projectone.local.com/
        <Directory "/home/jon/www/projectone.local.com/">
                AllowOverride All
                Order deny,allow
        </Directory>
        ErrorLog /var/log/httpd/projectone.local.com-error_log
        CustomLog /var/log/httpd/projectone.local.com-access_log common
</VirtualHost>

<VirtualHost *>
        ServerName projecttwo.local.com
        DocumentRoot /home/jon/www/projecttwo.local.com/
        <Directory "/home/jon/www/projecttwo.local.com/">
                AllowOverride All
                Order deny,allow
        </Directory>
        ErrorLog /var/log/httpd/projecttwo.local.com-error_log
        CustomLog /var/log/httpd/projecttwo.local.com-access_log common
</VirtualHost>
Therefore my /etc/hosts file looks like this:

Code:
127.0.0.1       projectone.local.com
127.0.0.1       projecttwo.local.com
Does this help?

Regards,
Jon

Last edited by reeksy; 3rd June 2008 at 07:38 PM.
Reply With Quote
  #3  
Old 3rd June 2008, 07:44 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Hi Jon,

I just tried it but something else is happening now...

Quote:
NameVirtualHost *

<VirtualHost *>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
ServerName proj1.localhost
DocumentRoot /home/kevin/www/proj1/
<Directory "/home/kevin/www/proj1/">
AllowOverride All
Order deny,allow
</Directory>
ErrorLog /home/kevin/www/proj1/logs/error-log
CustomLog /home/kevin/www/proj1/logs/error-log common
</VirtualHost>
I get this error restarting apache,

Quote:
[root@localhost ~]# /etc/init.d/httpd restart
Stopping httpd: [FAILED]
Starting httpd: Warning: DocumentRoot [/home/kevin/www/proj1/] does not exist
[Tue Jun 03 19:41:49 2008] [error] VirtualHost _default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[FAILED]
[root@localhost ~]#
Reply With Quote
  #4  
Old 3rd June 2008, 07:49 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Just noticed I didn't create the directories, so I created them, but now get this error;

Quote:
[root@localhost ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [Tue Jun 03 19:46:57 2008] [error] VirtualHost _default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[ OK ]
[root@localhost ~]#
when trying to acces localhost I get error 400 - Bad Request
Reply With Quote
  #5  
Old 3rd June 2008, 07:50 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
Do you still have:

Code:
NameVirtualHost 192.168.0.3:80
in your conf file? If so, remove it.

Ensure that /home/kevin/www/proj1/ is a directory:

Code:
$ mkdir /home/kevin/www
$ mkdir /home/kevin/www/proj1
Reply With Quote
  #6  
Old 3rd June 2008, 07:54 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
I'm getting closer I think...

I have

Quote:
NameVirtualHost *:80

<VirtualHost *>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
ServerName proj1.localhost
DocumentRoot /home/kevin/www/proj1/
<Directory "/home/kevin/www/proj1/">
AllowOverride All
Order deny,allow
</Directory>
ErrorLog /home/kevin/www/proj1/logs/error-log
CustomLog /home/kevin/www/proj1/logs/error-log common
</VirtualHost>
and

Quote:
127.0.0.1 localhost
127.0.0.1 proj1.localhost
I have a directory set up in /home/kevin/www/proj1 with a logs folder and a cgi-bin folder

Now when restarting Apache I get;

Quote:
[root@localhost ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [Tue Jun 03 19:53:46 2008] [warn] NameVirtualHost *:80 has no VirtualHosts
[ OK ]
[root@localhost ~]#
Reply With Quote
  #7  
Old 3rd June 2008, 07:57 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
What happens when you navigation to http://proj1.localhost ?

Do you need to *:80? I just use *

Code:
NameVirtualHost *
Reply With Quote
  #8  
Old 3rd June 2008, 07:57 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Now, rather than <VirtualHost *> I have edited to read <VirtualHost *:80> and apache restarts perfectly.

localhost works but proj1.localhost doesn't - the browser tries to get it externally and puts it a http://www.proj1.localhost resulting in a Address Not Found
Reply With Quote
  #9  
Old 3rd June 2008, 07:59 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
What happens if you use a 'sub domain'? At the moment you're just using 'proj1.localhost' I would suggest using a prefix (kevin for example). Like:

Code:
NameVirtualHost *

<VirtualHost *>
ServerName localhost
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
ServerName kevin.proj1.localhost
DocumentRoot /home/kevin/www/proj1/
<Directory "/home/kevin/www/proj1/">
AllowOverride All
Order deny,allow
</Directory>
ErrorLog /home/kevin/www/proj1/logs/error-log
CustomLog /home/kevin/www/proj1/logs/error-log common
</VirtualHost>
And your hosts file would read

Code:
127.0.0.1     kevin.proj1.localhost

Last edited by reeksy; 3rd June 2008 at 08:03 PM.
Reply With Quote
  #10  
Old 3rd June 2008, 08:02 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Just changed the ServerName to kevin.proj1.localhost in the httpd.conf and hosts.conf but still Address Not found.

I can't work it out.
Reply With Quote
  #11  
Old 3rd June 2008, 08:05 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
Have you restarted apache?

What's the apache error code? 404?
Reply With Quote
  #12  
Old 3rd June 2008, 08:05 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Here are my files...
Attached Files
File Type: conf host.conf (52 Bytes, 44 views)
File Type: conf httpd.conf (33.3 KB, 38 views)
Reply With Quote
  #13  
Old 3rd June 2008, 08:07 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Quote:
Originally Posted by reeksy
Have you restarted apache?

What's the apache error code? 404?

I don't get an apache error page, just a Firefox Address Not Found page
Reply With Quote
  #14  
Old 3rd June 2008, 08:11 PM
reeksy Offline
Registered User
 
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32
Quote:
Originally Posted by slipdigby
I don't get an apache error page, just a Firefox Address Not Found page
Is the address in the bar 'http://kevin.proj1.localhost'?
Reply With Quote
  #15  
Old 3rd June 2008, 08:14 PM
slipdigby Offline
Registered User
 
Join Date: May 2008
Posts: 21
Quote:
Originally Posted by reeksy
Is the address in the bar 'http://kevin.proj1.localhost'?
yep the address is correct just won't load it.

localhost still works though and apache has been restarted
Reply With Quote
Reply

Tags
setting, virtualhost

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VirtualHost 403 error alexgeek Servers & Networking 5 25th September 2008 06:16 PM
Apache (VirtualHost) with my own DNS server onastvar Servers & Networking 9 17th January 2008 03:07 PM
virtualhost + cgi in apache ?? blackwoodie Servers & Networking 0 22nd November 2006 06:51 PM


Current GMT-time: 14:53 (Wednesday, 22-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat