Hi guys (like a youtuber 😀 ),

If you have an experience about hosting, you know hosting panels like Plesk, cPanel. We often use these panels but this method can leave us ignorant. Upss, why?

When we use panels, we use just buttons for running, editing, removing etc. so we do not know the commands running behind. I am always wondering about the commands that running behind, if you’re wondering like me, join me 🙂

Result of wondering, I have a lot of virtual machines on my machine and a droplet on DigitalOcean, for test. In this scenario, we want to host multi site on a server (DigitalOcean Droplet). You will see, it’s too simple. At the end, you know how panels works for this event.

Ok, let’s start.

1. Set the DNS Zones,

DigitalOcean home page -> Networking -> Domains -> Add a Domain

Add domains that you want to host on the droplet.

My droplet name is “MyPersonalServer”

More -> Manage Domain

These settings are for web hosting, not for mx etc.

You must do this step(Manage Domian) for every domain.

2. Create web directory for every domain ,

You can use “/var/www” directory or any directory.

For example, you can create a directory in /home/ directory for every domain (domainname.ext). Like below,

  • /home/unalfaruk.com
  • /home/keep2ez.com
  • /home/testdomain.com
  • /home/anotherdomain.com

3. Configure Apache,

Now, we must tell our purpose to Apache.

Me: Hey Apache, I have a few domain and I want to host these sites on this server.

Apache: Ok bro, you can tell your domains to me.


cd /etc/apache2/sites-available/

touch domainame.ext.conf

ls

Your directory must  include conf files like this.

Edit every conf files like below,

<VirtualHost *:80>
DocumentRoot “/home/domainname.ext
ServerName domainname.ext
ServerAlias www.domainname.ext

# Other directives here, e.g. :

<Directory /home/domainname.ext/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

</Directory>
ErrorLog /var/log/apache2/domainname.ext-error_log
CustomLog /var/log/apache2/domainname.ext-access_log common
</VirtualHost>

And run the commands for every conf files,


ln -s /etc/apache2/sitesi-available/domainname.ext.conf /etc/apache2/sitesi-enabled/domainname.ext.conf

a2ensite domainname.ext.conf

Final step, restart Apache service,


sudo service apache2 restart

Result:

They are in the same server.