The instructions below show how to create virtual hosts in Centos 7. In this case the virtual hosts will be running from a custom location in the system and not from directories created in the /home directory.
Edit/Create your Virtual Host file
Create/edit the following file by entering the following line. This will tell httpd to read the configuration for the actual virtual hosts, provided of course that the main httpd.conf file is instructed (usually by default) to read the files in ‘conf.d/*.conf’ directory.
vim /etc/httpd/conf.d/vhosts.conf IncludeOptional vhosts.d/*.conf
Create the directory where the config files for the Virtual Hosts will reside.
Create the config file for your first Virtual Host.
Include the following lines in the config file.
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org DocumentRoot /repo/Centos06/centos/ ServerName rpmsrepo.sfentona.lol ServerAlias www.rpmsrepo.sfentona.lol <Directory "/repo/Centos06/centos/"> DirectoryIndex index.html index.php Options FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> Create the directories where your virtual hosts will be running frommkdir /repo/Centos06/centos/ chown -R apache:apache /repo/Centos06/centos/ chmod 755 /repo/Centos06/centos/
Check your httpd configuration and start httpdapachectl configtest systemctl restart httpd systemctl status httpd