LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   I am confused about best practices for virtual hosts under Debian LAMP setup (http://www.linuxquestions.org/questions/linux-server-73/i-am-confused-about-best-practices-for-virtual-hosts-under-debian-lamp-setup-711769/)

mohtech 03-15-2009 12:35 PM

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? :)

Ephracis 03-15-2009 09:33 PM

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.


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