Configure virtual hosts for mydomainname.com
#cd /var/www #mkdir -p /var/www/mydomainname.com #chmod -R 755 /var/www/mydomainname.com #chown -R www-data:www-data /var/www/mydomainname.com #mkdir -p /var/log/apache2/mydomainname.com #cd /etc/apache2/sites-available/ #cp 000-default.conf mydomainname.com.conf
#vim mydomainname.com.conf
Insert code below
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName mydomainname.com ServerAlias www.mydomainname.com mydomainname.com DocumentRoot /var/www/mydomainname.com <Directory /var/www/mydomainname.com> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/mydomainname.com/error.log CustomLog ${APACHE_LOG_DIR}/mydomainname.com/access.log combined </VirtualHost>
Activate
#a2ensite mydomainname.com.conf Enabling site mydomainname.com. To activate the new configuration, you need to run: systemctl reload apache2 # systemctl reload apache2
Check
#ls -la /etc/apache2/sites-enabled/ total 8 drwxr-xr-x 2 root root 4096 May 31 18:35 . drwxr-xr-x 9 root root 4096 Apr 10 15:07 .. lrwxrwxrwx 1 root root 35 Apr 10 13:23 000-default.conf -> ../sites-available/000-default.conf lrwxrwxrwx 1 root root 54 May 31 18:30 mydomainname.com.conf -> /etc/apache2/sites-available/mydomainname.com.conf
To add more virtual hosts for another domain please follow the step above