国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 幫助中心 > 正文

Mac配置虛擬主機詳細過程

2024-07-09 22:39:27
字體:
來源:轉載
供稿:網友

一、啟動Apache本文主要講述了

終端輸入:sudo apachectl start

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

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

2.打開終端:cd /etc

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

二、設置虛擬主機

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

2.在httpd.conf中找到“#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出。

3.運行“sudo apachectl restart”,重啟Apache后就開啟了虛擬主機配置功能。

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

  1. <VirtualHost *:80>  
  2.  
  3. ServerAdmin webmaster@dummy-host.example.com  
  4.  
  5. DocumentRoot "/usr/docs/dummy-host.example.com" 
  6.  
  7. ServerName dummy-host.example.com  
  8.  
  9. ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" 
  10.  
  11. CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common  
  12.  
  13. </VirtualHost>  
  14.  
  15. <VirtualHost *:80>  
  16.  
  17. ServerAdmin webmaster@dummy-host2.example.com  
  18.  
  19. DocumentRoot "/usr/docs/dummy-host2.example.com" 
  20.  
  21. ServerName dummy-host2.example.com  
  22.  
  23. ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" 
  24.  
  25. CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common  
  26.  
  27. </VirtualHost> 

而實際上,這兩個虛擬主機是不存在的,在沒有配置任何其他虛擬主機時,可能會導致訪問localhost時出現如下提示:

Forbidden

You don't have permission to access /index.php on this server

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

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

  1. <VirtualHost *:80>  
  2.  
  3. DocumentRoot "/Library/WebServer/Documents" 
  4.  
  5. ServerName localhost  
  6.  
  7. ErrorLog "/private/var/log/apache2/localhost-error_log" 
  8.  
  9. CustomLog "/private/var/log/apache2/localhost-access_log" common  
  10.  
  11. </VirtualHost>  
  12.  
  13. <VirtualHost *:80>  
  14.  
  15. DocumentRoot "/Library/WebServer/Documents" 
  16.  
  17. ServerName 虛擬主機地址 (如:www.test.com) 
  18.  
  19. ErrorLog "/private/var/log/apache2/test-error_log" 
  20.  
  21. CustomLog "/private/var/log/apache2/test-access_log" common  
  22.  
  23. <Directory />  
  24.  
  25. Options Indexes FollowSymLinks MultiViews  
  26.  
  27. AllowOverride None  
  28.  
  29. Order deny,allow  
  30.  
  31. Allow from all  
  32.  
  33. </Directory>  
  34.  
  35. </VirtualHost> 

保存,退出,重啟Apache。

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

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

It works!

配置成功,和localhost一致!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 秀山| 泸州市| 桑植县| 黎川县| 谢通门县| 华池县| 阳山县| 凤庆县| 彰化市| 三亚市| 贡觉县| 双桥区| 巍山| 南京市| 肥东县| 宜宾市| 甘谷县| 和顺县| 墨脱县| 泽库县| 宁都县| 丰镇市| 垫江县| 深圳市| 永泰县| 浏阳市| 辉县市| 葵青区| 庄河市| 邹城市| 内江市| 永城市| 民县| 苍南县| 沐川县| 富阳市| 依兰县| 镇原县| 威远县| 宜昌市| 龙州县|