I have a Centos webserver set up with 2 websites. Initially it only had one website and virtualhost config was added to the end of the httpd.conf file. Not best practice I know however it worked fine and looks as follows.
ServerName www.example.com
ServerAlias example.com
#ServerAdmin admin@example.com
DocumentRoot /var/www/html/example/
ErrorLog /var/log/httpd/example_error.log
CustomLog /var/log/httpd/example_access.log combined
#loglevel warn
#Options Indexes FollowSymLinks
#AllowOverride None
#Require all granted
Options Indexes FollowSymLinks MultiViews
Allowoverride All
Order allow,deny
allow from all
A second development website was added which was a copy of the first one and the virtual host was created just below the first one in the httpd.conf file as follows:
ServerName dev.example.com
ServerAlias dev.example.com
DocumentRoot /var/www/dev.example.com/html
#ErrorLog /var/log/httpd/dev.example.com/error.log
#CustomLog /var/log/httpd/dev.example.com/requests.log combined
#Options Indexes FollowSymLinks
#AllowOverride None
#Require all granted
Options Indexes FollowSymLinks MultiViews
Allowoverride All
Order allow,deny
allow from all
The second virtual host config is definitely being read as it displays the dev website but the directory directives seem to be ignored.
I have also tried making the second directory path explicit i.e.
However it was ignored again.
Am I missing something in the set up of the second site that will allow the directory directive to be read?
Answer
Thanks to both above for their information. It threw me that one site was working and one wasn't when the config file wasn't set up right. I would have assumed both sites wouldn't work.
- Remove the directory directive from the virtualhost section.
Make the directory paths explicit i.e.
Leave allowoverride all in place.
- Restart the service.
Additionally while one website was working and the other wasn't it until both website directory directives were set with an explicit path that it started to work.
No comments:
Post a Comment