質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

Q&A

解決済

3回答

3798閲覧

Let’s Encrypt の導入について Apache2 が起動しなくなった

退会済みユーザー

退会済みユーザー

総合スコア0

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

0グッド

0クリップ

投稿2018/08/14 08:26

編集2018/08/15 05:12

前提・実現したいこと

現在 RaspberryPi3(B)(Raspbian)環境にて Wordpress(最新バージョン)を導入しており,
Wordpressでブログの公開を検討しています.
現在,サイトのhttps化(Let’s Encrypt の導入)について質問があります

なお, https://enoatu.com/?p=1612 こちらのサイトを参照しながら作業して
問題が発生しました

発生している問題・エラーメッセージ

https://enoatu.com/?p=1612
のapache設定まで行ったのですが

$ a2ensite default-ssl
$ a2enmod ssl
$ systemctl restart apache2.service

の最後でエラーコードが生じ,Apache2が再起動できず,起動することができなくなってしまいました.

エラーメッセージ Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

メッセージのとおり
"systemctl status apache2.service" と "journalctl -xe" をそれぞれ参照したところ

ログ "systemctl status apache2.service" apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2018-08-14 17:09:02 JST; 2min 4s ago Process: 2024 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE) 8月 14 17:09:02 raspi systemd[1]: Starting The Apache HTTP Server... 8月 14 17:09:02 raspi apachectl[2024]: AH00526: Syntax error on line 35 of /etc/apache2/sites-enabled/default-ssl.conf: 8月 14 17:09:02 raspi apachectl[2024]: SSLCertificateFile: file '/etc/letsencrypt/live/(私の入力したdomain)/cert.pem' does not exist or 8月 14 17:09:02 raspi apachectl[2024]: Action 'start' failed. 8月 14 17:09:02 raspi apachectl[2024]: The Apache error log may have more information. 8月 14 17:09:02 raspi systemd[1]: apache2.service: Control process exited, code=exited status=1 8月 14 17:09:02 raspi systemd[1]: Failed to start The Apache HTTP Server. 8月 14 17:09:02 raspi systemd[1]: apache2.service: Unit entered failed state. 8月 14 17:09:02 raspi systemd[1]: apache2.service: Failed with result 'exit-code'.
ログ"journalctl -xe" 8月 14 17:10:01 raspi CRON[2078]: (root) CMD (sudo /home/pi/noticeIP.sh) 8月 14 17:10:01 raspi sudo[2079]: root : TTY=unknown ; PWD=/root ; USER=root ; COMMAND=/home/pi/noticeIP.sh 8月 14 17:10:01 raspi sudo[2079]: pam_unix(sudo:session): session opened for user root by (uid=0) 8月 14 17:10:02 raspi sudo[2079]: pam_unix(sudo:session): session closed for user root 8月 14 17:10:02 raspi CRON[2074]: (CRON) info (No MTA installed, discarding output) 8月 14 17:10:02 raspi CRON[2074]: pam_unix(cron:session): session closed for user root 8月 14 17:10:18 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 5 8月 14 17:10:23 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8 8月 14 17:10:31 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 8 8月 14 17:10:39 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 15 8月 14 17:10:54 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 20 8月 14 17:11:14 raspi dhclient[912]: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 5 8月 14 17:11:19 raspi dhclient[912]: No DHCPOFFERS received. 8月 14 17:11:19 raspi dhclient[912]: No working leases in persistent database - sleeping. 8月 14 17:11:35 raspi systemd[1]: Starting Cleanup of Temporary Directories... -- Subject: Unit systemd-tmpfiles-clean.service has begun start-up -- Defined-By: systemd -- Support: https://www.debian.org/support -- -- Unit systemd-tmpfiles-clean.service has begun starting up. 8月 14 17:11:35 raspi systemd[1]: Started Cleanup of Temporary Directories. -- Subject: Unit systemd-tmpfiles-clean.service has finished start-up -- Defined-By: systemd -- Support: https://www.debian.org/support -- -- Unit systemd-tmpfiles-clean.service has finished starting up. -- -- The start-up result is done.

の様です.
前者は素人の私からは
「'/etc/letsencrypt/live/(私の入力したdomain)/cert.pem' does not exist or 」
等からフォルダを確認してみたところそもそもliveフォルダが作成されていないなどが読み取れました.何故作成されてないのか...
(他のログからは何も,さっぱりわからないです...)
後者もやはり具体的に何がいけないかはわからないです...

試したこと

https://enoatu.com/?p=1612 の途中手順にあるapache設定中の

/etc/apache2/sites-available/default-ssl.conf 初期では↓と書かれているところがあるので SSLCertificateFile SSLCertificateKeyFile コメントアウトし、下記を追加。 SSLCertificateFile /etc/letsencrypt/live/[サーバーのドメイン]/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/[サーバーのドメイン]/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/[サーバーのドメイン]/chain.pem

これについて
コメントアウト状況を元に戻してapache2の再起動を図ったが,
再起動はできなかった.(全く同じエラーメッセージ)
この時のログ "systemctl status apache2.service"は以下の通り

ログ "systemctl status apache2.service" Failed to get properties: Unit name apache2.service].service is not valid. root@raspi:/home/pi# systemctl status apache2.service ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2018-08-14 17:20:51 JST; 32s ago Process: 2157 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE) 8月 14 17:20:51 raspi apachectl[2157]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443 8月 14 17:20:51 raspi apachectl[2157]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443 8月 14 17:20:51 raspi apachectl[2157]: no listening sockets available, shutting down 8月 14 17:20:51 raspi apachectl[2157]: AH00015: Unable to open logs 8月 14 17:20:51 raspi apachectl[2157]: Action 'start' failed. 8月 14 17:20:51 raspi apachectl[2157]: The Apache error log may have more information. 8月 14 17:20:51 raspi systemd[1]: apache2.service: Control process exited, code=exited status=1 8月 14 17:20:51 raspi systemd[1]: Failed to start The Apache HTTP Server. 8月 14 17:20:51 raspi systemd[1]: apache2.service: Unit entered failed state. 8月 14 17:20:51 raspi systemd[1]: apache2.service: Failed with result 'exit-code'.

他,Raspberrypi本体の再起動を行ったが起動できず.
知恵を貸していただけないでしょうか...
よろしくお願いします.

2018/08/15 追記1:
先ほど追記点としてCertbotのエラーログについて再度実行して取得するという形でログを掲載しましたが,
・昨日実行時は確認メールアドレスまで聞かれたので明らかに今日のとログ内容が違う
・そもそも再度実行して得られたログに意味があるか?
という理由から削除しました.

SSLなど詳しくなく,前回のCertbotのログも流れてしまっているので
一旦CertBotを削除して,apache2の設定ファイルも手動で書き直し,
まずはApache2自体が以前と同じように動くようにしたほうがいいんでしょうか...

2018/08/15 追記2:
Certbotを消しただけではやはりapache2は再起動できず.(どこか.confファイルを手動で書き直す必要か)
念のため:Certbot削除⇒Certbot導入時に出たログの確認
メールアドレスが聞かれただけで再導入時と導入時で特にログに違いはなさそう
また,ドメイン,ドキュメントルートの記法が違うかもと思い一応情報を記す
WordPressのルートがvar/wwwだから大丈夫だと思っているけど心配なので

以下それぞれ
mydns.jpで登録してる様子,apache2.confのドキュメントルートの記述箇所,
Certbot再導入時のログ
イメージ説明

# Sets the default security model of the Apache2 HTTPD server. It does # not allow access to the root filesystem outside of /usr/share and /var/www. # The former is used by web applications packaged in Debian, # the latter may be used for local directories served by the web server. If # your system is serving content from a sub-directory in /srv you must allow # access here, or in any related virtual host. <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> (ココ) Options Indexes FollowSymLinks AllowOverride None Require all granted #AddHandler .php </Directory> #<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory>
root@raspi:/home/pi# certbot certonly --webroot -w /var/www/ -d raspberrypi422.mydns.jp Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel):kang.dream.123456789@gmail.com ------------------------------------------------------------------------------- Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v01.api.letsencrypt.org/directory ------------------------------------------------------------------------------- (A)gree/(C)ancel: a Obtaining a new certificate Performing the following challenges: http-01 challenge for raspberrypi422.mydns.jp Using the webroot path /var/www for all unmatched domains. Waiting for verification... Cleaning up challenges Failed authorization procedure. raspberrypi422.mydns.jp (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://raspberrypi422.mydns.jp/.well-known/acme-challenge/UFuQsEmfmFEnHAMm8jQS5sMF7ZjEH9Y-qXDZJJ3HH24: Connection refused IMPORTANT NOTES: - If you lose your account credentials, you can recover through e-mails sent to ??????????(適当なメールアドレス) The following errors were reported by the server: Domain: raspberrypi422.mydns.jp Type: connection Detail: Fetching http://raspberrypi422.mydns.jp/.well-known/acme-challenge/UFuQsEmfmFEnHAMm8jQS5sMF7ZjEH9Y-qXDZJJ3HH24: Connection refused To fix these errors, please make sure that your domain name was entered correctly and the DNS A record(s) for that domain contain(s) the right IP address. Additionally, please check that your computer has a publicly routable IP address and that no firewalls are preventing the server from communicating with the client. If you're using the webroot plugin, you should also verify that you are serving files from the webroot path you provided.

何度も何度も編集して申し訳ない...;;

補足情報(FW/ツールのバージョンなど)

・debian ver 9.4
・Apache  Server version: Apache/2.4.25 (Raspbian)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

scsi

2018/08/14 10:20

certbot コマンドが失敗していると思います。
angel_p_57

2018/08/14 16:54

その参考にされたページでは、certbotの実行がサラリと軽く書かれているので、https://letsencrypt.jp/usage/ あたりとも照し合わせてみては。
退会済みユーザー

退会済みユーザー

2018/08/15 01:25

回答ありがとうございます. Debian9.4環境なのですが https://letsencrypt.jp/usage/ のサイトにはdebian9に該当するものがなく,この場合はインストールに失敗したと思しきcertbotをアンインストールし,Debian (その他)の項目を参照して再インストールすべきでしょうか?
angel_p_57

2018/08/15 01:57

ごめんなさい。日本語なのでそのサイトを紹介しましたが、記事の更新日時を見て貰えば分かる通り、情報が最新でない可能性があります。が、正常に実行されたのか何らかエラーが発生したのか判断の参考には使えるかと思いました。現時点では「どうすべきか」よりも「どこに問題があるか」を見る方が良いと思います。( ただ、公式の英語サイトからDebian9の情報を得て、最初からやり直すというのは1つの手だとも思います )
退会済みユーザー

退会済みユーザー

2018/08/15 03:47

なるほど,わかりました. 確かに問題がどこに発生したかを調べることから見ていきたいと思います... 今のところ手掛かりがご教授いただいたそのサイトと後は英語圏の記事を読み探すくらいなので まずその辺から着手してみようと思います
退会済みユーザー

退会済みユーザー

2018/08/15 05:42

Apacheの構文チェックしてください。apache2ctl configtest
退会済みユーザー

退会済みユーザー

2018/08/15 07:23

root@raspi:/home/pi# apache2ctl configtest AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message Syntax OK とでますね...
guest

回答3

0

ベストアンサー

解決しました
以前の環境でドキュメントルートを間違ったとは思ってないんですが,
恐らく証明書発行タイミングでドキュメントルートを間違って記述していたっぽいです
そのあとは通常の挙動通りapache2再起動までできました

投稿2018/09/05 23:22

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

こんにちは
私も先日までletsencrypt関連の問題を抱えておりましたことで、少し気になりましたのでコメントいたします。

「'/etc/letsencrypt/live/(私の入力したdomain)/cert.pem' does not exist or 」
等からフォルダを確認してみたところそもそもliveフォルダが作成されていないなどが読み取れました.何故作成されてないのか...

この/live/ディレクトリが作成されていない状態は、Certbotが正常にインストールされていないと思われます。
参考にされた記事
https://enoatu.com/?p=1612
こちらを確認させていただきましたが、Certbot クライアントをインストールして、Certbotを実行したときにターミナル上の最後の部分が以下の内容で終わっていましたか。

IMPORTANT NOTES:

  • Congratulations! Your certificate and chain have been saved at:
    /etc/letsencrypt/live/[あなたのドメイン]/fullchain.pem
    Your key file has been saved at:
    /etc/letsencrypt/live/[あなたのドメイン]/privkey.pem
    Your cert will expire on 2018-[ここに90日後の日付が記述されている]. To obtain a new or tweaked
    version of this certificate in the future, simply run certbot-auto
    again. To non-interactively renew all of your certificates, run
    "certbot-auto renew"

  • If you like Certbot, please consider supporting our work by:

    Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
    Donating to EFF: https://eff.org/donate-le

これで終わっていなければ、正常にインストールされていません。
その状態でも起動はするはずですが、default-ssl.conf内の修正をされたことが原因で起動しなくなったのではと思われます。

SSLCertificateFile
SSLCertificateKeyFile
などをコメントアウトしたつもりが、別にも同じ記述があってそれらのパスが合わずに起動しない。
などが考えられるので、もしdefault-ssl.confを全く編集する前の状態に戻すことができればそれで再起動してみてはどうかと思います。

上記しましたが、/etc/letsencrypt/live/ このliveというディレクトリが作成されていない状態は、正常にインストールされていません。(経験済み)

また、.confファイル等を編集するときは、編集前に必ずコピーを取ってからがいいと思います。

投稿2018/08/28 14:53

pro88

総合スコア17

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

certbot の認証エラーの原因が書いてあります。

Failed authorization procedure. raspberrypi422.mydns.jp (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://raspberrypi422.mydns.jp/.well-known/acme-challenge/UFuQsEmfmFEnHAMm8jQS5sMF7ZjEH9Y-qXDZJJ3HH24: Connection refused

certbot の認証の仕組みを調べて理解すれば解決できると思いますよ。

アドバイスするには apache DocumentRootなどの情報がほしいですね。

投稿2018/08/16 01:49

scsi

総合スコア2840

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/08/16 08:31

回答ありがとうございます 追記で書き足してあるのですが,Document rootはapache2.confにて # Sets the default security model of the Apache2 HTTPD server. It does # not allow access to the root filesystem outside of /usr/share and /var/www. # The former is used by web applications packaged in Debian, # the latter may be used for local directories served by the web server. If # your system is serving content from a sub-directory in /srv you must allow # access here, or in any related virtual host. <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> <Directory /usr/share> AllowOverride None Require all granted </Directory> <Directory /var/www/> (ここにWordPressが置かれている) Options Indexes FollowSymLinks AllowOverride None Require all granted #AddHandler .php </Directory> #<Directory /srv/> # Options Indexes FollowSymLinks # AllowOverride None # Require all granted #</Directory> このようになっております.(不慣れなもので恐らくここだと思っているのですが...) ちなみに,Cerbot導入前,Wordpressには http://raspberrypi422.mydsn.jp のように入力すると繋がります(今はapache2が稼働していないので繋がりませんが...) ので恐らく間違ってない...?と考えております. 要領を得ていない補足/追記かもしれませんが,何卒よろしくお願いします...
scsi

2018/08/16 12:11

1. a2ensite default-ssl でインストールされたと思われる default-ssl.conf はいらないので /var/tmp などに移動するか削除しましょう。 2. apache2 を起動しましょう。起動しない場合は、他にもいらない設定ファイルなどがないか探してください。 3. certbot を実行しましょう。 certbot -n certonly --webroot -w /var/www/ -d raspberrypi422.mydns.jp -m kang.dream.123456789@gmail.com --agree-tos --server https://acme-v02.api.letsencrypt.org/directory
退会済みユーザー

退会済みユーザー

2018/08/21 18:08

ご無沙汰しています,時間が取れたので再び... scsi様が書いてくださったとおりに1.を行ったうえで2.を実行をしようとしたのですが,起動できませんでした... ystemctl status apache2.service のログの内容も 本文中にある試したこと~に書きましたエラーログと同じエラーログでした. ssl関係のファイルも洗ってみたのですが,かなり多くて皆目見当がつかず,certbotインストールで何に影響が出たのかなどがいまいちつかめていない状況です. 設定ファイルは他には何があるのだろうか?という疑問はここで質問できるので, 質問する前にできることとして,エラーログの内容から解決を考えていたのですが, (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:443 とありますので443ポートのプロセスを確認 pi@raspi:~ $ sudo netstat -apn | grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 644/vpnserver tcp6 0 0 :::443 :::* LISTEN 644/vpnserver unix 2 [ ACC ] SEQPACKET LISTENING 14439 899/bluealsa /var/run/bluealsa/hci0 と出てきたのですが,これはwindowsで立てているVPNサーバーが443ポートを使っているからダメ...?ということなのでしょうか?ただ、certbotを導入前にすでにVPNサーバーは立てていて,その時はapache2も稼働できていましたので原因では無いと思っているのですが...(ちなみに本環境のUFWは443ポートを塞いでなどはしていないです) それか,本環境の何かが443ポートを二回呼び出してる?と考え ssl.confやapache2.conf,ports.confを見てみましてもListen 443の記述が2つ以上あるわけでもなく,全く見当がつかないです...;; だらだらと長文になってしまいましたが,質問の要点としては ・他にcertbotで影響を受け,apache2の起動を妨げている設定ファイルは何か? ・エラーログの一文一文から解決を考えるとして,なぜAH00072: make_sock: could not bind to address [::]:443 ~ 等のエラーログが出ているのだろうか? の2点となります.久しぶりにまた着手した問題で,要領を得た文章/行動になっているかやや心配ですが, よろしくお願いします...
scsi

2018/08/22 00:51

Apacheの設定を隅々まで見直し、ssl関連の設定を無効にすれば起動できると思います。
退会済みユーザー

退会済みユーザー

2018/09/05 16:12

漸くまとまった時間が取れたので... >Apacheの設定を隅々まで見直し、ssl関連の設定を無効にすれば起動できると思います。 これは少し自信がなかったため,raspberrypi環境を一から刷新して またwordpressを外部環境から見れる状態にまで再構築して, scsi様のcommandを入力してみました(command入力前でSDバックアップ保存済み)が, Saving debug log to /var/log/letsencrypt/letsencrypt.log An unexpected error occurred: KeyError: 'Directory field not found' Please see the logfiles in /var/log/letsencrypt for more details. といったエラーログが出てきました 当たり前ではありますが var/wwwのディレクトリ自体はあります また,var/log/letsencryptを参照しようと調べてみたのですが,生成自体がされていませんでした... 時間も大分たち 今更感がありますがよろしくお願いします...
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問