2.

ctl.sh httpd could not be started の原因と対処法完全ガイド

編集
この記事の要点
  • Bitnami / XAMPP の ctl.sh start「httpd could not be started」 が出るエラー
  • 原因 5 大: ポート 80/443 競合(Skype / IIS / 別 Apache)/ httpd.conf 構文エラー / SELinux/AppArmor / ファイル権限 / SSL 証明書パスミス
  • 切り分け 1: ctl.sh start apache verbose で詳細ログを見る
  • 切り分け 2: netstat -tlnp | grep :80 でポート競合確認
  • 切り分け 3: httpd -t(または apachectl configtest)で構文チェック
  • 対処: Bitnami の change-port ツールでポート変更、競合プロセス停止、conf 修正

エラーの全体像

Bitnami WAMP / LAMP スタックや XAMPP の起動スクリプトで頻出するエラーです。具体的なメッセージ:

$ ./ctlscript.sh start apache
/opt/bitnami/apache2/scripts/ctl.sh : httpd could not be started

Monitored apache

「Apache を起動しようとしたが、起動できなかった」という以上の情報がなく、原因が見えづらいのが厄介な点。実際は裏で動いている httpdが何らかの理由で起動拒否しています。

原因の切り分けフロー

確認コマンド
1詳細ログ./ctlscript.sh start apache verbose
2Apache エラーログtail -100 /opt/bitnami/apache2/logs/error_log
3ポート競合sudo netstat -tlnp | grep -E ':80|:443'
4conf 構文/opt/bitnami/apache2/bin/httpd -t
5SSL 鍵存在ls -la /opt/bitnami/apache2/conf/bitnami/certs/
6SELinux 状態getenforce
7権限ls -la /opt/bitnami/apache2/logs/

対処 1: ポート競合(最多)

80 / 443 を既に他のプロセスが使っていると Apache は起動できません。最頻出のケース:

  • Windows: IIS(World Wide Web Publishing Service)、Skype(古いバージョン)、Microsoft Web Deployment Agent
  • Linux: 既にインストール済みの 別 Apache / NginxTomcat(8080)
  • VPN ソフト / Hyper-V の予約ポート
# Linux: 80 を使っているプロセスを特定
sudo netstat -tlnp | grep :80
# tcp  0  0 0.0.0.0:80  0.0.0.0:*  LISTEN  1234/nginx

# 同じく ss(推奨)
sudo ss -tlnp | grep :80

# 競合プロセスを停止
sudo systemctl stop nginx
# または
sudo kill 1234
# Windows: 80 を使っているプロセス
netstat -ano | findstr :80
# TCP  0.0.0.0:80  0.0.0.0:0  LISTENING  4

# PID 4 は通常 System(IIS / HTTP.sys)
# IIS 停止
net stop W3SVC
net stop WAS

# HTTP.sys 自体を停止(ポート開放)
net stop http /y

# 別 Apache を停止
net stop Apache2.4

ポート変更で回避(Bitnami 推奨手順)

競合プロセスを止められない場合は、Bitnami 側を別ポート(8080 / 8443 等)に変更:

# Bitnami change-port ツール
cd /opt/bitnami
sudo ./bnconfig --apache_default_http_port 8080
sudo ./bnconfig --apache_default_https_port 8443

# 古い Bitnami の場合
sudo ./ctlscript.sh stop
sudo /opt/bitnami/configure.sh
# → 対話で新ポートを指定
sudo ./ctlscript.sh start

対処 2: httpd.conf 構文エラー

conf ファイルを編集した直後の起動失敗はほぼこれ。エラーログに行番号が出るので修正は容易:

# 構文チェック
/opt/bitnami/apache2/bin/httpd -t \
    -f /opt/bitnami/apache2/conf/httpd.conf
# → Syntax OK が出れば conf は問題なし
# → 出ない場合、ファイル名と行番号付きでエラー

# エラーログを確認
tail -50 /opt/bitnami/apache2/logs/error_log

# 例:
# AH00526: Syntax error on line 145 of httpd.conf:
#   Invalid command 'RewriteEngine', perhaps misspelled or
#   defined by a module not included in the server configuration
# → mod_rewrite が LoadModule されていない

対処 3: SSL 証明書パスエラー

HTTPS 対応中の編集ミスでよく発生:

AH02572: Failed to configure at least one certificate and key for example.com:443
SSL Library Error: error:0200100D:system library:fopen:Permission denied
SSL Library Error: error:20074002:BIO routines:file_ctrl:system lib
SSL Library Error: error:140AB10C:SSL routines:SSL_CTX_use_certificate:not pem
# 証明書ファイルの存在と権限を確認
ls -la /opt/bitnami/apache2/conf/bitnami/certs/
# -rw-r----- 1 root daemon ... server.crt
# -rw-r----- 1 root daemon ... server.key

# Apache 実行ユーザから読めるか
sudo -u daemon cat /opt/bitnami/apache2/conf/bitnami/certs/server.key

# 証明書の中身チェック(PEM 形式か)
openssl x509 -in server.crt -text -noout
openssl rsa  -in server.key -check

# パスを httpd.conf / bitnami.conf で指定
grep -r "SSLCertificateFile" /opt/bitnami/apache2/conf/

対処 4: SELinux / AppArmor

RHEL 系で SELinux が enforcing だと、Apache が conf やログを読めずに起動失敗することがあります:

# SELinux 状態確認
getenforce
# Enforcing → 厳格
# Permissive → 警告のみ
# Disabled → 無効

# 一時的に Permissive に
sudo setenforce 0
sudo ./ctlscript.sh start apache
# 起動できたら SELinux が原因確定

# 永続的に切り替え(推奨は適切なラベル付け)
sudo vi /etc/selinux/config
# SELINUX=permissive

# 適切なラベル付けで再有効化(推奨)
sudo chcon -R --type=httpd_sys_content_t /opt/bitnami/apache2/htdocs
sudo setsebool -P httpd_can_network_connect on

対処 5: ファイル権限

# ログディレクトリ書き込み権限
ls -la /opt/bitnami/apache2/logs/
# daemon ユーザが書ける必要あり

sudo chown -R daemon:daemon /opt/bitnami/apache2/logs/
sudo chmod -R u+rw /opt/bitnami/apache2/logs/

# pid ファイルの場所
ls -la /opt/bitnami/apache2/logs/httpd.pid
# 古い pid が残っている場合は削除
sudo rm /opt/bitnami/apache2/logs/httpd.pid

verbose 起動でリアルログを見る

# 詳細ログ付き起動
./ctlscript.sh start apache verbose

# それでもダメなら httpd を直接フォアグラウンド起動
sudo /opt/bitnami/apache2/bin/httpd -X \
    -f /opt/bitnami/apache2/conf/httpd.conf

# -X はシングルプロセスでフォアグラウンド実行
# エラーが標準エラーに直接出る

典型的なエラーメッセージと対処

error_log メッセージ原因対処
AH00072: make_sock: could not bind to address 0.0.0.0:80ポート競合 or 権限不足競合プロセス停止 or ポート変更
AH00526: Syntax error on line Nconf 構文エラー該当行を修正、httpd -t
AH02572: Failed to configure at least one certificateSSL 鍵問題パス・権限・形式を確認
Permission denied: AH00091: could not open error logログ書込権限所有者・権限修正
AH00112: Warning: DocumentRoot does not existDocumentRoot パス間違いパス修正 or ディレクトリ作成

FAQ

Q: 「httpd could not be started」しか出ず何も分からない
A: ctlscript.sh start apache verbose または httpd -X で直接起動するのが鉄則。Bitnami のラッパが詳細を隠しています。

Q: Skype を入れた途端に動かなくなった
A: 古い Skype は 80/443 を予約してしまうため。Skype の設定 → 詳細 → 接続 で「80 と 443 をポートに使う」を OFF にして再起動。新しい Skype は問題なし。

Q: 再起動するたびに同じエラー
A: 起動時に競合プロセスが先に上がっている可能性。systemctl list-unit-files | grep -E 'httpd|nginx' で自動起動を確認し、不要なら disable

編集
Post Share
子ページ

子ページはありません

同階層のページ
  1. rake aborted! PG::ConnectionBad: FATAL: Ident authentication failed for user "redmine"
  2. ctl.sh : httpd could not be started