Apache-2.2

httpd reload 作為 bash 中的第二個命令失敗

  • February 10, 2016

我正在嘗試執行一個執行一項操作的命令,以更新證書,然後重新載入 Apache。

為此,我正在執行以下命令:

sudo /home/ec2-user/letsencrypt/letsencrypt-auto --config 
/home/ec2-user/letsencrypt/cert.ini certonly --debug 
&& service httpd reload

這給了我以下資訊:

Updating letsencrypt and virtual environment dependencies......
Requesting root privileges to run with virtualenv:  /root/.local/share/letsencrypt/bin/letsencrypt --config /home/ec2-user/letsencrypt/secure_textinconfidence_com.ini certonly --debug
Version: 1.1-20080819
Version: 1.1-20080819

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
  /etc/letsencrypt/live/secure.textinconfidence.com/fullchain.pem.
  Your cert will expire on 2016-05-03. To obtain a new version of the
  certificate in the future, simply run Let's Encrypt again.
- If you like Let's Encrypt, please consider supporting our work by:

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

Reloading httpd: not reloading due to configuration syntax error
                                                  [FAILED]

但是,當我執行時:

sudo service httpd configtest

我得到:

Syntax OK

與證書續訂結合使用時,我的命令有問題嗎?

正如@chicks 所說,shell 正在解釋 && 部分而沒有 sudo 這樣做:

sudo /home/ec2-user/letsencrypt/letsencrypt-auto --config 
/home/ec2-user/letsencrypt/cert.ini certonly --debug 
&& sudo service httpd reload

對問題進行排序

引用自:https://serverfault.com/questions/754984