Create a subdomain (Apache2)

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

Create an apache config file:

touch /etc/apache2/site-available/blog.mywebsite.com
viĀ /etc/apache2/site-available/blog.mywebsite.com

Insert this configuration:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost

	DocumentRoot /var/www/blog.mywebsite.com
	<Directory />
		Options FollowSymLinks
		AllowOverride All
	</Directory>

	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
</VirtualHost>

Enable the new config

a2ensite blog.mywebsite.com

Put all files under /var/www/blog.mywebsite.com and done!

P/S : To remove a subdomain, run :

a2dissite blog.mywebsite.com

 

Linux Screen Tutorial

Screen is a Linux tool to run multiple virtual terminal from a command line. It is useful when you need to run long processes and you need to close your SSH client. Screen is really life saver.

Start

Start a new Screen

$ screen

Detach

Detach from Screen (left screen running in background)

$ ctrl a d

List

View running virtual terminal in background

$ screen -ls
There are screens on:
5311.pts-0.langkawi (08/23/2013 05:27:39 PM) (Detached)
5253.pts-0.langkawi (08/23/2013 05:27:09 PM) (Detached)
2 Sockets in /var/run/screen/S-ubuntu.

Resume

Resume existing Screen

$ screen -r 5253.pts-0.langkawi

Exit

To exit or close Screen, go inside the Screen and type exit or press ctrl a k.

$ exit

or

$ ctrl a k