设计笔记

  • 首页
  • 作品
  • 代码
  • 随笔
  • 关于博主
    • 豆瓣书影
  • 友情链接
  • 文章归档
  • 榜上有名
  • RSS Feed
  • GitHub
  • Twitter
  • Link

喜欢这款主题

抢先体验

LAMP配置多站点SSL

  • Tokin
  • 2016-09-28
  • 95

首先推荐安装 lamp.sh 的LAMP一键包,简单方便,安装也很快。

单个站点配置SSL可以 参考这里

其实多站点SSL跟单个站点SSL差不多。

1、安装openssl,命令如下:

yum install -y openssl openssl-devel   #CentOS 下

apt-get install -y openssl   #Debian 或 Ubuntu 下

2、申请SSL证书

市面上免费的SSL还是比较多的,但是不建议wosign和startssl,我使用的是腾讯云的免费SSL,申请后会获得一个csr文件和一个key文件

付费的则五花八门了,这里就不再赘述。

申请过程省略。

3、部署证书

在 /usr/local/apache/conf 路径下新建一个 “ssl” 目录,把你的证书全部上传到这个ssl目录下。

进入 /usr/local/apache/conf/vhost 找到你网站的配置文件,比如 fiyfile.com.conf

编辑成如下格式:

<VirtualHost *:80>
ServerName fiyfile.com
ServerAlias fiyfile.com www.fiyfile.com
DocumentRoot /data/www/fiyfile.com
DirectoryIndex index.php index.html index.htm
<Directory /data/www/fiyfile.com>
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Require all granted
php_admin_value open_basedir /data/www/fiyfile.com:/tmp:/proc
</Directory>
ErrorLog  /data/wwwlog/fiyfile.com/error.log
TransferLog  /data/wwwlog/fiyfile.com/access.log
</VirtualHost>

Listen 443
SSLPassPhraseDialog  builtin
SSLSessionCache  "shmcb:/usr/local/apache/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost *:443>
DocumentRoot /data/www/fiyfile.com
ServerName fiyfile.com
ServerAlias www.fiyfile.com

SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite ALL:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

SSLCertificateFile /usr/local/apache/conf/ssl/fiyfile.com.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl/fiyfile.com.key


BrowserMatch "MSIE [2-5]" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0

<Directory /data/www/fiyfile.com>
    Options -Indexes +FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
</VirtualHost>

保存后,重启 Apache

多个站点的 SSL 都按照此方法配置即可,请确保证书路径正确。

© 2025 设计笔记
Theme by Wing
  • {{ item.name }}
  • {{ item.name }}