Update system
apt -y update && upgrade
Install apache and php
apt install apache2 php7.2 php7.2-common
Backup configuration
mkdir /root/backup
cp -r /etc/apache2 /root/backup/
cp -r /etc/php /root/backup/
Start Apache daemon
systemctl start apache2
systemctl enable apache2
Create directory for each host
mkdir /var/www/host1.darin.web.id
mkdir /var/www/host2.darin.web.id
chown -R www-data:www-data /var/www/host1.darin.web.id/
chown -R www-data:www-data /var/www/host2.darin.web.id/
chmod 755 /var/www/*
Create index file for each host
cat >> /var/www/host1.darin.web.id/index.php
<?php phpinfo();?>
ctrl + c
cat >> /var/www/host2.darin.web.id/index.php
<?php phpinfo();?>
ctrl + c
Configure VirtualHost
cd /etc/apache2/sites-available
cp 000-default.conf host1.darin.web.id.conf
cp 000-default.conf host2.darin.web.id.conf
vim host1.darin.web.id.conf
<VirtualHost *:80>
ServerAdmin postmaster@darin.web.id
ServerName host1.darin.web.id
DocumentRoot /var/www/host1.darin.web.id
DirectoryIndex index.php
ErrorLog /var/log/apache2/host1.darin.web.id_error.log
CustomLog /var/log/apache2/host1.darin.web.id_access.log combined
</VirtualHost>
vim host2.darin.web.id.conf
<VirtualHost *:80>
ServerAdmin postmaster@darin.web.id
ServerName host2.darin.web.id
DocumentRoot /var/www/host2.darin.web.id
DirectoryIndex index.php
ErrorLog /var/log/apache2/host2.darin.web.id_error.log
CustomLog /var/log/apache2/host2.darin.web.id_access.log combined
</VirtualHost>
Enable VirtualHost
a2ensite host1.darin.web.id.conf
a2ensite host2.darin.web.id.conf
Enable mod_rewrite
a2enmod rewrite
Restart Apache daemon
apache2 -t
systemctl restart apache2
systemctl enable apache2
Additional notes
If there is any error like variable ${APACHE_x_x} is not defined
Just run command source /etc/apache2/envvars
Click here for the details.