0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Apache2: VirtualHost で LetsEncrypt を使う

Last updated at Posted at 2020-07-21

VirtualHost の設定

/etc/apache2/sites-available/virtual_hosts.conf
<VirtualHost *:80>
	ServerName test.example.com
	DocumentRoot /var/www/html/public_test
</VirtualHost>
cd /etc/apache2/sites-enabled
ln -s ../virtual_hosts.conf .

Let's Encrypt の設定

sudo certbot --apache -d test.example.com

/etc/apache2/sites-available/virtual_hosts.conf に変更が加えられます。

/etc/apache2/sites-available/virtual_hosts.conf
<VirtualHost *:80>
	ServerName test.example.com
	DocumentRoot /var/www/html/public_test


RewriteEngine on
RewriteCond %{SERVER_NAME} =test.ekample.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

/etc/apache2/sites-available/virtual_hosts-le-ssl.conf が作成されます。

/etc/apache2/sites-enabled/virtual_hosts-le-ssl.conf というシンボリックリンクが作成されます。

ブラウザーで動作の確認
https://test.example.com

参考
Apache2 で VirtualHost を使う

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?