i wonder how apache httpd vhost work. i use wampserver for web development, everything work well but one day, the httpd vhost seems not working for unknown reason. i was working some rewrite rule but wonder why anything i wrote doesn’t work even after i restart all thing (wamp,pc,server) and any rule worked previously also stop working. The http-vhosts.conf is as follow:
<VirtualHost 127.0.0.1:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "c:/wamp64/www"
<Directory "c:/wamp64/www/">
Options -Indexes +Includes -FollowSymLinks -MultiViews
AllowOverride None
Require all denied
</Directory>
</VirtualHost>
To test it, i set it “Require all denied” and go to my localhost:8080 but still i can access my site instead of the 403 forbidden. I also tried add and remove Options like the Indexes and nothing work.
As i keep testing, restarting wampserver, by random chance it will work with my setting “Require all denied” showing 403 forbidden on localhost, however, once i restart my setting is not followed. wampserver come in all in one package (apache, mysql, php), im not sure if i miss anything about how apache work.
im using windows 10,
wampserver, apache version 2.4
the “Include conf/extra/httpd-vhosts.conf” in httpd.conf is uncommented.
previosuly added a new vhost on same port (but then deleted), not sure if that cause the problem. please help
2
Answers
Looks like you have been messing about with the
httpd-vhosts.conf
file and made a bit of a mess.Here is what it should look like out of the box (WAMPServer V3)
By setting
Require all denied
nothing should get to that domain, as this tells Apache to deny access from everywhere. If it does not deny access, maybe you also messed up thehttpd.conf
file.Setting
AllowOverride None
amoung other things tells Apache DO NOT LOOK AT A.htaccess
EVEN IF IT EXISTS.This is an old question, but as I just ran into the same issue, I thought I would help out by adding a response.
Something Windows users have trouble with is file permissions and ownership. Just because you have a server (or laptop or PC that you use to run Apache) on which you are the only user, that doesn’t mean that everything runs as your user. In fact, Apache runs as a system process. So, if you created your path, c:/wamp64/www in the original post, as your user, you will have to make sure the system process that runs Apache can read that directory. I don’t have Apache installed on a Windows PC here – in fact, I don’t think I have any Windows PCs outside of the government laptop I use for work – but you would need to go to services, find the Apache Web Service, find out what user runs it, and then go to your path, again using c:/wamp64/www as an example, and right clicking on the www directory folder, choosing ‘Properties’ from the context menu, Going to the Security tab and checking to see if the Apache service user is listed. If so, check the Permissions tab. Don’t be afraid to check the Advanced button and look at the permissions there as well. Your apache user should have read and execute permissions to allow the webserver to go up and down the chain of directories. On Linux, you would either chown the whole tree to the apache daemon Run-as user, or change the group attribute to the daemon’s group and then change the permissions to allow the group user to read and execute files there.You could leave the ownership alone, but I have found that often creates more problems. Basically, chmod -R 755 my/htdocs/root and (chown -R myuser:daemongroup my/htdocs/root or chown -R daemonuser:daemongroup my/htdocs/root) will work.