Apache 配置 SSL证书

将私钥server.key和颁发的证书文件server.crt,以及根证书文件ca-bundle.crt放在/etc/ssl/123admin目录下

确保服务器安装了mod_ssl模块,可以用命令查看是否安装

# rpm -qa | grep mod_ssl

第一种方法

如果是yum安装的,编辑ssl.conf文件

# vim /etc/httpd/conf.d/ssl.conf

如果是编译安装的,请在编译安装好的apache目录找到httpd-ssl.conf文件

# vim /usr/local/apache/conf/extra/httpd-ssl.conf

修改内容如下:

DocumentRoot "/var/www/html/123admin"
ServerName www.123admin.com:443
SSLCertificateFile /etc/ssl/123admin/server.crt
SSLCertificateKeyFile /etc/ssl/123admin/server.key
SSLCertificateChainFile /etc/ssl/123admin/ca-bundle.crt

第二种方法

在/etc/httpd/conf.d新建虚拟主机配置文件www.123admin.com.conf

<VirtualHost *:443>    
    DocumentRoot /var/www/html/123admin
    ServerName www.123admin.com
    ServerAlias 123admin.com
    ErrorLog logs/www.123admin.com-error_log
    CustomLog logs/www.123admin.com-access_log combined
    DirectoryIndex index.html index.htm index.php
    SSLEngine on
    SSLCertificateFile /etc/ssl/123admin/server.crt
    SSLCertificateKeyFile /etc/ssl/123admin/server.key
    SSLCertificateChainFile /etc/ssl/123admin/ca-bundle.crt

    <Directory "/var/www/html/123admin">
        Options -Indexes FollowSymLinks
        AllowOverride all
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>