This document attempts to show you how to creating virtual host configurations on your Apache server.
It’s supposed that our web apps directory are placed to “/opt/web”
add a new directory named “default” in “/var/www/html” for Ip based request.
The Web applications directory structure are as follows:
/opt/web/com.example #for example.com and www.example.com /opt/web/com.example.home #for home.example.com /opt/web/org.example #for example.org and www.example.org
Then, create a sub-directory in each web application directory, to store pubic application or html files. If the application have security files, it is a good choice that stored them in the root directory.
/opt/web/com.example/www # For html /opt/web/com.example/files # For security path
Open the file “/etc/httpd/conf/httpd.conf”
$ sudo vim /etc/httpd/conf/httpd.conf
Listen for virtual host requests on all IP addresses
Then, add the following text to the end of this file:
Apache 2.4.3 added a new security feature that often results in this error. You would also see a log message of the form:
client denied by server configuration
The feature is requiring a user identity to access a directory. It is turned on by DEFAULT in the “httpd.conf” that ships with Apache:
Require all denied
This basically deny access to all users. To fix this problem, either remove the denied directive (or much better) add the following directive to the directories you want to grant access to:
Require all granted
<Directory "your directory here"> ...... # New directive needed in Apache 2.4.3: Require all granted ...... </Directory>
$sudo service httpd restart