12.linux上Apache虚拟主机的建立和https协议网站建立

一.Apache虚拟主机的建立
 
虚拟web主机
在同一台服务器上建立多个web站点,每个站点不独占用一台真正的服务器
 
    1.建立dns解析 两个域名同一个ip
    
        vim /etc/name.conf
    
        zone "simplexue.com" IN {
            type master ;
            file "simplexue.com.zone";
        };
 
        zone "simpleware.com" IN {
            type master ;
            file "simpleware.com.zone";
        };
 
        vim /var/named/simpelxue.com.zone
        vim /var/named/simpelware.com.zone
 
        $TTL 1D
        @       IN SOA  simplexue.com. allen.simplexue.com. (
                                        2017011901      ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
                NS      dns.simplexue.com.
        dns     A       192.168.0.1
        www     A       192.168.0.1
 
    2.配置基于域名的虚拟主机
    
        vim /etc/httpd/conf/httpd.conf
    
        NameVirtualHost 192.168.0.1:80  启动基于域名的虚拟主机
 
        <VirtualHost 192.168.0.1:80>
                DocumentRoot /var/www/html/simplexue
                ServerName www.simplexue.com
        </VirtualHost>
        <VirtualHost 192.168.0.1:80>
                DocumentRoot /var/www/html/simpleware
                 ServerName www.simpleware.com
        </VirtualHost>
    
    3.基于端口的虚拟主机
        
        vim /etc/httpd.conf.httpd.conf
 
            修改配置文件
 
            Listen 8080                                       监听端口
            #NameVirtualHost 192.168.0.1:80    注释掉
        <VirtualHost 192.168.0.1:80>
                DocumentRoot /var/www/html/simplexue
                    ServerName www.simplexue.com
        </VirtualHost>
        <VirtualHost 192.168.0.1:8080>
                 DocumentRoot /var/www/html/simpleware
                ServerName www.simplexue.com
        </VirtualHost>
 
 
二. https协议网站
 
        
        https 建立
 
        1.完善http软件的功能 支持ssl
 
            yum groupinstall "web server"
 
        2.生成私钥文件
 
            openssl genrsa -out linux.key 1024
 
        3.建立证书请求文件
 
            openssl req -new -key linux.key -out linux.csr
             国家缩写 省 市 公司名 部门名字 主机名 邮箱 默认回车
        
        4.建立一个自己签名的证书
 
            openssl x509 -req -days 365 -in linux.csr -signkey linux.key -out linux.crt
        
        5.编辑ssl配置文件使其指定签名证书以及私钥位置
 
            vim /etc/httpd/conf.d/ssl.conf
            SSLCertificateFile      /etc/pki/tls/certs/linux.crt  自签名证书位置
            SSLCertificateKeyFile      /etc/pki/tls/private/linux.key 私钥位置
        
        6.关闭之前的虚拟主机功能再验证
 
        重启http
 
        7.验证在浏览器 https://192.168.0.1
 
posted @ 2018-08-31 10:20  yikuaiqian  阅读(256)  评论(0编辑  收藏  举报