Update system yum -y update && upgrade Install apache yum -y install httpd httpd-tools
Install php 5.4 yum -y install php php-common
or
Install php 7.2 yum -y install epel-release rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum -y install php72w php72w-common
Backup configuration mkdir /root/backup cp -r /etc/httpd /root/backup/
Start Apache daemon systemctl start httpd systemctl enable httpd
Create directory for each host mkdir /var/www/host1.darin.web.id mkdir /var/www/host2.darin.web.id chown -R apache:apache /var/www/host1.darin.web.id/ chown -R apache:apache /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/httpd/conf.d touch host1.darin.web.id.conf touch host2.darin.web.id.conf
vim host1.darin.web.id.conf
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName host1.darin.web.id
DocumentRoot /var/www/host1.darin.web.id
DirectoryIndex index.php
ErrorLog /var/log/httpd/host1.darin.web.id_error.log
CustomLog /var/log/httpd/host1.darin.web.id_access.log combined
</VirtualHost>
vim host2.darin.web.id.conf
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName host2.darin.web.id
DocumentRoot /var/www/host2.darin.web.id
DirectoryIndex index.php
ErrorLog /var/log/httpd/host2.darin.web.id_error.log
CustomLog /var/log/httpd/host2.darin.web.id_access.log combined
</VirtualHost>
Restart Apache daemon apachectl -t systemctl restart httpd systemctl enable httpd
Additional notes Apache VirtualHost examples Sites classification methods apachectl -S (debug apache configuration)