Good time of day!
I successfully used apache + php on windows 7, but now I desided to make a couple of virtual hosts. I added to the end of apache config such section:
<virtualhost>
ServerAdmin yourmail@domain.com
ServerName jiifirst
DocumentRoot "c :/ apache2/web/jiifirst/htdocs"
ScriptAlias / cgi-bin / "c :/ apache2/web/jiifirst/cgi-bin /"
ErrorLog c :/ apache2 / web / jiifirst / logs / error.log
CustomLog c :/ apache2/web/jiifirst/logs/access.log common
</ virtualhost>
Then created the appropriate folders. However when I try to call http://127.0.0.2/test.php
such error appears:
error Forbidden
You don’t have permission to access / test.php on this server.
At the same time I can still access localhost without problems. I have also changed rights to the folders. What apache settings should I change to fix this problem?
Firstly, what’s with all the spaces in the configuration? E.g.
"c :/ apache2/web/jiifirst/htdocs". That’s not your real config; how did you cut and paste this?Secondly, you’re talking to the server as
http://127.0.0.2. Yes, that is the server’s IP address, but in HTTP (at least 1.1 and later), an address means more than just identifying a network card on a machine. It identifies a web site domain. The address goes into the protocol, and the web server can decide which web site to provide to the client (at the same IP address).Your
VirtualHostdefines a web site whose domain name isjiifirst. This does not match the IP-based access127.0.0.2.However, can still match the
VirtualHostanyway. YourVirtualHostis missing the address and port match fields, but if it looks something like this:it means that it’s possible for the
VirtualHostto match an IP based request from any address to port 80. If Apache cannot find an exact match for the host name among any of theVirtualHostentries, (and you have no special default VirtualHost), it will choose the first one in order of appearance that has a match on the address.The lack of an address on
<VirtualHost>may be the reason why things are not happening (and possibly the spaces, if they are indeed real).