Linux下Apache虚拟主机配置

Linux下Apache虚拟主机的三种配置。这样可以实现一台主机架构多个独立域名网站。其中基于域名的最为常见。性价比也最高。下面PHP程序员雷雪松详细的讲解下Linux下Apache虚拟主机配置的具体步骤。

1、基于多ip地址的虚拟主机

Listen 80

DocumentRoot /home/httpd/html1

ServerName www.ok1.com

ErrorLog /usr/local/apache/logs/error1_log

CustomLog /usr/local/apache/logs/access1_log combined

DocumentRoot /home/httpd/html2

ServerName www.ok2.com

ErrorLog /usr/local/apache/logs/error2_log

CustomLog /usr/local/apache/logs/access2_log combined

2、基于多IP 和多端口的虚拟主机配置

Listen 12.34.56.78:80

Listen 12.34.56.78:8080

Listen 87.65.43.21:80

Listen 87.65.43.21:8080

DocumentRoot /www/example1-80

ServerName www.example1.com

DocumentRoot /www/example1-8080

ServerName www.example1.com

DocumentRoot /www/example2-80

ServerName www.example1.org

DocumentRoot /www/example2-8080

ServerName www.example2.org

3、单个IP 地址的服务器上基于域名的虚拟主机配置

# Ensure that Apache listens on port 80

Listen 80

# Listen for virtual host requests on all IP addresses

NameVirtualHost *:80

DocumentRoot /www/example1

ServerName www.example1.com

ServerAlias example1.com. *.example1.com

# Other directives here

DocumentRoot /www/example2

ServerName www.example2.org

# Other directives here

来源:Linux下Apache虚拟主机配置

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • //////////2017-1-10 ~ 2017-1-15/////////// int study_data...
    javaMonkey阅读 3,359评论 0 0
  • 常用配置指令说明 1. ServerRoot:服务器的基础目录,一般来说它将包含conf/和logs/子目录,其它...
    小僧有礼了阅读 10,070评论 0 5
  • Apache虚拟主机配置 Lucky_man 2016-12-21 原文 在一个Apache服务器上可以配置多个虚...
    ljwheyxy阅读 3,928评论 0 0
  • 一、WWW服务器虚拟主机原理 WWW服务器虚拟主机是指使用一台物理机器,充当多个主机名的WWW服务器。比如由一台机...
    BUG弄潮儿阅读 3,301评论 0 2
  • 黑白镜子原创,禁止转载 她是一个极度缺乏安全感的孩子。 指尖划过商店里因为寒冷而凝结了一团雾气的橱窗玻璃,呆滞的眼...
    黑白镜子阅读 1,877评论 0 1

友情链接更多精彩内容