Apache Configure Domain

Kevin FOO
2 min readJun 5, 2020

--

In my previous story of Ubuntu installing Laravel, it ended with Apache listening to all IP addresses. Now I am going to configure it to listen to one subdomain only, this way one server can be shared by multiple subdomains.

I have a domain at Cloudflare, I am going to point it to the Laravel blog I setup earlier.

I had previously backup a copy of the 000-default.conf, rollback to the original with the commands below. I prefer to name my config file with the name of the subdomain for easy searching in future.

cd /etc/apache2/sites-available
sudo mv 000-default.conf laravel.oofnivek.com.conf
sudo mv 000-default.conf.bak 000-default.conf
sudo vim laravel.oofnivek.com.conf

Edit “ServerName” to the subdomain.

Lastly enable the site and restart Apache.

sudo a2ensite laravel.oofnivek.com
sudo systemctl restart apache2

Browse with subdomain, you’ll see something similar to the screenshot below.

Browse with IP address you’ll see the Apache Ubuntu default page.

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet