Apache Basic Vhost Configuration

Source: Internet
Author: User

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 file (e.g. D:\wamp\bin\apache\apache2.2.8\conf), find the following module
# Virtual Hosts
#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 Httpd-vhosts file in the example, modified as follows:
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "D:\wamp\www"
ServerName localhost
Serveralias localhost
Errorlog "Logs/dummy-host.localhost-error.log"
Customlog "Logs/dummy-host.localhost-access.log" common
</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:
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot E:\WebRoot\biuuu
ServerName test.biuuu.com
Errorlog "Logs/dummy-host2.localhost-error.log"
Customlog "Logs/dummy-host2.localhost-access.log" common
</VirtualHost>
2. Open the Host file (C:\WINDOWS\system32\drivers\etc\hosts) and add a line of code
127.0.0.1 test.biuuu.com
3, open test.biuuu.com in the browser, found the following error 403 Forbidden Error
Forbidden
You don't 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
<directory/>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Deny from all
</Directory>
Copy the above code, and make the directory modification, put/replace with E:\WebRoot\biuuu, modify the VirtualHost code as follows
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot E:\WebRoot\biuuu
ServerName test.biuuu.com
Errorlog "Logs/dummy-host2.localhost-error.log"
Customlog "Logs/dummy-host2.localhost-access.log" common
<directory e:\webroot\biuuu>
Options FollowSymLinks
AllowOverride None
Order Deny,allow
Deny from all
</Directory>
</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

Note: such as occurs fatal error:allowed memory size of 8388608 bytes exhausted error
Modify php.ini Settings Memory_limit = 12M (default 8M)
Or just need to add in your program header: Ini_set ("Memory_limit", "12M");

Apache Basic Vhost Configuration

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.