Reputation: 1
Hoping to get some guidance with a move from a single apache/website per machine to a multiple virtual host setup per machine.
Current setup: LAMP stack with software packages installed from source code: Apache 2.4.2, php 5.4.3 and mysql 5.1.63 For the current single site (site1.ie) setup I have the virtualhost details, DocumentRoot and Directory directive pointing to site1 documentroot for the current site in the httpd.conf.
To enable virtual hosts I have uncommented the Include conf/extra/httpd-vhosts.conf and I have moved the virtualhost site config details into the httpd-vhosts.conf. Something like this:
<VirtualHost _default_:443>
ServerName http://site1.ie
DocumentRoot "/usr/local/apache2/htdocs/site1"
ServerAlias site1.ie
</VirtualHost>
When I uncomment the DocumentRoot details in the httpd.conf file and restart httpd I get a 403 forbidden error when I try to load site1.ie.
Directory directive in the httpd-vhosts.conf (moved from httpd.conf):
<Directory "/usr/local/apache2/htdocs/site1">
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Require all granted
</Directory>
EDIT:
The error_log in httpd gave this error: AH01630: client denied by server configuration: /usr/local/apache2/htdocs/
This is the location of the website data is it controlled by this Directory directive:
<Directory />
AllowOverride none
Require all denied
</Directory>
As far as I know this is the default to deny access to this folder but allow access to its subfolders through Directory directives of their own?
The point at which the 403 issue occurs is when I comment out the DocumentRoot in the main httpd.conf file and define the DocumentRoot inside the virtualhost directive (either in the httpd.conf file or the httpd-vhosts.conf file).
I temporarily changed the Directory / directive (shown above) to Require all granted and this got rid of the 403 error but all I was presneted with is the default apache 'It works' page. I still was unable to access the defined documentroot directory for site1.
Would anyone have any pointers on what I am doing wrong?
Upvotes: 0
Views: 1077
Reputation: 1127
I believe your tags need to be inside the vhosts file inside the tags in order for it to work, since you've enabled virtual hosting inside your httpd.conf file, such as:
<VirtualHost *:443>
ServerName site1.ie
ServerAlias site1.ie
DocumentRoot "/usr/local/apache2/htdocs/site1"
<Directory "/usr/local/apache2/htdocs/site1">
Options Indexes FollowSymLinks
AllowOverride AuthConfig
Require all granted
</Directory>
</VirtualHost>
Also consider adding variables to httpd.conf so you can adjust in one location, like so:
Define INSTALL_DIR d:/wamp64
Define SRVRPATH ${INSTALL_DIR}/usr/local/apache2/htdocs
Which will allow you to change the first code block above from
DocumentRoot "/usr/local/apache2/htdocs/site1"
<Directory "/usr/local/apache2/htdocs/site1">
To
DocumentRoot "${SRVRPATH}/site1"
<Directory "${SRVRPATH}/site1">
Upvotes: 0