How to host Multiple domains/Websites on Apache Without Control panel

So you have got a dedicated server or VPS and want to host more than one website /domain on Apache web server but also don’t want to spend money on control panel like cPanel , Directadmin etc.. I will show you how to seriously host multiple websites or domains on your LAMP stack easily without any control panel! in this small tutorial I have Apache with Mysql , PHP on Ubuntu.

then lets SSH to server first, I’m connecting from my Ubuntu desktop, if you are on windows then look at putty a cool ssh client for windows computers

ssh root@xx.xxx.xx

in this example we are going to host the domain name “www.example.com”.
now that you are logged in to server, lets change dir

cd /etc/apache2/sites-available

let’s create a configuration file for www.example.com
NOTE: I will be using “vi” its a text editor that comes with Ubuntu and you can use it in any ssh session, if you don’t like it then install yum or just sftp to server and work with a GUI

vi www.example.com

Now that vi has create the virtual host file , lets copy and paste the following inside that file
TIP to paste the following in the file we created/opened in the step above, press i then mouse right click

<VirtualHost *:80>
        ServerAdmin name@example.com
        ServerName  example.com
        ServerAlias www.example.com
        # Indexes + Directory Root.
        DirectoryIndex index.html
        DocumentRoot /var/www/example.com
</VirtualHost>

Now lets save that file, press Esc 2 times then type:

:wq

Now we have to enable www.example.com on the server, to do that issue:

a2ensite www.example.com

Great! Now you only need to go to /var/www to create a home directory for example.com, remember in the steps above we created a configuration file that has a virtual host for example.com? in that file we also added something like DocumentRoot ?
thats where the domain home directory will be so lets create it.

cd /var/www
sudo mkdir example.com

Lets reload apache

service apache2 reload

Now remain to add an A record to example.com wherever you have it registered, here is a guide on how to do that on Godaddy

That is it! just upload the website files to /var/www/example.com and you will be able to access them by visiting wwww.example.com

Post comment as twitter logo facebook logo
Sort: Newest | Oldest