LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-10-2011, 07:20 PM   #1
WetDreams
LQ Newbie
 
Registered: Feb 2011
Distribution: Slackware
Posts: 12

Rep: Reputation: 3
Question Setting up Apache 2.2 virtual hosts


I tried to setup a development environment in my local Apache server to have multiple sites, each with its own name. However when I try to access them (ex. http://site1) from a browser I get:
Quote:
Forbidden

You don't have permission to access / on this server.
This is what I have done so far in order to enable vhosts:

Quote:
I created a folder to keep for my projects and added an html file in each site folder

cd
mkdir webdev
cd webdev
mkdir site1 site2

I uncommented the following line in /etc/httpd/httpd.conf
Code:
Include /etc/httpd/extra/httpd-vhosts.conf
and then edited /etc/httpd/extra/httpd-vhosts.conf
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin webmaster@site1
    DocumentRoot /home/reborn/webdev/site1/
    ServerName site1
    ServerAlias *.site1
    ErrorLog "/var/log/httpd/site1.log"
    CustomLog "/var/log/httpd/site1.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@site2
    DocumentRoot /home/reborn/webdev/site2/
    ServerName site2
    ErrorLog "/var/log/httpd/site2.log"
    CustomLog "/var/log/httpd/site2.log" common
</VirtualHost>
and /etc/hosts
Code:
127.0.0.1    localhost
127.0.0.1    site1 site2
In /var/log/httpd/site1.log I get
Quote:
[Sun Dec 11 02:48:41 2011] [error] [client 127.0.0.1] client denied by server configuration: /home/reborn/webdev/site1/
127.0.0.1 - - [11/Dec/2011:02:48:41 +0200] "GET / HTTP/1.1" 403 202
I can post httpd.conf too, if you need it.

Google hasn't helped me much.
I am using slackware 13.37 and Apache version 2.2.21

EDIT: I want to add that the server worked correctly before and still does if I comment again the line in httpd.conf that includes extra/httpd-vhosts.conf, then I can can access localhost from a browser but uses /var/www/htdocs as DocumentRoot.

Last edited by WetDreams; 12-10-2011 at 07:27 PM.
 
Old 12-10-2011, 08:42 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , Solaris 10, RHEL
Posts: 1,935
Blog Entries: 1

Rep: Reputation: 188Reputation: 188
You need a "Directory" directive to allow access to the directory...

Something like this...

Code:
<VirtualHost *:80>
<Directory /home/reborn/webdev/site1>
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>
    ServerAdmin webmaster@site1
    DocumentRoot /home/reborn/webdev/site1/
    ServerName site1
    ServerAlias *.site1
    ErrorLog "/var/log/httpd/site1.log"
    CustomLog "/var/log/httpd/site1.log" common
</VirtualHost>
If you have SELinux turned on you may want to set it to "Permissive Mode"

Code:
setenfore 0
-C
 
Old 12-11-2011, 04:54 AM   #3
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Yes or make /home/reborn/webdev directory globally available

Code:
NameVirtualHost *:80

<Directory "/home/reborn/webdev">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
    ServerAdmin webmaster@site1
    DocumentRoot /home/reborn/webdev/site1/
    ServerName site1
    ServerAlias *.site1
    ErrorLog "/var/log/httpd/site1.log"
    CustomLog "/var/log/httpd/site1.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@site2
    DocumentRoot /home/reborn/webdev/site2/
    ServerName site2
    ErrorLog "/var/log/httpd/site2.log"
    CustomLog "/var/log/httpd/site2.log" common
</VirtualHost>
 
Old 12-11-2011, 05:40 AM   #4
WetDreams
LQ Newbie
 
Registered: Feb 2011
Distribution: Slackware
Posts: 12

Original Poster
Rep: Reputation: 3
Thumbs up

Yes you are right, I added the "Directory" directive and now everything works!

Thanks a lot!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting up virtual hosts Madone_SL_5.5 Linux - Server 4 07-05-2008 04:19 PM
About setting up virtual hosts raymond Linux - General 7 09-21-2004 09:14 AM
apache virtual hosts smaida Linux - Software 3 06-20-2004 04:28 PM
Setting up virtual hosts in Apache using Webmin Spudley Linux - Software 2 09-25-2003 08:50 PM
Apache virtual hosts Mil0 Linux - Software 5 06-01-2003 11:58 PM


All times are GMT -5. The time now is 07:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration