ubuntu apache 网站ssl 配置

  1. 获取免费ssl证书:从阿里云可以获取,并下载。
  2. 编辑default-ssl.conf

<IfModule mod_ssl.c>

<VirtualHost _default_:443>
                ServerAdmin webmaster@localhost
                DocumentRoot /var/www/html
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
               SSLCertificateFile /etc/apache2/cert/7813799_yeshiwei.com_public.crt
               SSLCertificateKeyFile /etc/apache2/cert/7813799_yeshiwei.com.key
               SSLCertificateChainFile /etc/apache2/cert/7813799_yeshiwei.com_chain.crt

               <FilesMatch “\.(cgi|shtml|phtml|php)$”>
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
        </VirtualHost>
</IfModule>

  1. 启用mod

sudo a2enmod ssl

  systemctl restart apache2

  sudo systemctl restart apache2

  sudo a2enmod headers

  sudo systemctl restart apache2

  sudo a2enconf ssl-params

  sudo systemctl restart apache2

  sudo a2ensite default-ssl

  sudo systemctl restart apache2

  sudo apache2ctl configtest

  sudo systemctl restart apache2

Add a Comment

您的电子邮箱地址不会被公开。 必填项已用*标注