Running apps on subdomains with Apache is an affordable and efficient solution. By configuring virtual hosts, you can easily manage multiple subdomains, each running different apps. Here’s a quick guide to set it up:
1. Create Virtual Host Files
In the /etc/apache2/sites-available/
directory, you need to create a configuration file for each subdomain you want to run. For example:
todo.heybam.boo.conf
for thetodo.heybam.boo
subdomain
You can copy an existing default configuration or create a new one:
touch todo.heybam.boo.conf
2. Edit Virtual Host Files
For each of these configuration files, modify the ServerName
and DocumentRoot
directives to match your subdomains.
For heybam.boo.conf
, it might look like this:
<VirtualHost *:80>
ServerName todo.heybam.boo
DocumentRoot /var/www/todo/public
<Directory /var/www/heybam.boo>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
3. Enable the Sites and Obtain SSL Certificates
After configuring the virtual host files, enable them and get certs:
sudo a2ensite todo.heybam.boo.conf
sudo certbot --apache -d todo.heybam.boo -d www.todo.heybam.boo
4. Restart Apache
Finally, restart Apache to apply the changes:
sudo systemctl restart apache2
Conclusion
By following these steps, you can configure multiple subdomains to run different apps on your Apache server. Each subdomain will have its own document root and settings.
Leave a Reply