2017年に無料のSSL証明書を作成します

まえがき


最近、自分のサイトのSSL証明書を探していましたが、Habrでは、Google ChromeとMozillaFirefoxがサポートしなくなったStartSSlの指示しかありませんでした。 そして、ここで、自分のサーバーで段階的に証明書を作成する方法を示したいと思います。

それでは始めましょう


ルートにsslのフォルダーを作成します。

mkdir /ssl 

次に、Apacheの設定に移動します

 cd /etc/apache2/sites-available 

サンプル構成をダウンロードします。

 sudo wget https://linode.com/docs/assets/apache2-roundcube.sample.conf 

所有者をrootおよび権限に変更します。

 sudo chown root:root apache2-roundcube.sample.conf 

 sudo chmod 644 apache2-roundcube.sample.conf 

そして編集中です。

 nano apache2-roundcube.sample.conf 

タグ<VirtualHost *:80>および<VirtualHost *:443>内
ServerAdminをwebmaster @ site nameに変更します。
ServerNameをサイト名に変更します。
DocumentRootをサイトのあるディレクトリに変更します。これは次のとおりです。

 /var/www/html/ 

次を除くすべてのディレクトリタグが削除されます。

 <Directory /var/www/roundcube>...</Directory> 

ここでは、/ var / www / roundcube / var / www / htmlの代わりにパスを変更します。 そして、SSL証明書へのパスを変更します。

  SSLCertificateFile /etc/apache2/ssl/webmail.example.com/apache.crt 

  SSLCertificateKeyFile /etc/apache2/ssl/webmail.example.com/apache.key 



  SSLCertificateFile /ssl/crt.crt 

  SSLCertificateKeyFile /ssl/key.key 

設定例:

 # Apache2 vhost configuration sample for Roundcube # https://linode.com/docs/email/clients/installing-roundcube-on-ubuntu-14-04/ <VirtualHost *:80> # Virtual host configuration + information (replicate changes to *:443 below) ServerAdmin webmaster@uranius.pp.ua ServerName uranius.pp.ua DocumentRoot /var/www/html/ # ErrorLog /var/log/apache2/webmail.example.com/error.log # CustomLog /var/log/apache2/webmail.example.com/access.log combined # Permanently redirect all HTTP requests to HTTPS RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L] </VirtualHost> <IfModule mod_ssl.c> <VirtualHost *:443> # Virtual host configuration + information (replicate changes to *:80 above) ServerAdmin webmaster@uranius.pp.ua ServerName uranius.pp.ua DocumentRoot /var/www/html # ErrorLog /var/log/apache2/webmail.example.com/error.log # CustomLog /var/log/apache2/webmail.example.com/access.log combined # SSL certificate + engine configuration SSLEngine on SSLCertificateFile /ssl/crt.crt SSLCertificateKeyFile /ssl/key.key # Roundcube directory permissions + restrictions <Directory /var/www/html/> Options -Indexes AllowOverride All </Directory> </VirtualHost> </IfModule> 

ファイルの名前を変更する

 sudo mv apache2-roundcube.sample.conf uranius.pp.ua.conf 

不要な構成を無効にする

 sudo a2dissite 000-default.conf default-ssl.conf 

必要なモジュールが含まれています。

 sudo a2enmod deflate expires headers rewrite ssl 

サイト構成をオンにします。

 a2ensite uranius.pp.ua.conf 

そして今、最も興味深いのは、証明書を取得することです。 www.sslforfree.comにアクセスします。 ドメイン名を入力し、受信をクリックします。 次に、ファイルをダウンロードしてサーバーにアップロードします。 サイトがあるフォルダーに移動し、ディレクトリを作成します。

 cd /var/www/html/ 

 mkdir .wellknown 

 cd .wellknown 

 mkdir acme-challenge 

 cd acme-challenge 

ファイルをそこに置き、「SSl証明書のダウンロード」をクリックします。 証明書付きのzipをダウンロードし、ルートのsslフォルダーにあるサーバーにアップロードします。 フォルダーに入って名前を変更しましょう:

 cd /ssl 

 mv certificate.crt crt.crt 

 mv private.key key.key 

保存します。 設定の確認:

 apachectl configtest 

サーバーを再起動するだけで、サイトの準備は完了です。

 /etc/init.d/apache2 restart 

Source: https://habr.com/ru/post/J324740/


All Articles