- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2021-07-20T13:59:05+00:00","default:src128","src128")
#author("2021-07-22T23:44:42+00:00","default:src128","src128")
&tag(Ubuntu2004/Apache);
*目次 [#bd7a7de2]
#contents
*関連ページ [#cd557910]
-[[ufw]]
*参考情報 [#p73a52ad]
-[[How to Install Apache Web Server on Ubuntu 20.04:https://www.tecmint.com/install-apache-web-server-on-ubuntu-20-04/]]
*インストール [#a86207b7]
-以下のコマンドを実行
sudo apt install apache2
*設定 [#c871b664]
**ユーザー設定 [#ra5850ec]
-デフォルトのUser、Groupはwww-dataなのでとりあえずそこはそのまま。
**ポート変更 [#p080db8a]
-ポートの変更。/etc/apache2/ports.confを編集。
Listen 7777
-ファイウォールも変更しておくこと。
ufw allow 7777/tcp
**DocumentRootの変更 [#o7e7106d]
-DocumentRootの変更。/etc/apache2/sites-available/000-default.confを編集。
#pre{{
DocumentRoot /home/sora/public_html
<Directory /home/sora/public_html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
}}
** ホスト名をひく [#x70fca10]
-/etc/apache2/apache2.confを編集。
HostnameLookups On
**モジュール [#fd7aff89]
-mod_rewrite
a2enmod rewrite
-http_digest
a2enmod auth_digest
**Let's Encrypt [#g804899f]
***参考情報: [#ldb3ce88]
--[[Ubuntu 20.04でLet’s Encryptを使用してApacheを保護する方法 | DigitalOcean:https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04-ja]]
***インストール [#n9eb56bd]
-事前にVirtualHostの設定をすませておくこと。ドメインごとの設定ファイルがあればよいらしいがなくてもいけた(000-default.confでも)
-cartbotのインストール
sudo apt install certbot python3-certbot-apache
***apacheの設定ファルの確認 [#j3713176]
-/etc/apache2/sites-available/000-default.confにバーチャルホストの設定をすませておくこと。
-certbot実行時にドメインごとに80番にアクセスできることが必要。
***証明書の取得 [#z49ef453]
-以下のコマンドを実行
sudo certbot --apache
-もしくはドメインを指定
sudo certbot --apache -d aaa.com
-実行すると/etc/apache2/sites-available/000-default-le-ssl.confが作成される。
-リダイレクトを許可すると000-default.confのVirtualHostから000-default-le-ssl.confのVirtualHostへのリダイレクトが作成される。
***その他設定 [#q0201a32]
-SSLの許可
sudo ufw allow 443
-自動更新のタイマーを確認
sudo systemctl status certbot.timer
-自動更新のテスト
sudo certbot renew --dry-run
***証明書の確認 [#ica4558d]
-以下のコマンドを実行
sudo certbot certificates
-削除
sudo certbot revoke --cert-name hoge.com
**サブドメインの削除 [#v8810919]
-サブドメインの削除はできない? [[How to remove a sub-domain from the renewal process - Help - Let's Encrypt Community Support:https://community.letsencrypt.org/t/how-to-remove-a-sub-domain-from-the-renewal-process/65426]]
-以下のコマンドで取得しなおせばいいみたい。
#pre{{
sudo certbot --apache --cert-name growthpath.com.au -d growthpath.com.au -d www.growthpath.com.au
}}
-apacheの起動設定を変更するかどうか聞いてくるので変更しないを選ぶ
*管理 [#a0726c3b]
-再起動
sudo systemctl restart apache2
*rbenv環境でPassengerを使う [#s8a555dc]
-必要なパッケージを入れる(ビルドが失敗したら何が必要が教えてくれるが)。
sudo apt install libcurl4-openssl-dev apache2-dev libapr1-dev libaprutil1-dev
-passengerを入れてpassenger-install-apache2-moduleを実行
$ gem install passenger
$ passenger-install-apache2-module
-インストール後表示される情報をメモ。
#pre{{
LoadModule passenger_module /home/sora/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/sora/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.7
PassengerDefaultRuby /home/sora/.rbenv/versions/2.6.6/bin/ruby
</IfModule>
}}
-さらにこれも必要。
#pre{{
<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
}}
-httpd.confの一番したにあるIncludeの上に書くのが正解?