Everything is not easy to understand, and you must be blind in case of any problems-configuration memorandum for Apache server development in PHP

Source: Internet
Author: User
: This article mainly introduces the configuration memorandum for Apache server development in PHP. if you are interested in the PHP Tutorial, you can refer to it. The configuration process is always smooth and secure.

Yesterday, I got a PHP applet and wanted to run the test locally. However, my work computer didn't have an environment to install. so I downloaded a wamp and it went all the way. Apache, Mysql, and PHP were all there. Start the wamp service and enter "http: // localhost" in the browser. the access is normal and the wamp homepage is displayed. As a result, I want to configure my CrashServer website to Apache. I can use a virtual domain name to access and test it locally. as a result, I encountered many problems. today I am using Google to study it, and I am finally able to use it.

1. First, the configuration file of Apache is httpd. conf and httpd-vhosts.conf. let's take a look at the default configuration of httpd. conf after wamp is installed.

DocumentRoot "d:/wamp/www/"
     AllowOverride none    Require all denied
 
      Options Indexes FollowSymLinks    AllowOverride all    Require local
 

# Virtual hosts
# Include conf/extra/httpd-vhosts.conf

 

To access a website through a virtual domain name, you need to configure the httpd-vhosts.conf. So you need to start the httpd-vhosts.conf, because the default is closed, so the configuration file # Include conf/extra/httpd-vhosts.conf before # Remove. So the httpd-vhosts.conf is enabled, so let's edit the httpd-vhosts.conf file.

2, the location of the httpd-vhosts.conf file, conf/extra under the apache Directory, the above Include conf/extra/httpd-vhosts.conf has actually told you its location.

In this file, add and configure my CrashServer website:

NameVirtualHost *:80
 
      DocumentRoot "D:/wamp/www/CrashServer"    ServerName crash.com
 

First, my CrashServer is placed under wamp/www, which is the default website directory of wamp. second, I want to access CrashServer through crash.com during local testing, the configuration is as follows.

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

After the configuration is complete, restart Apache and enter crash.com for access. the access result is normal. However, when accessing with localhost, the original web page appears, but now it shows CrashServer, so it also needs to append 127.0.0.1 localhost in hosts, in the httpd-vhosts.conf, append the localhost site configuration, which now looks like this:

NameVirtualHost *:80
 
      DocumentRoot "D:/wamp/www"    ServerName localhost
 
 
      DocumentRoot "D:/wamp/www/CrashServer"    ServerName crash.com
 

OK. Now the website is configured and looks very simple. However, this is not the case for me. I encountered the following problems yesterday.

First, my CrashServer was not originally placed under wamp/www, but under E: \ 360Downloads, so the following configuration is available:

 
      DocumentRoot "E:/360Downloads/CrashServer"    ServerName crash.com
 

That's right. the paths are correct, and the virtual domain name is also correct. However, the system prompts 403 Forbidden during access, and the system does not have the permission. So Google, Oh, I knew that I had to add permissions to the CrashServer directory, so I modified the configuration as follows:

 
      DocumentRoot "E:/360Downloads/CrashServer"    ServerName crash.com    
  
           Order Allow,Deny        Allow from All        Require all granted    
  
 

Restart Apache and access is normal. First, the newly added Directory can be found in httpd. conf added, can also be added in the httpd-vhosts.conf, I think it is better to add in the latter, the configuration content is more clear, the project directory permissions with the project site configuration. In the newly added Directory, we added permissions to the CrashServer Directory under 360Downloads to allow access, so we will no longer prompt 403 Forbidden.

This problem is so simple and easy to write, but it can be confusing and depressing when the problem occurs. For projects outside wamp/www, you must grant the project directory permission. note:

Order Allow,DenyAllow from AllRequire all granted

These three items are indispensable. this is configured to allow external computers to access the server site.

3. after the problem is solved today, I want to access my site through other devices in the same LAN. so I used my mobile phone and entered the ip address of my computer in my browser, so I couldn't access it. I went to Google again, it needs to be modified in httpd. configuration in conf:

 
      Options Indexes FollowSymLinks    AllowOverride all    Require local
 

Here, Require local is not displayed on Google, but the name indicates that only local access is allowed. Therefore, it is changed to Require all granted to allow access by all requests, and the mobile phone can be accessed.

For more information, see http://roteg.iteye.com/blog/1465380.

Here is a configuration blog written by a foreigner. it is very good. in the "7" period, add permissions to the project directory:

 
      Order Deny,Allow       Allow from all 
 

The Require all granted is missing, which leads to 403 Forbidden at last, which makes me very depressed.

This configuration is performed in the following wamp environment:

So far, all PHP site configuration under Apache has been completed.

The above section introduces the configuration memorandum for Apache server development in PHP, which includes some content and is helpful to PHP tutorials.

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.