raspberry 安装apache2,使其支持ssl ,并创建自签名证书

原文链接: http://www.cnblogs.com/lthxk-yl/archive/2013/06/04/3117488.html

1:安装 apache2   命令

      sudo apt-get install apache2 php5 libapache2-mod-php5

2: 添加 ssl 模块

    默认安装apache2后,并没enable ssl功能,查看apache2 当前enable 的模块 命令

    sudo apache2ctl -M

    此时输出中应不包括  ssl_module

    运行 sudo a2enmod ssl 命令  使ssl模块 enable

  然后 sudo /etc/init.d/apache2 force-reload   强制重新载入

   此时再运行 sudo apache2ctl -M

    输出中应出现  ssl_module

3:安装openssl    命令

     sudo apt-get install openssl ssl-cert

4:生成自签名证书 ,随便建一个文件夹,我是在 /usr/local/apache/conf/caForTest

     进入此文件夹  ,

-----------------

     生成私钥  openssl genrsa -des3 -out server.key 1024

     server.key 即私钥文件

     过程中要输入密码,此密码要记住 ,以后还要用

------------------

     生成 csr(Certificate Signing Request) 文件

     openssl req -new -key server.key -out server.csr

----------------
     
用刚才的私钥和 csr 文件生成自签名证书

     openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

     server.crt 即为自签名证书

     过程详细见此网页:http://www.akadia.com/services/ssh_test_certificate.html

5:配置apache2,使其支持https连接

    编辑 /etc/apache2/sites-enabled/000-default,追加以下内容

<VirtualHost *:443>
     DocumentRoot "/var/www/phpinfo.php"
     SSLEngine on
     SSLCertificateFile /usr/local/apache/conf/caForTest/server.crt 
     SSLCertificateKeyFile /usr/local/apache/conf/caForTest/server.key
</VirtualHost>

注意证书及私钥的位置要写对
重起 apache    :    service apache2 restart

   

    

转载于:https://www.cnblogs.com/lthxk-yl/archive/2013/06/04/3117488.html

猜你喜欢

转载自blog.csdn.net/weixin_30745641/article/details/94790004