LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 09-09-2009, 10:38 AM   #1
vertigo12369
LQ Newbie
 
Registered: Feb 2008
Location: Canton, MI
Distribution: Ubuntu
Posts: 7

Rep: Reputation: 0
Apache Virtual Host Document Root


Hi All,

I'm now configuring my web server to server different Virtual Hosts based on DNS name. Right now I store my files in /var/www per the default installation settings in Apache.

Questions:
I want to change the Document Root to /home/username/public_html/example1.dyndns.org for the second virtual server. What do the permissions need to be in order for Apache to read the files in this location? Would it be best to force Apache to run as this new username instead of www-data?

My Virtual host setup will look something like this

<VirtualHost *:80
DocumentRoot /var/www
ServerName default.dyndns.org
#Additional options here

</VirtualHost

<VirtualHost *:80
DocumentRoot /home/username/public_html/example1.dyndns.org
ServerName example1.dyndns.org
#Additional options here

</VirtualHost

I want to change the DocumentRoot as I am running a chrooted ProFTPd server and want to be able to update webserver files via FTP.

I hope this makes sense. I am running Ubuntu 8.04 LTS Server (CLI only).
 
Old 09-10-2009, 03:02 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
As long as apache can read the directory and files, it will be fine. Don't forget the below section if you get 403 errors.
Code:
#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site1/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
My web applications need write permissions (by apache). I have allocated one 'standard' directory in each documentroot for this and did sort out the permissions using ACL so apache can indeed write there.

PS The documentroots for my virtual sites are in /home as shown below (from a Slackware box; I know ubuntu works slightly different).
Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

# catch-all
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /srv/httpd/htdocs
    ServerName btd-techweb02
</VirtualHost>

# site 1
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /home/wim/www/site1/web
    ServerName site1.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site1/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# site2
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /home/wim/www/site2/web
    ServerName site2.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site2/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
 
Old 09-10-2009, 03:03 AM   #3
Fill
Member
 
Registered: Jun 2007
Posts: 96

Rep: Reputation: 16
Hi,

I would do this:

Code:
# cd /home/username
# mkdir public_html
# cd public_html
# mkdir example1.dyndns.org
# chown www-data example1.dyndns.org
That way, user www-data (or whoever you want to) would be able to write and read on the directory example1.dyndns.org, but not on public_html.

See ya
 
Old 09-10-2009, 07:08 AM   #4
vertigo12369
LQ Newbie
 
Registered: Feb 2008
Location: Canton, MI
Distribution: Ubuntu
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks, guys! I have it up an running, but it looks like I should add some lines to handle exceptions and fix some permissions.

Couple more questions I ran across when looking at some HowTos...

Is there anything that needs to be added to the main apache2.conf file to enable virtual hosts or can I just add sites to the /sites-available from a fresh install?

One article says I need to create a file...
/etc/apache2/conf.d/virtual.conf
and put the following statement in the file...

Code:
#  We're running multiple virtual hosts.
#
NameVirtualHost *
#
Another article says I need

Code:
NameVirtualHost <ip>:<Port Number>
In the /etc/apache2/apache2.conf file.


Now I added both of these statements, but noticed that I do the same thing in my virtual host files that are stored in /sites-enabled

What is the correct location to add these statements?
 
Old 09-10-2009, 08:19 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
If you use Ubuntu, stick to articles dedicated to Ubuntu. Do not read anything else as it more than likely does not apply and therefore will confuse you.

What I posted in #2 is the vhosts.conf file as used in Slackware 12 and that's the only place where NameVirtusalHost is used.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2.2 - can not access virtual host document root bobnw Linux - Newbie 8 06-11-2009 06:16 PM
Apache 2: won't allow document root to be changed, plus more QtCoder Linux - Networking 1 11-06-2004 04:44 PM
Virtual hosts refer to the same document root folder kumu Linux - Software 2 09-04-2004 07:19 PM
RH9 Apache Virtual Host Default Document jswilson Linux - Newbie 2 01-29-2004 09:27 AM
Document Root in Apache Hal Linux - Newbie 2 10-28-2003 06:10 AM


All times are GMT -5. The time now is 11:11 AM.

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