Create a Subdomain in Apache2

Let’s say you have a domain and you want to add a subdomain Here’s how to do it.

Create an apache config file:

touch /etc/apache2/site-available/
vi /etc/apache2/site-available/

Insert this configuration:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www/
	<Directory />
		Options FollowSymLinks
		AllowOverride All

	ErrorLog ${APACHE_LOG_DIR}/error.log

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

	CustomLog ${APACHE_LOG_DIR}/access.log combined

Enable the new config


Put all files under /var/www/ and done!

P/S : To remove a subdomain, run :


comments powered by Disqus