Centos+Apache+PHP で .htaccess 導入時のエラーについて
Centos + Apache + PHP で環境構築を設定した際に
.htaccess を書いたらエラー
原因は単純なことでした。
問題について
CentosにApacheとPHPをインストールして index.html が表示できた後で、
.htaccessを入れた際に表示されたエラーがこんな感じ
↓ ↓ ↓ ↓ ↓
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
解決について
.htaccessを導入する前は問題なく動いていたということなので、
1:.htaccess の中に書いてある内容がオカシイ
2:.htaccess に必要なモジュールの実行権限がない
このあたりだと予想。たぶん1だけど。
ということで、Apacheの httpd.conf を見てみると、
♯LoadModule rewrite_module modules/mod_rewrite.so
となっていた。
これのコメントアウトを外せばOK
(Apache再起動も忘れずに)
ちなみにエラーログをみるとちゃんとありますので
似たようなエラーの際は必ずチェックしましょう
[Sun Oct 02 06:36:01.926266 2016] [core:alert] [pid 3422:tid 140211212248832] [client 192.168.33.1:61031] /usr/local/apache2/vhosts/.local.yukibata.com/htdocs/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
おわり