国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
【轉(zhuǎn)】XAMPP中配置多個網(wǎng)站,xampp配置多個
Home php教程 php手冊 【轉(zhuǎn)】XAMPP中配置多個網(wǎng)站,xampp配置多個

【轉(zhuǎn)】XAMPP中配置多個網(wǎng)站,xampp配置多個

Jun 13, 2016 am 08:57 AM
xampp Multiple website virtual change Configuration

【轉(zhuǎn)】XAMPP中配置多個網(wǎng)站,xampp配置多個

XAMPP虛擬主機(jī)配置,多域名綁定訪問本地站點(diǎn)

XAMPP有時候你需要一些頂級域名訪問方式來訪問你本地的項(xiàng)目也就是虛擬主機(jī)配置,這時候就需要配置虛擬主機(jī),給你的目錄綁定一個域名,實(shí)現(xiàn)多域名綁定訪問。


在Mac 下一直使用 MAMP 搭建本地 php 環(huán)境,因?yàn)槠鋸?qiáng)大的組合配置以及方便的 UI 操作。因?yàn)楣镜碾娔X是 Windows的,有時候需要搭建 php 環(huán)境來調(diào)試一些小東西方便自己工作,因?yàn)橹皇切?yīng)用,所以自己搭建本地的 WAMP 環(huán)境就沒有必要了,網(wǎng)上的 WAMP環(huán)境集成包還是很多的,什么 PHPNow 啊,WampServer 啊,PHPStudy 啊,AppServ 啊,EasyPHP啊之類的我都沒用過,以及我之前一直在使用的 UniServer,琳瑯滿目啊,看得我眼花繚亂。之所以后來不用 UniServer的原因其實(shí)我也不知道, UniServer 很強(qiáng)大,值得推薦一下,但是后來我又轉(zhuǎn)用了 XAMPP ,因?yàn)樗埠軓?qiáng)大,并且文件包達(dá) 100MB還多,當(dāng)然你可以下載 Lite 版本,但是文件大小都比 UniServer 大出好幾倍,可能就是因?yàn)樗拇螅髞砦也呸D(zhuǎn)用了 XAMPP。

有時候你需要一些頂級域名訪問方式來訪問你本地的項(xiàng)目文件而不是目錄方式訪問,這時候就需要配置虛擬主機(jī),給你的目錄綁定一個域名(本地的話可以通過修改 hosts 文件隨便綁定什么域名比如?www.a.com?或者 localdemo)。
現(xiàn)在假定你有兩個目錄,一個存在于 /xampp/htdocs/a,另一個存在于 /xampp/htdocs/b 。
現(xiàn)在你想要在本地測試的時候訪問?www.a.com?對應(yīng)的目錄是 /xampp/htdocs/a ,訪問?www.b.com?對應(yīng)的目錄是 /xampp/htdocs/b 。
懂得 Apache配置的其實(shí)就可以繞開了,因?yàn)?XAMPP 無非就是集成了 APache 之類的環(huán)境集成包,實(shí)現(xiàn)多域名也就是通過配置 Apache 實(shí)現(xiàn)的。

當(dāng) 然網(wǎng)上搜索到的方法很多,但是網(wǎng)上的信息都是轉(zhuǎn)載來轉(zhuǎn)載去的,有的方法我懷疑是否驗(yàn)證過是否正確都不知道。以下的方法是我親測的,如果你按照我的配置還是 無法實(shí)現(xiàn)本地多域名調(diào)試的話,可能是因?yàn)槟愕?XAMPP 的版本和我的不一致造成的。你可以在下面評論告知我,我會給你一一解答。以下配置針對的是XAMPP Windows 1.7.1 版本。

1、首先修改C盤WINDOWS\system32\drivers\etc目錄下的 hosts 文件,用記事本打開,加入:

(是在文件的未尾加入)
127.0.0.1?www.a.com
127.0.0.1?www.b.com

2、打開xampp\apache\conf\httpd.conf文件,搜索 “Include conf/extra/httpd-vhosts.conf”,確保前面沒有 # 注釋符,也就是確保引入了 vhosts 虛擬主機(jī)配置文件。

開啟了httpd-vhosts.conf,默認(rèn)的httpd.conf默認(rèn)配置失效(確保 httpd-vhosts.conf 文件里也開啟了虛擬主機(jī)配置,見第3條),訪問此IP的域名將全部指向 vhosts.conf 中的第一個虛擬主機(jī)。(注意是第一個,詳見第4)

3、在虛擬主機(jī)設(shè)置文件xampp\apache\conf\extra\httpd-vhosts.conf里設(shè)置:
取消 NameVirtualHost *:80 前面的 ##,這樣就啟用了 vhosts.conf ,默認(rèn)的httpd.conf默認(rèn)配置失效。虛擬主機(jī)配置將只設(shè)置在 httpd-vhosts.conf 里。

DocumentRoot /xampp/htdocs/a
ServerName?www.a.com



DocumentRoot /xampp/htdocs/b
ServerName?www.b.com


4、 設(shè)置完了第3條之后,你會發(fā)現(xiàn)訪問 localhost直接指向到設(shè)置的 a 那個路徑去了,這個問題在第2條有講。也就是開啟了 vhosts后,默認(rèn)的 httpd 的配置就會失效了,默認(rèn)的訪問就指向到 vhosts 里的第一條設(shè)置去了。這時候你要把 localhost的目錄配置給設(shè)置回來。

DocumentRoot /xampp/htdocs/
ServerName localhost


至此,XAMPP 的虛擬主機(jī)設(shè)置完畢,現(xiàn)在 訪問 localhost 還是原來的 XAMPP 的幫助指南,訪問?www.a.com?將指向到綁定的 a 目錄,訪問?www.b.com?將指向到綁定的 b 目錄。

--------------------------------------------------------------------------------

實(shí)例參考:
XAMPP添加VirtualHost以支持多個站點(diǎn)
在c:\xampp\apache\conf\extra\httpd-vhosts.conf文件中添加如下內(nèi)容:

NameVirtualHost *:80


DocumentRoot "E:/php/wordpress"
ServerName wordpress

(這一段必須加入,不然無法訪問)

Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all

?

(這一段將localhost默認(rèn)訪問設(shè)置回來,將必須放在后面)

DocumentRoot "D:/xampp/htdocs/"
ServerName localhost


在C:\WINDOWS\system32\drivers\etc目錄下的hosts文件中添加如下內(nèi)容:

127.0.0.1 wordpress

把文件httpd-vhosts.conf里:?
#NameVirtualHost *:80?

把去掉#就好了

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Understand Linux Bashrc: functions, configuration and usage Understand Linux Bashrc: functions, configuration and usage Mar 20, 2024 pm 03:30 PM

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

How to configure and install FTPS in Linux system How to configure and install FTPS in Linux system Mar 20, 2024 pm 02:03 PM

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

Computer configuration recommendations for building a high-performance Python programming workstation Computer configuration recommendations for building a high-performance Python programming workstation Mar 25, 2024 pm 07:12 PM

Title: Computer configuration recommendations for building a high-performance Python programming workstation. With the widespread application of the Python language in data analysis, artificial intelligence and other fields, more and more developers and researchers have an increasing demand for building high-performance Python programming workstations. When choosing a computer configuration, in addition to performance considerations, it should also be optimized according to the characteristics of Python programming to improve programming efficiency and running speed. This article will introduce how to build a high-performance Python programming workstation and provide specific

XAMPP encountered PHP execution exception? Troubleshooting tips to help XAMPP encountered PHP execution exception? Troubleshooting tips to help Mar 12, 2024 pm 03:21 PM

In the technical field, XAMPP is a commonly used development environment tool. It integrates software such as Apache, MySQL, PHP and Perl, and can help developers quickly build a local server environment. However, sometimes when using XAMPP, you will encounter PHP execution exception problems, which may cause problems in development work. This article will share some troubleshooting techniques to help readers solve the problem when XAMPP encounters PHP execution exceptions. 1. Check the PHP error log. First, when the P in XAMPP

Common problems and solutions for Laravel environment configuration file .env Common problems and solutions for Laravel environment configuration file .env Mar 10, 2024 pm 12:51 PM

Common problems and solutions for Laravel environment configuration file .env When using the Laravel framework to develop projects, the environment configuration file .env is very important. It contains key configuration information of the project, such as database connection information, application keys, etc. However, sometimes there are some common problems when configuring the .env file. This article will introduce these problems and provide solutions, and attach specific code examples for reference. Problem 1: Unable to read the .env file when we have configured the .env file

The solution to the problem that XAMPP cannot execute PHP is revealed The solution to the problem that XAMPP cannot execute PHP is revealed Mar 12, 2024 pm 06:39 PM

The solution to the problem that XAMPP cannot execute PHP is revealed. Specific code examples are needed. XAMPP is a very commonly used integrated development environment tool during website development or local testing. However, sometimes during the installation and configuration of XAMPP, you may encounter the problem that XAMPP cannot execute PHP, resulting in the website being unable to run normally. This article mainly provides a detailed introduction to the solution to the problem that XAMPP cannot execute PHP, including specific code examples. I hope it can help people who encounter similar problems.

Top 10 virtual currency trading platforms in the 2025 cryptocurrency circle Top 10 virtual currency trading platforms in the 2025 cryptocurrency circle Mar 12, 2025 pm 05:27 PM

Top 10 virtual currency trading platforms in the 2025 cryptocurrency circle: 1. OKX, known for its high liquidity, low fees and abundant products; 2. Binance, one of the world's largest exchanges, with a huge user base; 3. Gate.io, a veteran exchange, safe and stable; 4. Kraken, focusing on professional traders, safe and compliant; 5. Huobi Global, a world-renowned, strong technical strength; 6. Coinbase, a leading exchange in the United States, easy to use compliance; 7. KuCoin, rich trading pairs, low fees.

What are the top ten digital currency trading app platforms? The top ten digital currency exchange platforms What are the top ten digital currency trading app platforms? The top ten digital currency exchange platforms Apr 22, 2025 pm 02:54 PM

Top 10 digital currency trading app platforms: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi, 5. Coinbase, 6. Kraken, 7. Bitfinex, 8. KuCoin, 9. Bybit, 10. Bitstamp, these platforms provide real-time market trends, technical analysis tools and user-friendly interfaces to help investors conduct effective market analysis and trading decisions.

See all articles