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

3rd June 2008, 06:55 PM
|
|
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.
|

3rd June 2008, 07:35 PM
|
|
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.
|

3rd June 2008, 07:44 PM
|
|
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 ~]#
|
|

3rd June 2008, 07:49 PM
|
|
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
|

3rd June 2008, 07:50 PM
|
|
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
|

3rd June 2008, 07:54 PM
|
|
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 ~]#
|
|

3rd June 2008, 07:57 PM
|
|
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 *
|

3rd June 2008, 07:57 PM
|
|
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
|

3rd June 2008, 07:59 PM
|
|
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.
|

3rd June 2008, 08:02 PM
|
|
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.
|

3rd June 2008, 08:05 PM
|
|
Registered User
|
|
Join Date: May 2008
Location: Wiltshire, UK
Posts: 32

|
|
|
Have you restarted apache?
What's the apache error code? 404?
|

3rd June 2008, 08:05 PM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 21

|
|
|
Here are my files...
|

3rd June 2008, 08:07 PM
|
|
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
|

3rd June 2008, 08:11 PM
|
|
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'?
|

3rd June 2008, 08:14 PM
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 14:53 (Wednesday, 22-05-2013)
|
|
 |
 |
 |
 |
|
|