Here is a clean way of doing this on Suse.
in /etc/apache2/httpd.conf make sure there is an include to a
directory with all of your virtual hosts definitions:
Include /etc/apache2/vhosts.d/*.conf
then in my /etc/apache2/listen.conf I have (it could go anywhere in
reality but SUSE puts it in here.) And I am willing to bet that this
is the part you have missed out if you are still not up and running:
NameVirtualHost *:80
and as I use Passenger i have the following file: /etc/apache2/
vhosts.d/passenger.conf
these are the Apache directived to load the passenger runtime module
for Rails. These are used by the rails virtual hosts
LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/
passenger-2.2.2/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.2.2
PassengerRuby /usr/bin/ruby
PassengerUserSwitching off
PassengerDefaultUser wwwrun
then for each of your virtual hosts put a file in /etc/apache2/
vhosts.d/example.conf (I redirect example.com to www.example.com for
which you have to enable the rewrite Apache module)
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) http://www.example.com/$1 [L,R]
RailsEnv production
RailsBaseURI /
<Directory /srv/www/vhosts/example/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
DocumentRoot /srv/www/vhosts/example/current/public
ErrorLog /var/log/apache2/example_production_error_log
TransferLog /var/log/apache2/example_production_access_log
LogLevel warn
Another simple thing here is that if you rename a example.conf to
example.conf.disable and do a rcapache2 restart then you can take a
virtual host off-line.
I did think at one stage at templating this using capistano (and some
have) but I decided to keep everything in Git. Then it is easy to
move virtual hosts between servers.
On my setup I am still not happy on where the errors go to (mainly the
default server error log for some reason) so any ideas out there on
why this is the case.
O.