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
1 |
apt install apache2 |
changing directory cd command
1 |
cd /var/www/ |
Creating two apache root directories for our website server
1 |
mkdir -p ctfplayer.com/public_html |
1 |
mkdir -p jameshacker.me/public_html |
Changing Permission our Web directories
1 |
chmod -R 755 ctfplayer.com/ |
1 |
chown -R www-data:www-data ctfplayer.com/ |
1 |
chmod -R 755 jameshacker.me/ |
1 |
chown -R www-data:www-data jameshacker.me/ |
1 |
cd ctfplayer.com/public_html |
Creating an index.html for testing purpose
1 |
vi index.html |
1 2 3 4 5 6 7 |
<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
1 |
cp index.html /var/www/jameshacker.me/public_html/ |
1 |
cd /var/www/jameshacker.me/public_html |
1 |
ls |
Editing our second website default index.html file
1 |
vi index.html |
1 2 3 4 5 6 7 |
<html> <head> <center><h1>jameshacker.me</h1> <title> JamesHacker</title> <h3> This is our Second Website for demo </h3></center> </head> </html> |
creating a virtual-host our websites I am copy 000-default.conf file ctfplayer.com.conf and jameshacker.me.conf
1 |
cd /etc/apache2/sites-available/ |
1 |
cp 000-default.conf ctfplayer.com.conf |
1 |
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
1 |
vi ctfplayer.com.conf |
1 2 3 4 5 6 7 |
ServerName ctfplayer.com ServerAlias www.ctfplayer.com ServerAdmin webmaster@ctfplayer.com DocumentRoot /var/www/ctfplayer.com/public_html |
Editing our second virtual-host file jameshacker.me.conf
1 |
vi jameshacker.me.conf |
1 2 3 4 5 6 7 |
ServerName jameshacker.me ServerAlias www.jameshacker.me ServerAdmin webmaster@jameshacker.me DocumentRoot /var/www/jameshacker.me/public_html |
enable our virtual-host configuration file
1 |
sudo a2ensite ctfplayer.com.conf |
1 |
sudo a2ensite jameshacker.me.conf |
now disable our default apache server configuration file 000-default.conf remember after disabling apache2 default configuration file default host is not working
1 |
sudo a2dissite 000-default.conf |
after creating and enable our virutal-host we need to restart our apache2 server
1 |
service apach2 restart |
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
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
Add A record (associates a name with an IP address) server address and click save button to save our records file
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
jameshacker.me Checking our Second Website in the web browser and again we see our default index.html file
Joomla setup apache server read here