您的位置:首页 > 运维架构 > Apache

Apache服务器三种配置文件

2016-06-14 14:40 483 查看
1. 基于IP
mkdir /var/www/ip1 /var/www/ip2 //创建两个主目录编辑httpd.conf文件:<Virtualhost 192.168.0.2> //设置虚拟主机的IP DocumentRoot /var/www/ip1 //设置虚拟主机的主目录 DirectoryIndex index.html //设置主页文件 ServerAdmin root@linuxidc.com //设置管理员邮箱 ErrorLog logs/ip1-error_log //设置错误日志的存放位置 CustomLog logs/ip1-access_log common //设置访问日志的存放位置</Virtualhost><Virtualhost 192.168.0.3> //设置相应的IP DocumentRoot /var/www/ip2 DirectoryIndex index.html ServerAdmin root@linuxidc.com ErrorLog logs/ip2-error_log CustomLog logs/ip2-access_log common</Virtualhost>2. 基于域名
mkdir /var/www/linuxidc /var/www/long //创建两个主目录编辑httpd.conf文件:<Virtualhost 192.168.0.3> //设置虚拟主机的IP DocumentRoot /var/www/linuxidc //设置虚拟主机的主目录 DirectoryIndex index.html //设置主页文件 ServerName www.linuxidc.com //设置虚拟主机完全域名 ServerAdmin root@linuxidc.com //设置管理员邮箱 ErrorLog logs/linuxidc-error_log //设置错误日志的存放位置 CustomLog logs/linuxidc-access_log common //设置访问日志的存放位置</Virtualhost><Virtualhost 192.168.0.3> DocumentRoot /var/www/long DirectoryIndex index.html ServerName www.linuxidc.com //设置虚拟主机完全域名 ServerAdmin root@linuxidc.com ErrorLog logs/long-error_log CustomLog logs/long-access_log common</Virtualhost>3. 基于端口
mkdir /var/www/port8080 /var/www/port8090 //创建两个主目录编辑httpd.conf文件:Listen 8080Listen 8090<Virtualhost 192.168.0.3:8080> //设置相应的端口 DocumentRoot /var/www/port8080 //设置虚拟主机的主目录 DirectoryIndex index.html //设置主页文件 ServerAdmin root@linuxidc.com //设置管理员邮箱 ErrorLog logs/port8080-error_log //设置错误日志的存放位置 CustomLog logs/port8080-access_log common //设置访问日志的存放位置</Virtualhost><Virtualhost 192.168.0.3:8090> //设置相应的端口 DocumentRoot /var/www/port8090 DirectoryIndex index.html ServerAdmin root@linuxidc.com ErrorLog logs/port8090-error_log CustomLog logs/port8090-access_log common</Virtualhost>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息