Ubuntu apache vhost_alias setup


/ Published in: Apache
Save to your folder(s)

First of all this refers to a clean Ubuntu 10.04 install with the LAMP and OpenSSH packages installed, but can probably be applied in most cases.

Duplicate the file /etc/apaches/sites-available/default, and name it subdomains.

Edit the new file to look like this one.

Enable the vhost_alias module, "a2enmod vhost_alias".

Activate the new virtual host, "a2ensite subdomains".

Reload apache, "/etc/init.d/apache2 reload".

In order to change the configuration to your needs, [you can go here](
http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html)


Copy this code and paste it in your HTML
  1. <VirtualHost *:80>
  2. ServerAdmin webmaster@localhost
  3.  
  4. ServerName example.com
  5. ServerAlias *.example.com
  6. VirtualDocumentRoot /home/%1/www/html
  7. <Directory />
  8. Options FollowSymLinks
  9. AllowOverride All
  10. </Directory>
  11.  
  12. ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  13. <Directory "/usr/lib/cgi-bin">
  14. AllowOverride None
  15. Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  16. Order allow,deny
  17. Allow from all
  18. </Directory>
  19.  
  20. ErrorLog /var/log/apache2/error.log
  21.  
  22. # Possible values include: debug, info, notice, warn, error, crit,
  23. # alert, emerg.
  24. LogLevel warn
  25.  
  26. CustomLog /var/log/apache2/access.log combined
  27.  
  28. Alias /doc/ "/usr/share/doc/"
  29. <Directory "/usr/share/doc/">
  30. Options Indexes MultiViews FollowSymLinks
  31. AllowOverride None
  32. Order deny,allow
  33. Deny from all
  34. Allow from 127.0.0.0/255.0.0.0 ::1/128
  35. </Directory>
  36.  
  37. </VirtualHost>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.