PDA

View Full Version : Apache Virtual Hosts


danno
09-24-2008, 09:00 AM
I am new to Westhost. I've been a unix user for years, but am only moderately skilled on web hosting. I am trying to stumble through a configuration issue for my site. I want to install egroupware and joomla, then slowly move joomla to typo3. In order to do that I would like to use Virtual Hosts. however, I can't quite seem to get the configuration right. It seems to me that all I need to do is add the following entries to my httpd.conf file. I haven't added Typo3/eGroupware yet - once I get joomla up and running then it should be reasonably simple to throw on a new virtual host for each new directory. One note, my domain is not fully transferred yet, so if I have to wait for the DNS transfer to complete, let me know. Could someone advise me as to what is wrong with this configuration?

NameVirtualHost ???.???.???.???
<VirtualHost _default_:*>
RedirectMatch permanent (.*) http://www.aaaaaaaaa.net
</VirtualHost>

#<VirtualHost ???.???.???.???>
#ServerName www.aaaaaaaaa.net
#DocumentRoot /var/www/html
#</VirtualHost>

<VirtualHost ???.???.???.???>
ServerName www.aaaaaaaaa.net/bluehost
DocumentRoot /usr/local/httpd/bluehost
AddHandler application/x-httpd-php5 .php
AddHandler application/x-httpd-php .php
ReWriteEngine on
RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
<Directory>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

danno
09-26-2008, 02:23 AM
I have been thinking this one through and have found some possible answers, but not what I really wanted. I will have to use subdomains to get multiple apps installed on the same domain. Then I can have Joomla installed at the root, eGroupware installed at gw.????.net, and typo3 installed at test.????.net.

But now I have a question about subdomains. Why does the site manager take a subdomain like gw.????.??? and give it the directive ServerAlias www.gw.????.???? What is the ServerAlias directive for and can I simply remove it?

The next question is that I want the DocumentRoot for Joomla elsewhere than /var/www/html. So how can I move that elsewhere and still have access to site manager?

wildjokerdesign
09-26-2008, 08:25 AM
Well ServerAlias is supposed to be other names that can be used to access the same site. From my experience when it comes to sub domains on a WestHost account this added ServerAlias that the Site Manager adds is ignored. I actually had a client who wanted to be able to access their subdomain via www.sub.domain.com and in order for that to happen I had to set up two subdomains via the Site Manager.

When I have added second domains to an account I have had to go in and add the www.seconddomain.com as a subdomain of the new second domain.

Something to note is this bit of information from the Apache Manual:
Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.

When you add a subdomain or second domain via your Site Manager I am pretty sure there is more that happens then just the VirtualHost being added to your httpd.conf. :) I would imagine that the WestHost VPS environment also "informs" the DNS server of the addition and updates it as needed.

Now there is something called a Wildcard DNS. It is something that is needed for Wordpress MU and you have to contact WestHost to have them set it up. See this Forum Thread (http://forums.westhost.com/showthread.php?t=10486) on the subject. I am not sure if that is something you need or not but thought it was worth mentioning.

Did you install Joomla via the Site Manager? If so I would suggest uninstalling it and doing a manual install of Joomla. You well have more control over the installation and in your case that is what you want. :)

I didn't fully follow what you wanted in your first post which is why I did not respond at first, hoping someone else would understand and reply.

I am pretty sure that your Directory directive needs to have the path added even though it is inside the VirtualHost. At least I have always supplied the path when setting up a Directory directive for a VirtualHost. I think that Directory directives are "based" not on the DocumentRoot but on the root of the account.

danno
10-01-2008, 09:03 AM
Thanks for the info. I ended up just deleting the Alias keyword.

Regarding my Joomla, I am dumping Bluehost due to numerous problems on thier service in the last 6 months. They were great for several years, but recently have had almost daily problems with my site. So I backed up Joomla and Gallery on Bluehost and restored them here on Westhost. So the install was really a backup and then I took advantage of the move and upgraded to the latest 1.0 series.

My original intent was to separate my sites into their own directories. I did not want my groupware for email and my personal web site to get mixed in with the Westhost apps like site manager and the installed phpMyAdmin. By using subdomains I can move all the files elsewhere on my server so they are easy to clean out later if I so choose.

However, I couldn't move the document root without removing access to site manager. In the end, I came up with the following entries to keep my stuff separate from Westhost and allow access to site manager through www.domain.com.whsites.net/manager.

Note there are a couple other changes to the httpd.conf file but the bulk of the changes are in the virtual hosts section. Since I haven't installed typo3 for testing yet, I don't have a subdomain defined yet.

NameVirtualHost xxx.xxx.xxx.xxx
<VirtualHost _default_:*>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
</IfModule>
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
ServerName www.domain.com
DocumentRoot /usr/local/httpd/bluehost
<Directory /usr/local/httpd/bluehost>
<IfModule mod_rewrite.c>
ReWriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
</IfModule>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
ServerName www.domain.com.whsites.net
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
</Directory>
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
ServerName gw.domain.com
DocumentRoot /usr/local/httpd/gw
CustomLog logs/gw.log combined
ErrorLog logs/gw-error.log
</VirtualHost>