欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

MacApache配置虛擬主機(jī)

今天小編就為大家?guī)?lái)一篇Mac在自帶apache配置虛擬主機(jī)的文章。小編覺得挺不錯(cuò)的,為此分享給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。

創(chuàng)新互聯(lián)建站是一家專業(yè)提供阿拉山口企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、H5技術(shù)、小程序制作等業(yè)務(wù)。10年已為阿拉山口眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。

一、啟動(dòng)Apache

終端輸入:sudo apachectl start

Apache的安裝目錄在:/etc/apache2/,etc默認(rèn)是隱藏的。有三種方式查看:

1.桌面位于Finder時(shí):shift+command+g,輸入“/etc”(即Finder-前往-前往文件夾的快捷鍵)

2.打開終端:cd /etc

3.可以在terminal 輸入 "open /etc"

二、設(shè)置虛擬主機(jī)

1.在終端運(yùn)行“sudo vi /etc/apache2/httpd.conf”,打開Apche的配置文件

2.在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“?!保4娌⑼顺?。

3.運(yùn)行“sudo apachectl restart”,重啟Apache后就開啟了虛擬主機(jī)配置功能。

4.運(yùn)行“sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打開了配置虛擬主機(jī)文件httpd-vhost.conf,配置虛擬主機(jī)了。需要注意的是該文件默認(rèn)開啟了兩個(gè)作為例子的虛擬主機(jī)

<VirtualHost *:80> 
ServerAdmin webmaster@dummy-host.example.com 
DocumentRoot "/usr/docs/dummy-host.example.com" 
ServerName dummy-host.example.com 
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" 
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common 
</VirtualHost> 
<VirtualHost *:80> 
ServerAdmin webmaster@dummy-host2.example.com 
DocumentRoot "/usr/docs/dummy-host2.example.com" 
ServerName dummy-host2.example.com 
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" 
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common 
</VirtualHost>

而實(shí)際上,這兩個(gè)虛擬主機(jī)是不存在的,在沒有配置任何其他虛擬主機(jī)時(shí),可能會(huì)導(dǎo)致訪問localhost時(shí)出現(xiàn)如下提示:
Forbidden
You don't have permission to access /index.php on this server

最簡(jiǎn)單的辦法就是在它們每行前面加上#,注釋掉就好了,這樣既能參考又不導(dǎo)致其他問題。

5.增加如下配置,支持localhost訪問,添加虛擬主機(jī)訪問

<VirtualHost *:80> 
DocumentRoot "/Library/WebServer/Documents" 
ServerName localhost 
ErrorLog "/private/var/log/apache2/localhost-error_log" 
CustomLog "/private/var/log/apache2/localhost-access_log" common 
</VirtualHost> 
<VirtualHost *:80> 
DocumentRoot "/Library/WebServer/Documents" 
ServerName 虛擬主機(jī)地址 (如:www.test.com)
ErrorLog "/private/var/log/apache2/test-error_log" 
CustomLog "/private/var/log/apache2/test-access_log" common 
<Directory /> 
Options Indexes FollowSymLinks MultiViews 
AllowOverride None 
Order deny,allow 
Allow from all 
</Directory> 
</VirtualHost>

保存,退出,重啟Apache。

6.運(yùn)行“sudo vi /etc/hosts”,打開hosts配置文件,加入"127.0.0.1 www.test.com",這樣就可以配置完成test虛擬主機(jī)了。

打開瀏覽器,輸入:www.test.com

It works!

配置成功,和localhost一致!

看完上述內(nèi)容,你們掌握Mac Apache配置虛擬主機(jī)的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

當(dāng)前題目:MacApache配置虛擬主機(jī)
網(wǎng)頁(yè)鏈接:http://chinadenli.net/article42/jiigec.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站收錄、用戶體驗(yàn)、品牌網(wǎng)站制作網(wǎng)站維護(hù)、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司