麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > Apache > 正文

Apache搭建多個站點方法詳解

2024-08-27 18:22:19
字體:
來源:轉載
供稿:網友

Apache的虛擬主機是一種允許在同一臺機器上配置多個不同站點的web服務器環境的,就是iis一樣可以創建多站點了,但是apache需要在編輯狀態操作,不能像windows iis直接點擊幾下就好了,以下是介紹配置的方法。

最平常的大概有3種方法。

第一種:單IP不同端口

第二種:多IP同端口(獨立IP的虛擬空間)

第三種:域名綁定根目錄的方式(共享IP的虛擬空間)

Apache的核心配置文件名是”httpd.conf”,其所存放的路徑在Apache目錄下的conf文件夾下。修改它只需要使用記事本(建議使用其他編輯器,帶行數的那種,方便修改),生效的話只需要保存httpd.conf,重啟apache即可。

下面多站點支持的話,修改httpd.conf的第187~264行(不同的httpd.conf可能有差異),也就是在ServerAdmin和ServerName那里,大部分是注釋。下面是主要修改的地方。

注意:如果是服務器請備份httpd.conf后再修改文件。

  1. # 'Main' server configuration 
  2. # 
  3. # The directives in this section set up the values used by the 'main' 
  4. # server, which responds to any requests that aren't handled by a 
  5. # <VirtualHost> definition.  These values also provide defaults for 
  6. # any <VirtualHost> containers you may define later in the file. 
  7. # 
  8. # All of these directives may appear inside <VirtualHost> containers, 
  9. # in which case these default settings will be overridden for the 
  10. # virtual host being defined. 
  11. # 
  12. # 
  13. # ServerAdmin: Your address, where problems with the server should be 
  14. # e-mailed.  This address appears on some server-generated pages, such 
  15. # as error documents.  e.g. [email protected] 
  16. # 
  17. ServerAdmin [email protected] 
  18. # 
  19. # ServerName gives the name and port that the server uses to identify itself. 
  20. # This can often be determined automatically, but we recommend you specify 
  21. # it explicitly to prevent problems during startup. 
  22. # 
  23. # If your host doesn't have a registered DNS name, enter its IP address here. 
  24. # 
  25. ServerName www.example.com:80 
  26. # 
  27. # Deny access to the entirety of your server's filesystem. You must 
  28. # explicitly permit access to web content directories in other  
  29. # <Directory> blocks below. 
  30. # 
  31. <Directory /> 
  32.     AllowOverride All 
  33.     Require all denied 
  34. </Directory> 
  35. # 
  36. # Note that from this point forward you must specifically allow 
  37. # particular features to be enabled - so if something's not working as 
  38. # you might expect, make sure that you have specifically enabled it 
  39. # below. 
  40. # 
  41. # 
  42. # DocumentRoot: The directory out of which you will serve your 
  43. # documents. By default, all requests are taken from this directory, but 
  44. # symbolic links and aliases may be used to point to other locations. 
  45. # 
  46. DocumentRoot "g:/www" 
  47. <Directory "g:/www"
  48.     # 
  49.     # Possible values for the Options directive are "None", "All", 
  50.     # or any combination of: 
  51.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
  52.     # 
  53.     # Note that "MultiViews" must be named *explicitly* --- "Options All" 
  54.     # doesn't give it to you. 
  55.     # 
  56.     # The Options directive is both complicated and important.  Please see 
  57.     # http://httpd.apache.org/docs/2.4/mod/core.html#options 
  58.     # for more information. 
  59.     # 
  60.     Options Indexes FollowSymLinks 
  61.     # 
  62.     # AllowOverride controls what directives may be placed in .htaccess files. 
  63.     # It can be "All", "None", or any combination of the keywords: 
  64.     #   Options FileInfo AuthConfig Limit 
  65.     # 
  66.     AllowOverride All 
  67.     # 
  68.     # Controls who can get stuff from this server. 
  69.     # 
  70.     Require all granted 
  71. </Directory> 

第一種一般是測試環境,畢竟加了端口,如何綁定域名,訪問的時候域名后面也需加端口。

例子分別通過80和8080訪問不同的根目錄,大概在50幾行有個Listen 80,在下面添加8080端口。

  1. Listen 80 
  2. Listen 8080<VirtualHost *:80>  
  3.     ServerAdmin [email protected]  
  4.     ServerName localhost:80  
  5.     DocumentRoot "g:/www1"  
  6.      <Directory "g:/www1">  
  7.      Options  Indexes FollowSymLinks  
  8.      AllowOverride All  
  9.      Require all granted  
  10.    </Directory>    
  11. </VirtualHost>  
  12. <VirtualHost *:8080>  
  13.     ServerAdmin [email protected] 
  14.     ServerName localhost:8080   
  15.     DocumentRoot "g:/www2"  
  16.    <Directory "g:/www2">  
  17.      Options Indexes FollowSymLinks  
  18.      AllowOverride All  
  19.      Require all granted  
  20.    </Directory>        
  21. </VirtualHost> 

第二種多IP同端口。

IP地址1:192.168.2.2  IP地址2:192.168.1.68  端口同是80端口。

  1. <VirtualHost 192.168.1.68:80>  
  2.     ServerAdmin [email protected]  
  3.     ServerName localhost:80  
  4.     DocumentRoot "g:/www1"  
  5.      <Directory "g:/www1">  
  6.      Options FollowSymLinks  
  7.      AllowOverride All  
  8.      Require all granted  
  9.    </Directory>    
  10. </VirtualHost>  
  11. <VirtualHost 192.168.2.2:80>  
  12.     ServerAdmin [email protected] 
  13.     ServerName localhost:80  
  14.     DocumentRoot "g:/www2"  
  15.    <Directory "g:/www2">  
  16.      Options FollowSymLinks  
  17.      AllowOverride All  
  18.      Require all granted  
  19.    </Directory>        
  20. </VirtualHost> 

第三種同IP不同域名和根目錄(域名的話修改本地host演示)。

  1. <VirtualHost 192.168.2.2:80>  
  2.     ServerAdmin [email protected]  
  3.     ServerName www.hzhuti.com  
  4.     DocumentRoot "g:/www1"  
  5.      <Directory "g:/www1">  
  6.      Options FollowSymLinks  
  7.      AllowOverride All  
  8.      Require all granted  
  9.    </Directory>    
  10. </VirtualHost>  
  11. <VirtualHost 192.168.2.2:80>  
  12.     ServerAdmin [email protected] 
  13.     ServerName www.111cn.net 
  14.     DocumentRoot "g:/www2"  
  15.    <Directory "g:/www2">  
  16.      Options FollowSymLinks  
  17.      AllowOverride All  
  18.      Require all granted  
  19.    </Directory>        
  20. </VirtualHost> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 看国产一级毛片 | 99欧美精品| 亚州成人在线观看 | 宅男视频在线观看免费 | 国产精品久久久久久久亚洲按摩 | 亚洲aⅴ在线观看 | 91社区电影 | 国产精品久久久久久久久久尿 | 9999精品| 玩偶姐姐 在线观看 | 孕妇体内谢精满日本电影 | 中文字幕精品久久 | www.91在线观看 | 日韩在线播放第一页 | 成人三级电影网 | 国产精品美女久久久免费 | 欧美大片一级毛片 | 99精品视频在线看 | 毛片视频网址 | 色999中文字幕| 亚洲精品aⅴ中文字幕乱码 欧美囗交 | 精品国产一区二区三区四 | chinese hd xxxx tube| 欧美人与性禽动交精品 | 久久久久久久亚洲视频 | 在线视频 日韩 | 少妇的肉体的满足毛片 | 国产精品嘿咻嘿咻在线播放 | 国产免费中文字幕 | 亚洲不卡| 亚洲精品午夜视频 | 91看片在线观看视频 | 亚洲第一成人久久网站 | 国产一区毛片 | 日韩av官网| 国产成人高清在线观看 | h色网站免费观看 | 精品一区二区三区在线视频 | 国产午夜免费福利 | 亚洲第一视频在线 | 免费a观看 |