According to this configuration process, absolutely all the way unimpeded, can be guaranteed without danger.
Yesterday to get a PHP applet, want to run a test in the local, but the work of the computer does not install the environment, so downloaded a wamp, all the way, Apache, Mysql, PHP all have. Start Wamp Service, enter "http://localhost" in the browser, Access normal, jump out of Wamp home. So, the following want to put their own crashserver site in Apache, can be accessed through the virtual domain in the local test, the results encountered a lot of problems, today, a Google research, finally let the two-pulse all-pass.
1, first, the Apache configuration file is httpd.conf and httpd-vhosts.conf, we first look at the Wamp installed, httpd.conf the default configuration.
?
1234567891011121314 |
documentroot " d:/wamp/www/" <directory/> &NBSP, allowoverride none &NBSP;&NBSP; Code class= "Plain Plain" >require all denied </DIRECTORY> <directory "d:/wamp/www/", &NBSP;&NBSP; options Indexes followsymlinks &NBSP;&NBSP; allowoverride all &NBSP;&NBSP; Require local </DIRECTORY> # Virtual hosts #Include conf/extra/httpd-vhosts.conf |
To access the site through a virtual domain, you need to configure httpd-vhosts.conf. Then you need to start httpd-vhosts.conf, because the default is closed, so the configuration file # # # # conf/extra/httpd-vhosts.conf before the # removed. So httpd-vhosts.conf enabled, then we go to edit httpd-vhosts.conf this file.
2, httpd-vhosts.conf file location, in the Apache directory of Conf/extra, the above include conf/extra/httpd-vhosts.conf has actually told you its location.
In this file, add the Configure my Crashserver website above:
?
123456 |
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "D:/wamp/www/CrashServer" ServerName crash.com </VirtualHost> |
First of all, my crashserver is placed under the Wamp/www, which is wamp default site directory, second, I would like to test in the local time, with crash.com can access to Crashserver, so configured as above.
Here, in order for us to access the local site through crash.com, we need to modify the Hosts file and add 127.0.0.1 crash.com.
Here, the configuration is complete, so restart Apache, enter crash.com access, results normal access. However, when a visit to localhost, originally appeared Wamp's homepage, but now show crashserver, so also in the hosts to append 127.0.0.1 localhost, In httpd-vhosts.conf, append the site configuration on localhost, which now looks like this:
?
1234567891011 |
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "D:/wamp/www" ServerName localhost </VirtualHost> <VirtualHost *:80> DocumentRoot "D:/wamp/www/CrashServer" ServerName crash.com </VirtualHost> |
OK, to this basically can end, the site is configured, looks very very simple. But for me it is not so, I encountered the following problem yesterday.
First of all, my crashserver in the beginning is not placed under the wamp/www, but placed under the E:\360Downloads, so there is the following configuration:
?
1234 |
<VirtualHost *:80> DocumentRoot "E:/360Downloads/CrashServer" ServerName crash.com </VirtualHost> |
That's right, the path is right, the virtual domain name is also right, but when the visit, but prompted 403 Forbidden, no permissions. So Google, oh, know the original is to give the Crashserver directory plus permissions, and then modify the configuration as follows:
?
12345678910 |
<virtualhost *:80 &NBSP;&NBSP; documentroot "e:/ 360downloads/crashserver " &NBSP;&NBSP; ServerName crash.com &NBSP;&NBSP; < Directory e:/360downloads/crashserver> &NBSP;&NBSP;&NBSP;&NBSP; order allow,deny &NBSP;&NBSP;&NBSP;&NBSP; allow from all &NBSP;&NBSP;&NBSP;&NBSP; require all granted &NBSP;&NBSP; </DIRECTORY> </VIRTUALHOST> |
Reboot Apache, the access is OK. First of all, the new directory can be added in the httpd.conf, can also be added in the httpd-vhosts.conf, I think in the latter to add better, more clear configuration content, project directory permissions follow the project site configuration. In the new directory above, we gave the Crashserver directory under 360Downloads permission to allow access, so we no longer prompt 403 forbidden.
This question, now written is so simple and easy, but when the problem arises, it is very annoying and depressed. For projects outside the wamp/www, you need to give the project directory permission, note:
?
123 |
Order Allow,Deny Allow from All Require all granted |
These three articles are integral, which is configured to allow external computers to access the server site.
3, the problem solved today, think through the same LAN under the other devices to access my site, so with the phone, in the browser input My computer's IP, can not access, again Google, the original need to modify the configuration in the httpd.conf:
?
12345 |
<Directory "d:/wamp/www/"> Options Indexes FollowSymLinks AllowOverride all Require local </Directory> |
Among them, Require Local, no Google out, but to see the name know, is only allowed local access, and then changed to Require all granted, allowing all requests to access, the phone can be accessed.
For reference, http://roteg.iteye.com/blog/1465380, here is an explanation of the access authentication configuration.
Here, a foreigner wrote the configuration blog, very good, https://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp#wamp-step-7 , but only one point, in his step 7, add permissions to the project directory:
?
1234 |
<Directory C:/Users/Kristen/Documents/Projects> Order Deny,Allow Allow from all </Directory> |
But just less require all granted, resulting in the last or 403 Forbidden, make me very depressed.
---------------------------------------------------------------------------------Supplementary 2015-07-13----------------- --------------------------------------------------------------------------------
Thanks to the only reviewer in the comments: Require all granted this is 2.4 above, 2.2 is not required.
This can understand why Google came out of the technical articles, some mention require all granted, while others do not.
---------------------------------------------------------------------------------End Supplement 2015-07-13-------------- ------------------------------------------------------------------------------
This configuration is done in the following WAMP environments:
At this point, under Apache configuration PHP site, all completed.
PHP Development Apache Server Configuration