Use XAMPP to build a detailed procedure for running a PHP virtual host _php Instance

Source: Internet
Author: User

Recently, a new installation of xampp such a software to build their own web development environment, installed natural to virtual several directories put their own projects, how to build a Web server in the XAMPP environment to create a virtual host of the process of summary sharing, the general process is divided into three steps , as follows:
Step One: Open the C:/windows/system32/drivers/etc/hosts file in Notepad (Win7 Hosts file location:%systemroot%\system32\drivers\etc),
Under 127.0.0.1 localhost I added a 127.0.0.1 localhost.tuolarapp.com, so that every time in the browser to enter the localhost.tuolarapp.com, it will no longer to the network DNS solution Analysis, but directly resolve to the local. So in fact you can't visit localhost.tuolarapp.com, of course you can set yourself up as a sohu.com if you want.
Step two: because I xampp is installed in D disk: With Notepad to open the d:/xampp/apache/conf/httpd.conf file, I found include "conf/extra/httpd-vhosts.conf", Make sure there is no plus # in front.
Step Three: D:/xampp/apache/conf/extra/httpd-vhosts.conf, followed by the following code snippet:

<virtualhost 127.0.0.1:80>
documentroot "D:/tuolarapp"
ServerName "localhost.tuolarapp.com"
</VirtualHost>

Or the detailed points are as follows:

<virtualhost 127.0.0.1:80>
documentroot "D:/tuolarapp"
ServerName "localhost.tuolarapp.com"
<directory "D:/tuolarapp" >
Options Indexes followsymlinks
serveralias 1.com *.2.com ErrorLog logs/
Www.eachbrand.com-error_log
customlog logs/www.eachbrand.com-access_log Common
allowoverride
all Order Allow,deny
allow from all
</Directory>
</VirtualHost>

Then save and restart Apache so that when I enter localhost.tuolarapp.com in the browser, it will automatically parse to the site in the D:/tuolarapp directory. This input is much more convenient, and the key ego will feel better.

The above configuration elements are described as follows:
<virtualhost localhost:80>:localhost for the site domain name, 80 port can not write, if you change to another port you need to write, but also to modify the httpd.conf in the listener port number: Listen 80
ServerName: website domain name, ditto, must fill in;
DocumentRoot: The website program main directory, must fill in;
Options Indexes followsymlinks: Display directory listings, if you want to set the security point can be removed Indexes, do not display directory list, not required;
Alias: able to access through multiple domain names;
ErrorLog: error log file storage location;
customlog: Access log file storage location;
Resinconfigserver: Resin Server listening port, I here is the Local: 127.0.0.1, if there are more than one machine as a server, modify the corresponding IP address can;
The above will be the configuration of the virtual host completed, a site corresponding to a <virtualhost xxx.xxx.com></virtualhost> tag;
This completes the XAMPP implementation of the application of multiple Web sites.
What if you want to run the site under another port?
Very simple: In the "httpd.conf" main configuration file, set up multiple ports, such as listen 8081

How to use XAMPP to build a virtual host running PHP, I believe that the future encounter similar problems, it will not be difficult to everyone, I hope you will like this article.

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.