multiple websites host one server

How to install Multiple Websites host on ubuntu server AWS and connect our domain name server I am starting with install apache server I am using AWS ec2-Machine

Installing Apache webserver on ubuntu server

apt install apache2

changing directory cd command

cd /var/www/
Multiple Websites host
Creating two apache root directories for our website server
mkdir -p ctfplayer.com/public_html
mkdir -p jameshacker.me/public_html
Multiple Websites host
Changing Permission our Web directories
chmod -R 755 ctfplayer.com/
chown -R www-data:www-data ctfplayer.com/
chmod -R 755 jameshacker.me/
chown -R www-data:www-data jameshacker.me/
cd ctfplayer.com/public_html

Creating an index.html for testing purpose

vi index.html
<html>
	<head>
		<center><h1>ctfplayer.com</h1>
		<title> ctfplayer</title>
		<h3> This is our First Website for demo </h3></center>
	</head>
</html>

I am copying the index.html file our second website root directory

cp index.html /var/www/jameshacker.me/public_html/
cd /var/www/jameshacker.me/public_html
ls

Editing our second website default index.html file

vi index.html
Multiple Websites host
<html>
	<head>
		<center><h1>jameshacker.me</h1>
		<title> JamesHacker</title>
		<h3> This is our Second Website for demo </h3></center>
	</head>
</html>
Multiple Websites host

creating a virtual-host our websites I am copy 000-default.conf file ctfplayer.com.conf and jameshacker.me.conf

cd /etc/apache2/sites-available/
cp 000-default.conf ctfplayer.com.conf
cp 000-default.conf jameshacker.me.conf

Configure Virtual Host in Apache to host multiple domains

now configure our virtual host in apache configuration file Go to the apache conf location. ( in default installation – you will find it here /etc/apache2/sites-available

I am copying the default 000-default.conf to our domain name ctfplayer.com.conf and again copy the default 000-default.conf file to our second domain name ctfplayer.com.conf

Editing our first virtual host file ctfplayer.com.conf and add server name and our root directory

vi ctfplayer.com.conf 
ServerName ctfplayer.com

        ServerAlias www.ctfplayer.com

	ServerAdmin [email protected]

	DocumentRoot /var/www/ctfplayer.com/public_html

Editing our second virtual-host file jameshacker.me.conf

vi jameshacker.me.conf
ServerName jameshacker.me

        ServerAlias www.jameshacker.me

	ServerAdmin [email protected]

	DocumentRoot /var/www/jameshacker.me/public_html
Multiple Websites host

enable our virtual-host configuration file

sudo a2ensite ctfplayer.com.conf
sudo a2ensite jameshacker.me.conf
Multiple Websites host

now disable our default apache server configuration file 000-default.conf remember after disabling apache2 default configuration file default host is not working

sudo a2dissite 000-default.conf

after creating and enable our virutal-host we need to restart our apache2 server

service apach2 restart
Multiple Websites host
Configure our domain DNS record connection our server IP address

Go to your domain name provider and log in your account my case I am using Godaddy go to the Domains section and you see your domain now changing our DNS record for connecting our hosting server

Multiple Websites host

After click DNS we see our DNS Records now adding our hosting IP address remember to delete your old A Type records and click the add button choose to Type-A Records and Host section @ and Point to address (your hosting IP address and TTL Value is default and save button

Same configuration our second domain DNS record
Multiple Websites host

Add A record (associates a name with an IP address) server address and click save button to save our records file

Multiple Websites host
checking our Website is connect properly to our hosting server

ctfplayer.com Checking our first Website in the web browser and we see our first web site default web page index.html

Multiple Websites host

jameshacker.me Checking our Second Website in the web browser and again we see our default index.html file

Multiple Websites host

Joomla setup apache server read here

About Rahul Gehlaut

Cyber Security Researcher, CTF Player. Tech Blog Writer.

View all posts by Rahul Gehlaut →