PHP Development Apache Server Configuration _php Instance

Source: Internet
Author: User

According to this configuration process, absolutely unimpeded, can guarantee no risk.

Yesterday got a PHP applet, want to run a local test, but the work of the computer does not install the environment, so downloaded a wamp, all the way, Apache, Mysql, PHP is all there. Start Wamp Service, enter "http://localhost" in the browser, visit normal, jump out of Wamp homepage. So, the following want to put their own Crashserver Web site configuration to Apache, through the virtual domain name in the local access test, the results encountered a lot of problems, today a Google research, and finally the governor of the two veins full pass.

1, first of all, Apache configuration files are httpd.conf and httpd-vhosts.conf, we first look at the Wamp installed after the httpd.conf of the default configuration.

DocumentRoot "d:/wamp/www/"

<directory/>
  allowoverride None
  Require all denied
</ directory>

<directory "d:/wamp/www/" >
  Options Indexes followsymlinks
  allowoverride All Require local
</Directory>
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

To access a Web site through a virtual domain name, you need to configure httpd-vhosts.conf. Then you need to start httpd-vhosts.conf because the default is off, so remove the # #include conf/extra/httpd-vhosts.conf in the configuration file. So httpd-vhosts.conf enabled, so we went to edit httpd-vhosts.conf this file.

2, httpd-vhosts.conf file location, in the Apache directory of the Conf/extra, the above include conf/extra/httpd-vhosts.conf has actually told you its location.

In this file, add the Crashserver Web site to configure me above:

Namevirtualhost *:80

<virtualhost *:80>
  documentroot "D:/wamp/www/crashserver"
  ServerName Crash.com
</VirtualHost>

First of all, my crashserver is placed under the wamp/www, this is the Wamp default site directory, secondly, I want to test in the local time, with crash.com can access to crashserver, so configure as above.

Here, in order to allow us to access the local site through crash.com, we need to modify the Hosts file, add 127.0.0.1 crash.com.

Here, configuration finished, so restart Apache, enter crash.com access, the results of normal access. However, when the localhost visit, the original appears is Wamp's homepage, but now show crashserver, so also in the hosts to add 127.0.0.1 localhost, In httpd-vhosts.conf, appending the localhost site configuration, now looks like this:

Namevirtualhost *:80

<virtualhost *:80>
  documentroot "d:/wamp/www" ServerName localhost
< /virtualhost>

<virtualhost *:80>
  documentroot "D:/wamp/www/crashserver" ServerName crash.com
</VirtualHost>

OK, the basic can be finished, the site is configured well, looks very very simple. But for me it is not so, I encountered the following problems yesterday.

First of all, my crashserver was not placed under the wamp/www, but under the E:\360Downloads, so I have the following configuration:

<virtualhost *:80>
  documentroot "E:/360downloads/crashserver"
  ServerName crash.com
Virtualhost>

This is right, the path is right, the virtual domain name is also true, but when visiting, but prompts 403 forbidden, does not have the authority. So Google, oh, know the original is to give the Crashserver directory plus permissions, so modify the configuration as follows:

<virtualhost *:80>
  documentroot "E:/360downloads/crashserver"
  ServerName crash.com

  < Directory e:/360downloads/crashserver> order
    Allow,deny
    Allow to all
    Require all granted
  </ Directory>
</VirtualHost>

Restart Apache, access is normal. First, the new directory can be added in httpd.conf or added in httpd-vhosts.conf, which I think adds better in the latter, the configuration content is clearer, and the project directory permissions follow the project site configuration. In the new directory above, we gave the Crashserver directory under 360Downloads permissions, allowing access, so no longer prompted 403 forbidden.

This question, now write is so simple and easy, but when the problem arises, it is very annoying and depressing. For items outside of wamp/www, you need to give the project directory permissions, and note:

Order Allow,deny
Allow from all
Require all granted

These three indispensable, this is configured to allow the external computer access to the server site.

3, the problem solved today, think through the same LAN under the other equipment to visit my site, so with the mobile phone, in the browser to enter My computer IP, can not access, again Google, the original need to modify the configuration in httpd.conf:

<directory "d:/wamp/www/" >
  Options Indexes followsymlinks
  allowoverride all
  Require
Local </Directory>

Among them, Require Local, did not Google out, but see the name knows, is only allowed to visit locally, so changed to Require all granted, allow all requests to access, the mobile phone can be accessed.

Reference, http://roteg.iteye.com/blog/1465380, here is an explanation of the access verification configuration.

Here, there is a foreigner wrote the configuration Bowen, very good, https://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp, but only a little, In his step 7, add permissions to the project directory:

<directory c:/users/kristen/documents/projects> order
  Deny,allow  
  Allow to all 
</directory >

But just less require all granted, cause finally or 403 forbidden, make me very depressed.

---------------------------------------------------------------------------------Supplement 2015-07-13----------------- --------------------------------------------------------------------------------

Thanks to the commentary's only commentator's reminder: Require All granted this is required on top 2.4, 2.2 not required.

This makes sense of why Google comes out of technical articles, some of which refer to require all granted, while others do not.

---------------------------------------------------------------------------------End Supplemental 2015-07-13-------------- ------------------------------------------------------------------------------

This configuration is done in the following WAMP environment:

At this point, under Apache configuration PHP site, complete.

The above mentioned is the entire content of this article, I hope you can enjoy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.