導航:首頁 > IDC知識 > xampp虛擬主機

xampp虛擬主機

發布時間:2020-08-06 00:02:32

1、xampp 虛擬主機執行perl 的方法

在你的虛擬機裡面增加配置
ScriptAlias /cgi-bin/ "D:/htdocs/cgi-bin/"
然後設置對應的目錄D:/htdocs/cgi-bin/的許可權
<Directory "D:/htdocs/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
重新啟動apache就OK了

2、如何配置XAMPP的虛擬主機

1.下載並安裝好xampp,這個過程就不掩飾了哇。
   如果已經打開了apache伺服器,先將其關掉。接下來進入配置虛擬主機:
   我這里先項目放在了D盤,文件夾名稱project,新建一個index.php文件,雙擊打開文件後寫入測試代碼:
<?php
      phpinfo();
?>
代碼什麼意思相信大家都懂的!

3
2.找到你的xampp安裝目錄,依次找到下面的目錄:apache目錄--conf目錄--extra目錄--httpd-vhosts.conf文件,使用編輯器打開,notepad等等...
PS:目錄的話,大家根據圖走就行;

4
3.打開文件後,在最下邊寫入如下代碼:
<VirtualHost *:80>
 ServerName project.com
 DocumentRoot "D:/Developing/project"
<Directory "D:/Developing/project"> 
 Options FollowSymLinks IncludesNOEXEC Indexes
 DirectoryIndex index.html index.htm index.php
 AllowOverride all 
 Order Deny,Allow 
 Allow from all 
 Require all granted
</Directory>
</VirtualHost>
保存。
其中的網站名稱和項目路徑需要大家根據自己的實際情況去更改,切不可照搬!

5
4.打開C盤,依次找到下面的目錄:windows目錄--system32目錄--drivers目錄--etc目錄--找到hosts文件,使用編輯器打開;

6
5.最文件最下邊加入如下代碼:
127.0.0.1 project.com  保存。
啟動apache伺服器,輸入你的網站名稱,如果結果和如圖一樣,則說明xampp配置虛擬主機成功。

3、虛擬機安裝xampp 主機無法訪問

你給的信息太少,你有xampp提供的控制工具來打開看看,具體的錯誤提示有哪些,還有,apache的埠是不是被其它程序佔用了,比如IIS!

4、Mac os XAMPP配置了虛擬主機之後IP地址訪問403

httpd.conf
第一步:注銷,如下樣式:
#DocumentRoot "C:/myenv/apache/htdocs"
第二步:啟動虛擬主機的配置,如下樣式:
Include conf/extra/httpd-vhosts.conf

第三步:配置httpd-vhosts.conf,增加如下樣式:
<VirtualHost *:80>
DocumentRoot "D:/myblog2"
ServerName seophp.example.com
DirectoryIndex test.html index.html index.htm index.php
<Directory />
Options FollowSymLinks
#AllowOverride None 不許可別人修改我們的頁面
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

注意標點符號,apache對中英標點號是不檢測的,但是運行會出問題。

如果不行就看一下\apache\logs\error.log轉上看看。

你這些是否是多餘的
《httpd.conf檢查了httpd-vhosts.conf是打開的
httpd-vhosts.conf中的配置如下:
NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
</VirtualHost>

5、xampp apache2怎麼配置虛擬主機

用護衛神.apache大師,自帶主機管理系統。

6、如何配置 Apache 的虛擬主機

1、基於ip地址的虛擬主機

復制代碼代碼如下:

Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /home/httpd/html1
ServerName www.ok1.com
ErrorLog /usr/local/apache/logs/error1_log
CustomLog /usr/local/apache/logs/access1_log combined
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /home/httpd/html2
ServerName www.ok2.com
ErrorLog /usr/local/apache/logs/error2_log
CustomLog /usr/local/apache/logs/access2_log combined
</VirtualHost>

2、基於IP 和多埠的虛擬主機配置

復制代碼代碼如下:

Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>

DocumentRoot /www/example1-8080
ServerName www.example1.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example1.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example2.org
</VirtualHost>

3、單個IP 地址的伺服器上基於域名的虛擬主機配置

復制代碼代碼如下:

# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ServerAlias example1.com. *.example1.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>

如果您感覺上面的文章還不夠詳細可以看下下面的文章:

實驗目標:在apache實現基於域名的虛擬主機
實驗用的XAMPP版本為1.7.7,內含apache版本為2.2.21

實驗前准備:

1. 為了測試不同的域名,在Windows/System32/drivers/etc/下覓得hosts文件,在其中添加實驗用的域名若干,如 -

復制代碼代碼如下:

127.0.0.1 test1.net
127.0.0.1 test2.net

如此,則在瀏覽器中輸入該倆域名時,Windows將其解析為127.0.0.1本地地址。即,在瀏覽器中訪問localhost, test1.net, test2.net均可訪問XAMPP的歡迎頁。
2. 在apache目錄下建立目錄,以放置您不同的網站。為保護XAMPP原有的htdocs中的歡迎頁內容,實驗另外建立了與htdocs平級的htdocs1目錄,在其下建立了test1.net, test2.net兩個子目錄用以放置實驗用的網站。如下 -
apache/htdocs1/test1.net - 放置test1.net網站內容
apache/htdocs1/test2.net - 放置test2.net網站內容
在這兩個目錄中各新建hello world一網頁 index.html,內容 -

復制代碼代碼如下:

<HTML>
<HEAD></HEAD>
<BODY>
<H1>hello~, 這是[對應的網站名,用以區別].net</H1></BODY>
</HTML>

實驗步驟:
1. 找到apache/conf/httpd.conf, 將其中的
ServerAdmin
ServerName
DocumentRoot
注釋掉。

2. 在httpd.conf中,找到行
Include "conf/extra/httpd-vhosts.conf"
如被注釋則解注。該文件記載了虛擬主機的參數。[以前虛擬主機參數是直接填寫在httpd.conf中的,為了更好地組織文件,將其分離出去,類似於某些編程語言一樣。因此httpd.conf中include它,即相當於把它的內容填在了httpd.conf中。]

3. 這個httpd-vhosts.conf文件格式基本如下 -

復制代碼代碼如下:

#blah-blah
NameVirtualHost *:80
#blah-blah
#blah-blah
<VirtualHost *:80>
ServerAdmin XXXXXXXX
DocumentRoot "XXXXXXXX"
ServerName XXXXXXX
ServerAlias XXXXXX
ErrorLog "logs/XXXXXX-error.log"
CustomLog "logs/XXXXXXX-error.log" combined
</VirtualHost>

需要修改的,就是<VirtualHost>中的參數了。這個可以參見apache官方文檔。根據實驗域名,可以增加兩個<VirtualHost>:

復制代碼代碼如下:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/xampp/htdocs1/test1.net"
ServerName test1.net
ServerAlias www.test1.net
ErrorLog "logs/test1-error.log"
CustomLog "logs/test1-access.log" combined

<Directory "C:/xampp/htdocs1/test1.net">
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/xampp/htdocs1/test2.net"
ServerName test2.net
ServerAlias www.test2.net
ErrorLog "logs/test1-error.log"
CustomLog "logs/test1-access.log" combined

<Directory "C:/xampp/htdocs1/test2.net">
order allow,deny
allow from all
</Directory>
</VirtualHost>

注意,如果不在各VirtualHost中定義Directory的可訪問性,你將遇到的是Access Forbidden!就連原來的localhost也是。

4. 由於之前注釋掉了httpd.conf中的ServerName, DocumentRoot等,為了仍然能以localhost訪問原XAMPP歡迎頁,就在增加一個VirtualHost,如下 -

復制代碼代碼如下:

<VirtualHost *:80>
ServerAdmin adm@localhost
DocumentRoot "C:/xampp/htdocs"
ServerName localhost

ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined

<Directory "C:/xampp/htdocs">
order allow,deny
allow from all
</Directory>
</VirtualHost>

為了避免出錯,把它放置在第一個Virtualhost位置。

至此,apache基於域名的虛擬主機配置完成。可以通過http://localhost訪問XAMPP歡迎頁,通過http://test1.net和http://test2.net訪問各自的主頁。

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/sky/apache2/htdocs"
ServerName localhost
ServerAlias www.sky.com
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined

<Directory "E:/sky/apache2/htdocs">
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/sky/apache2/htdocs/project1"
ServerName project1.com
ServerAlias www.project1.com
ErrorLog "logs/project1-error.log"
CustomLog "logs/project1-access.log" combined

<Directory "E:/sky/apache2/htdocs/project1">
order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/sky/apache2/htdocs/zendTest/public"
ServerName zendTest.com
ServerAlias www.zendTest.com
DirectoryIndex index.php
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/sky/apache2/htdocs/testRewrite"
ServerName testRewrite.com
ServerAlias www.testRewrite.com
# DirectoryIndex index.php
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "E:/sky/apache2/htdocs/test"
ServerName test.com
ServerAlias www.test.com
ErrorLog "logs/zendTest-error.log"
CustomLog "logs/zendTest-access.log" combined

<Directory "E:/sky/apache2/htdocs/test">
order allow,deny
allow from all
</Directory>
</VirtualHost>

7、如何在VMware Workstation11的Windows Server 2008 R2中安裝XAMPP

先到官網上下載windows server 2012體驗版ISO。

在VMware Workstation上新建一個虛擬機,硬體配置不低於要求的512內存和32G硬碟空間。中間提示需要輸入產品密鑰等信息可以先不填,直接點擊「下一步」

這里的硬體配置是1G內存,60G硬碟。

點擊完成後打開虛擬機電源,系統通過光碟啟動安裝程序

安裝程序啟動後第一步是選擇要安裝語言。

這里按默認選項幾可,點擊「下一步」提示現在安裝,左下角有個比較有意思的功能「修復計算機」

點擊修復計算機後有「疑難解答」和「關閉電腦」兩選項,疑難解答提示恢復或初始化電腦或者使用高級工具

於是點擊進去看了一下才知道,說的高級工具是「系統映像恢復」和「命令提示符」就是高級工具呀,系統映像恢復估計類似修復光碟的功能,而命令後提示就是咱們裝98時用的命令環境。真是高級呀。。

到這個界面來以後,沒有返回到安裝界面的地方,只能用命令提示符,進到光碟,執行下「setup」命令了,回想起win98了吧


8、你好,ubuntu下xampp配置虛擬主機的問題我情況和你的一樣。請問 sudo vi /etc/resolv.conf 內容要怎麼寫

這個相當於windows系統中的dns伺服器,寫兩個常用的dns伺服器就可以了,和虛擬主機配置應該關系不大。比如
nameserver 8.8.8.8

9、linux下Xampp 中ftp的配置問題

簡單的辦法就是 在linux中分別創建帳號,並且把帳號主目錄設置為相關的目錄

useradd -g ftp -d /opt/lampp/htdocs/web1 -s /sbin/nologin web1
這樣就添加了一個 ftp組的用戶web1 ,主目錄是 /opt/lampp/htdocs/web1 無登錄許可權(只允許通過ftp登錄),創建用戶的時候會生成主目錄,不要自己創建 /opt/lampp/htdocs/web1,
然後就是passwd web1 為其設置密碼

如果用戶比較多,上百個這樣子就需要用到虛擬用戶了,虛擬用戶的設置 就沒那麼簡單了,,到網上找找相應的文章吧。

10、虛擬機上安裝的CentOS,然後安裝了Xampp,虛擬機上面能夠訪問,就是本地不能直接訪問,本地能夠ping通

在centos關閉selinux和防火牆試試

與xampp虛擬主機相關的知識