PHP Intermediate article Apache configuration httpd-vhosts Virtual Host summary and considerations [OK]

Source: Internet
Author: User
Tags php development environment 403 forbidden error

Often use Apache virtual host for development and testing, but every time you need to configure the virtual host is the habitual CTRL + C and CTRL + V, this time because of the reload system, you need to configure a new PHP development environment Virtual host, So summarize the APACEH configuration httpd-vhosts virtual Host use methods and procedures, easy to find and use.

Development environment: WAMP
Website: http://www.wampserver.com/en/

Instance one, Apaceh configuring the localhost virtual host step
1, open the Apache directory with Notepad httpd.conf file (e.g. D:\wamp\bin\apache\apache2.2.8\httpd.conf), find the following module

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

Remove the previous # so that the Httpd-vhosts virtual host file is turned on. This time restart Wamp environment, unable to open localhost, need to be configured in httpd-vhosts.conf.

2, open the Httpd-vhosts file with Notepad, configure the localhost virtual host, Refer to the example in the Httpd-vhosts file, modified as follows:

    1. serveradmin [email protected]
    2. documentroot  "D:\wamp\www"
    3. servername  localhost
    4. customlog" Logs/dummy-host.localhost-access.log "Common
    5. </VIRTUALHOST>

Modify the configuration as follows:
DocumentRoot modified to the WWW directory under the local WAMP environment (e.g., D:\wamp\www)
ServerName Change to localhost

3, restart Apache, found that localhost can open normally, configure localhost is relatively simple.

Example two, APACEH configuring test.biuuu.com virtual Host Steps

1, the same way, the replication configuration code is modified as follows:

    1. <virtualhost *:80>
    2. ServerAdmin [email protected]
    3. DocumentRoot E:\WebRoot\biuuu
    4. ServerName test.biuuu.com
    5. Errorlog "Logs/dummy-host2.localhost-error.log"
    6. Customlog "Logs/dummy-host2.localhost-access.log" common
    7. </VirtualHost>

2. Open the Host file (C:\WINDOWS\system32\drivers\etc\hosts) and add a line of code

    1. 127.0.0.1 test.biuuu.com

3, open test.biuuu.com in the browser, found the following error 403 Forbidden Error
Forbidden you do have permission to access/on the this server.

Analysis: This is mainly the directory access permissions are not set, you need to set access to the directory!

4, open the httpd file and locate the following statement

    1. <directory/>
    2. Options FollowSymLinks
    3. AllowOverride None
    4. Order Deny,allow
    5. Deny from all
    6. </Directory>

Copy the above code, and make the directory modification, put/replace with E:\WebRoot\biuuu, modify the VirtualHost code as follows

  1. <virtualhost *:80>
  2. ServerAdmin [email protected]
  3. DocumentRoot E:\WebRoot\biuuu
  4. ServerName test.biuuu.com
  5. Errorlog "Logs/dummy-host2.localhost-error.log"
  6. Customlog "Logs/dummy-host2.localhost-access.log" common
  7. <directory E:\WebRoot\biuuu>
  8. Options FollowSymLinks
  9. AllowOverride None
  10. Order Deny,allow
  11. Deny from all
  12. </Directory>
  13. </VirtualHost>

Test found in the browser or not open, prompted as above 403 Forbidden error, modify the deny from all to allow from all

5, restart Apache, virtual host configuration success!

Precautions
1, directory path, such as E:\WebRoot\biuuu
2, access rights, such as upper deny from all modified to allow from all
3,host file, configure the virtual domain host to point to
4,HTTPD file, open the Include conf/extra/httpd-vhosts.conf module
5,httpd-vhosts files, configuring virtual hosts

6, There may also be a Linux SELinux firewall that causes this, remember

Configuring Httpd-vhosts Virtual Host with APACEH is simple for developers, but very important, for reference only!

Resources:

http://httpd.apache.org/docs/2.2/vhosts/

Http://httpd.apache.org/docs/2.0/vhosts/examples.html

Original articles such as reproduced, please specify: reprinted from the http://www.biuuu.com/blog

Gu Banxin Note: If fatal error:allowed memory size of 8388608 bytes exhausted error occurs

Modify php.ini Settings Memory_limit = 12M (default 8M)

Or just need to add in your program header: Ini_set ("Memory_limit", "12M");

PHP Intermediate article Apache configuration httpd-vhosts Virtual Host summary and considerations [OK]

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.