zoukankan      html  css  js  c++  java
  • CentOS6.5 服务器+apache5.3绑定多个域名+SELinux设置

    Apache配置多个监听端口和不同的网站目录的简单方法   这个可以参考结合操作

    下面简单的介绍了如何通过设置Apache的http.conf文件,进行多个域名以及其相关的二级域名的绑定(假设我们要绑定的域名是minidx.com和ntt.cc,二级域名是blog.minidx.com,独立IP为72.167.11.30).

    打开http.conf

    1.修改根目录

    DocumentRoot "/var/www/html"  修改成你自己设置的根目录  我这是 "/var/www/websitel"

    <Directory "/var/www/html"> 别忘了也修改下  <Directory "/var/www/website">

    2.设置多个域名

    1,ServerName 127.0.0.1 修改成ServerName 72.167.11.30         我的是:ServerName *:80

    2,#NameVirtualHost *   修改成"NameVirtualHost 72.167.11.30"  我的是:NameVirtualHost *:80

    这个是主机默认根目录

    <VirtualHost *:80>
        ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot /var/www/website
        ServerName 72.137.11.30
        ErrorLog logs/dummy-host.example.com-error_log
        CustomLog logs/dummy-host.example.com-access_log common
    </VirtualHost>
    #这个是增加的虚拟域名目录
    <VirtualHost *:80>
    #     ServerAdmin webmaster@dummy-host.example.com
         DocumentRoot /var/www/website/weixin
         ServerName weixin.yunxindai.com
         ErrorLog logs/weixin.yunxindai.com-error_log
         CustomLog logs/weixin.yunxindai.com-access_log common
     </VirtualHost>

    下面这个是一个站点绑定多个域名: 还没测试 留待后期测试验证

    后来看了看书,发现有个叫”ServerAlias“的东西可以用
    其实可以这样:

    <VirtualHost *:80>
    ServerAdmin i@kuigg.com
    DocumentRoot /www/kuigg.com
    ServerName kuigg.com
    ServerAlias  www.kuigg.com  abc.kuigg.com
    </VirtualHost>

    要绑多少个域名都可以写在 ServerAlias   后面,用空格隔开即可

    linux服务器apache 一个IP,一个端口,建立多个网站的方法。()

    我的配置如下 

    ServerName 192,168.197.139:80
    NameVirtualHost 192.168.197.139:80
    <VirtualHost 192.168.197.139>
         ServerAdmin admin@yun.yunxindai.com
         DocumentRoot /var/www/website
         ServerName   192.168.197.139
         ErrorLog logs/dummy-host.example.com-error_log
         CustomLog logs/dummy-host.example.com-access_log common
    </VirtualHost>
    #
    <VirtualHost 192.168.197.139>
        ServerAdmin admin@yun.yunxindai.com
        DocumentRoot /var/www/website/yun.yunxindai
        ServerName   www.wl.yun.yunxindai.com
        ServerAlias  www.wl.yun.yunxindai.com
        ErrorLog logs/dummy-host.example.com-error_log
        CustomLog logs/dummy-host.example.com-access_log common
        <Directory "/var/www/website/yun.yunxindai">
               Options Indexes FollowSymLinks
               AllowOverride ALL
               Order allow,deny
               Allow from all
         </Directory>
    </VirtualHost>
     #
    <VirtualHost 192.168.197.139>
         ServerAdmin admin@weixin.yunxindai.com
         DocumentRoot /var/www/website/weixin
         ServerName   www.wl.weixin.yunxindai.com
         ServerAlias  www.wl.weixin.yunxindai.com
         ErrorLog logs/dummy-host.example.com-error_log
         CustomLog logs/dummy-host.example.com-access_log common
         <Directory "/var/www/website/weixin">
                Options Indexes FollowSymLinks
                AllowOverride ALL
                Order allow,deny
                Allow from all
          </Directory>
    </VirtualHost>

    重启 apach报错 :

    DocumentRoot  [/var/www/website/weixin] does not exit

    苍天呐大地啊,天地良心,这个目录真实存在就是不行不能访问。

    是因为是使用了SELinux,有两种方法解决:

     方法一:禁止使用SELinux,运行:

    system-config-securitylevel (或 redhat-config-securitylevel)

    来禁止对http的SELinux设置。

     方法二:或给新路径设置SELinux权限:

    chcon -R -h -t httpd_sys_content_t  /var/www/website/weixin

    我采用方法2设置后就好了。

    本地 C:WindowsSystem32driversetchosts

    设置如下:

    192.168.197.139 www.wl.yun.yunxindai.com
    192.168.197.139 www.wl.weixin.yunxindai.com

    本地直接输入域名即可访问(本地测试很好用!)

     具体关于selinux的设置参考博文:在CentOS 6.X上折腾SELinux

     在虚拟机上设置半天 selinux 还是time out后来才发现是没开80宽口。

    碰到的问题:You don't have permission to access / on this server.

    参考博文:Linux Centos7 Apache 访问 You don't have permission to access / on this server.

    我的是在上面基础上修改权限:

    chmod o+x  /var/www/website
    chmod g+x  /var/www/website
  • 相关阅读:
    浏览器的跨域请求 与 CORS(跨域资源共享)
    HTML 占位符
    C# 中的 base和this
    推荐一个pdf引擎
    整理wifi相关的知识点
    交叉编译(ISC)DHCP:dhcp-4.3.0b1
    (转载)子网掩码,网关的概念
    海思-VB被占用导致vb无法去初始化
    c++创建文件时重命名同名文件
    iw创建虚拟网卡wlan1,ap_sta共存
  • 原文地址:https://www.cnblogs.com/wuling129/p/4689779.html
Copyright © 2011-2022 走看看