DIGIT-ARC read-only archive · snapshot: July 23, 2026

WEb Server....Adding virtual...host how?

18 posts · originally from https://geek.digit.in/community/threads/web-server-adding-virtual-host-how.22659/

mediator
mediator Original post #1
Jan 24, 2006 at 7:54 PM
Post has been edited
Please If u have experience in making web server then please post else dont post by copying articles from net ect.! Coz I'm really frustrated reading samething again n again! My first question below has been solved..answer my 2nd one...scroll down below!
Forbidden
You don't have permission to access /index.html on this server.


This is the error that is killin me now whenever I try to access the the page!
The index.html page resides in /var/www/html.... I tried to run it through different browsers but no luck.

Previosly it was working fine but when I removed the index.html and made a new one the problem started! I tried index.htm with no luck. I added date.php to /var/www/html and can access it with *localhost/date.php, but *localhost/index.html gives me the reported error!

Help please..Thanx in advance!
praka123
Jan 24, 2006 at 9:50 PM
Did U entered the dir containing index.html in the Apache config file
mediator
Jan 24, 2006 at 10:17 PM
U mean documentroot..then yes!
desertwind
Jan 24, 2006 at 10:39 PM
Have you set read permissions to all ?

try

Code:
$ chmod 755 index.html
mediator
Jan 25, 2006 at 12:26 AM
i'll try that n post again...but what do u mean by all?
desertwind
Jan 25, 2006 at 12:50 AM
Read it as

Have you set read permissions to all users?

Thats what the code is meant for.
mediator
Jan 25, 2006 at 12:55 AM
Thanx man...that really worked...755 worked!

And can explain what is 755..I forgot that! I remember it has somethin to do with user,group,others like that!


One thing more I wanna set up virtual hosts..can u explain how to do that?
my configuration file for *med.dl is as..
<VirtualHost 127.0.0.2>
DocumentRoot /home/mediator/www
ServerName med.dl
DirectoryIndex index.html index.htm index.shtml
</VirtualHost>
I thought it wud be OK..but when i tried *med.dl and *localhost/med.dl it gave "The requested URL /zwat was not found on this server." error!.
When I tried *127.0.0.2 it said "You don't have permission to access / on this server" error again!

I want to setup a virtual host "med"...So that whenever i try to browse *localhost/med it points to /home/mediator/www

I also tried 755 permission for this one bt v.host cudnt bed established!
desertwind
Jan 25, 2006 at 4:33 AM
755 stands for -rwxr-xr-x

Its sets permisions in the following order. owner, group, others
4 for read, 2 for write and 1 for execute. simply add the numbers for which all permissions you need to set up. for allowing read and execute, 4+1=5. for allowing read and write, 4+2=6.

755 stands for read,write and execute to owner, read and execute to group, read and execute to others.

Regarding virtual Hosts, read this
mediator
Jan 25, 2006 at 10:01 AM
Tried...
# Virtual host 127.0.0.2
<VirtualHost 127.0.0.2>
DocumentRoot /home/med/www
<Directory "/home/med/www">
Options all
AllowOverride none
</Directory>
ServerPath /med
ServerName localhost

DirectoryIndex index.html index.htm index.shtml
<Directory "/home/med/www">
Options all
AllowOverride none
</Directory>
</VirtualHost>

But no Luck!
desertwind
Jan 25, 2006 at 10:45 AM
Also try changing userDir to public_html
mediator
mediator #11
Jan 25, 2006 at 10:50 PM
desertwind said:
Also try changing userDir to public_html
I didnt get that one! Can u explain?
desertwind
Jan 26, 2006 at 12:18 AM
The default value of userDir in httpd.conf is set to disable. comment that line and uncomment the line userDir public_html
mediator
mediator #13
Jan 26, 2006 at 12:35 AM
Yea tried that one but still no luck! HElp!
T
Feb 12, 2006 at 7:59 PM
R U having SELinux???? in that case, u gotta check the security context...
mediator
mediator #15
Feb 12, 2006 at 9:24 PM
Yea Already know now how to configure everything...neways thanx for concern! Now I need to know how to lock the topic!
I had initially configured selinux to allow the virtual host...but the problem persisted.....so i configured host file and permissions...added a entry in it and hooray it worked!
desertwind
Feb 13, 2006 at 12:44 AM
mediator said:
Now I need to know how to lock the topic!

Thats a bit tough. ;)

request a mod to do that.
M
mehulved #17
Feb 13, 2006 at 2:00 AM
Or to request a mod status :-D if you want a longer way around.
mediator
mediator #18
Feb 15, 2006 at 10:58 PM
OK here's the complete process I learnt after years of research to setup a web server completely on a local machine (loopback) ! To setup network http server u dont have to edit host file!



Setting Web server
"*mediator" ..... on local machine ...loopback


1.
HOST FILE
/etc/host

127.0.0.1 localhost.localdomain localhost Machine_Name
127.0.0.2 mediator


2.
READ PERMISSIONS
755 stands for -rwxr-xr-x

Its sets permisions in the following order. owner, group, others
4 for read, 2 for write and 1 for execute. simply add the numbers for which all permissions you need to set up. for allowing read and execute, 4+1=5. for allowing read and write, 4+2=6.

755 stands for read,write and execute to owner, read and execute to group, read and execute to others.

So that the error "You do not have permission to..." doesnt occur for new directory such as /home/user1/www the whole path must be readable and code executable. Apache by default doesnt have permission to read into /home/user1 directory
permission -> 755 or 745
command...."chmod 755 /home/user1"..."chmod 755 /home/user1/www"
command...."chomd 755 /home/user1/www.index.html"


3.
HTTPD FILE
~../httpd.conf

# Virtual host med
<VirtualHost 127.0.0.2>
DocumentRoot /home/mediator/www
ServerName med
<Directory /home/mediator/www>
order allow,deny
allow from all
</Directory>
<Location /home/mediator/www>
order allow,deny
allow from all
</Location>
DirectoryIndex index.html index.htm index.shtml
</VirtualHost>


If problem Still persists..Then configure the seLinux to allow the document directory...or disable selinux for http service as last resort!!