LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-15-2009, 01:35 PM   #1
mohtech
Member
 
Registered: Dec 2004
Location: Denver Colorado
Distribution: Kubuntu/Debian
Posts: 120

Rep: Reputation: 15
I am confused about best practices for virtual hosts under Debian LAMP setup


I have created my virtual hosts under ..../apache2/sites-available
and ran a2ensite sitename

that configuration works, but one domain supersedes the other (local server, development machine running Ubuntu 8.10

I moved both configurations to my httpd.conf file, and everything seems happier.

Is it better to use separate files under sites-avaiable/sites-enabled or to throw everything into httpd.conf?

and why?
 
Old 03-15-2009, 10:33 PM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
I have a site with multiple subdomains. I just put a lot of stuff into /etc/apache2/sites-enabled/000-default and runs "apache2ctl restart" and it works perfectly. Though if you have a lot of different virtual hosts you could put them in seperate files just to make it easier to manage (for humans). But I don't believe that there is any difference for apache in which file or how many files you have you configuration in. As long as all files are parsed it should work out fine.

Anyway, here's my virtual hosts:
Quote:
NameVirtualHost *:80

<Virtualhost *:80>
ServerName *.jovianvoid.com
DocumentRoot /var/www/jovianvoid/

<Directory /var/www/jovianvoid/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

<Virtualhost *:80>
ServerName ps3music.jovianvoid.com
DocumentRoot /var/www/ps3music/

<Directory /var/www/ps3music/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

<Virtualhost *:80>
ServerName dynapt.jovianvoid.com
DocumentRoot /var/rails/dynapt/public/

<Directory /var/rails/dynapt/public>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</Virtualhost>

<Virtualhost *:80>
ServerName ephracis.jovianvoid.com
DocumentRoot /var/rails/ephracis/public/

<Directory /var/rails/ephracis/public/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</Virtualhost>


<Virtualhost *:80>
ServerName libertas.jovianvoid.com
DocumentRoot /var/www/empty/

<Directory /var/www/empty/>
Options ExecCGI FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>

<Location /svn>
DAV svn
SVNPath /var/svn_repos/libertas
#SVNAutoversioning on
AuthType Basic
AuthName "Libertas SVN repository"
AuthUserFile /etc/svn-auth-libertas
Require valid-user
</Location>

</Virtualhost>

<Virtualhost *:80>
ServerName snowhard.jovianvoid.com
DocumentRoot /var/trac/htdocs
#ErrorLog /var/trac/log

# <Directory /var/trac/>
# Options ExecCGI FollowSymLinks
# AllowOverride all
# Order allow,deny
# Allow from all
# </Directory>

# DocumentRoot /var/local/trac/trac.example.com/
Alias /trac/ /usr/lib/python2.5/site-packages/Trac-0.11.1-py2.4.egg/trac/htdocs
<Directory "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.4.egg/trac/htdocs">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location />
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonInterpreter main_interpreter
PythonOption TracEnv /var/trac
PythonOption TracUriRoot /
#AuthType Basic
#AuthName "trac.example.com"
# Use the SVN password file.
#AuthUserFile /var/local/svn/svn.example.com/conf/passwd
#Require valid-user
</Location>
# CustomLog /var/log/apache2/trac.example.com/access.log combined
# ErrorLog /var/log/apache2/trac.example.com/error.log
# SSLEngine on
# SSLCertificateFile /etc/apache2/ssl/apache.pem
# Add this once there is a real (non self-signed) certificate.
# SSLCertificateKeyFile /etc/apache2/ssl/server.key

# <Location "/login">
# AuthType Basic
# AuthName "Trac"
# AuthUserFile /var/trac/trac.htpasswd
# Require valid-user
# </Location>

<Location /svn>
DAV svn
SVNPath /var/svn/
#SVNAutoversioning on
AuthType Basic
AuthName "SVN login = Trac login"
AuthUserFile /var/trac/trac.htpasswd
Require valid-user
</Location>

<Location /svn2>
DAV svn
SVNPath /var/svn2/
#SVNAutoversioning on
AuthType Basic
AuthName "SVN login = Trac login"
AuthUserFile /var/trac/trac.htpasswd
Require valid-user
</Location>

# <Location /new>
# SetHandler mod_python
# PythonHandler trac.web.modpython_frontend
# PythonInterpreter main_interpreter
# PythonOption TracEnv /var/trac/trac_new
# PythonOption TracUriRoot /
# </Location>
</Virtualhost>
I am not sure if this is the best practice but it works for me and does what I want it to do. Though I am no expert on Apache's virtual hosts.

I also commented out the line "NameVirtualHost *:80" inside /etc/apache2/ports.conf to get rid of a warning message when booting apache.
 
  


Reply

Tags
apache2, hosts, virtual


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
LAMP with Debian Etch on a Virtual Machine & Leopard as host riganta Linux - Server 4 12-18-2008 11:35 AM
how do I setup virtual hosts in Apache 2.0.54 on linux canegames Linux - Software 2 06-25-2006 10:27 AM
apache-ssl setup virtual hosts notolerance Linux - Software 3 12-22-2005 05:20 PM
webalizer setup for virtual hosts intranet_man Linux - Security 1 03-03-2005 01:00 PM
How to setup virtual hosts for a web site? George2 Linux - Software 4 10-21-2003 04:46 AM


All times are GMT -5. The time now is 06:08 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