Home  >  Article  >  Backend Development  >  php sets Apache virtual host vhost

php sets Apache virtual host vhost

WBOY
WBOYOriginal
2016-07-30 13:30:101466browse

This article address: http://blog.csdn.net/oneym/article/details/48050487
Author: oneym

1. Environment description

1. Use PHP environment and use XAMPP
2. win7_64-bit system
3. XAMPP is installed in the root directory of drive C

2. Modify related files

1. Register the host header in the system

Use a text editing tool to edit the C:WindowsSystem32driversetchosts file and add a line of records in the file as follows:
127.0.0.1 php sets Apache virtual host vhost

2. Enable Apache’s vhost function

Locate the C:xamppapacheconfhttpd.conf file to start editing, use the editor’s search function ctrl+FSearch for mod_vhost_alias.so ;After finding the corresponding code, remove the # sign in front of the code. After editing, it will look as follows:
LoadModule vhost_alias_module modules/mod_vhost_alias.so

3. Configure Apache’s vhost function

Edit C:xamppapacheconfextrahttpd-vhosts.conf file, add the following code at the end of the file:

<virtualhost> <br> DocumentRoot "C:/xampp/htdocs/php" <br> ServerName php sets Apache virtual host vhost <br> ErrorLog "logs/php sets Apache virtual host vhost-error.log" <br> CustomLog "logs/php sets Apache virtual host vhost-access.log" common <br> </virtualhost>

4. Restart the Apache server

Use the control panel to quickly restart the Apache server. The screenshot is as follows:
XAMPP Control Panel

2. Test

As shown in the figure below, you can directly use the browser we defined The host head comes to access the project, so that our development can be moved closer to the production environment.
php sets Apache virtual host vhost

Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces how to set up the Apache virtual host vhost in PHP, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn