How to set up Apache with domain and sub domain:
As an example: your-domain.com, project1.your-domain.com
Step 1: Configure your domain
Go to Domain Management system and set A-records value with VPN IP
Step 2: Add New Projects
Open your ssh interface and connect to your VPN
add directories and HTML files
sudo mkdir -p /var/www/your-domain sudo mkdir -p /var/www/project1
sudo echo "test your-domain" > /var/www/your-domain/index.html sudo echo "test your-domain" > /var/www/project1/index.html
Step 2: Add Virtual Host to your Apache
Domain Configurations
Create new file /etc/apache2/sites-available/your-domain.conf
Add this to file /etc/apache2/sites-available/your-domain.conf
<VirtualHost *:80> ServerAdmin youradmin@your-domain.com ServerName your-domain.com ServerAlias www.your-domain.com DocumentRoot /var/www/your-domain ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory "/var/www/your-domain"> Options +Indexes +FollowSymLinks +MultiViews AllowOverride All Allow from All </Directory> </VirtualHost>
To enable your new virtual host configuration run this:
sudo a2ensite your-domain.conf
Restart Apache
sudo service apache2 restart
sudo echo "<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName webnetkit.com DocumentRoot /var/www/webnetkit ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>" > /etc/apache2/sites-available/webnetkit.conf