LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Apache Virtualhosts and subdomains (http://www.linuxquestions.org/questions/linux-networking-3/apache-virtualhosts-and-subdomains-398509/)

arew264 01-01-2006 10:24 PM

Apache Virtualhosts and subdomains
 
I have a DNS server running on Debian linux that lets the computers on my network go to domain.com and connect to an apache2 server running on the same Debian box. I want to create the subdomain forum.domain.com, yet it does not work. I think I need to place a virtual host file in the /etc/apache2/enabled-hosts folder, yet this does not work. This is the default file in that folder that lets people connect when you install apache:
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/host/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Here is the file I have been trying to get to work:

NameVirtualHost *
<VirtualHost forum.domain.com:80>
ServerAdmin (removed in the post to stop spam)

DocumentRoot /var/www/host/phpBB2/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/host/phpBB2>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# RedirectMatch ^/$ /apache2-default/
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access2.log combined
ServerSignature On

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

kbuk 01-03-2006 08:53 AM

ok for a start forum.domain.com is NOT a sub-domain (go have a look at a full dns manual / rfc for what a subdomain is. forum.domain.com is just a virtual host.

You'll need to add an A record for forum in the domain.com file in bind (or whatever dns server you're using).
Then make sure it resolves to your server.

Then create a regular virtual host eg

<VirtualHost ip_address : port>
Options ExecCGI Includes
DocumentRoot /path/to/files
ServerAdmin webmaster @ email.address
ServerName forum.domain.com
ScriptAlias /cgi-bin/ /path/to/cgi/bin/
ErrorLog /path/to/log/file
</VirtualHost>

The correct way is to create a file in the
/etc/apache2/sites-available then symlink it to /etc/apache2/sites-enabled

You'll probably want to specify the ip and port that the apache listens on


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