LoginSignup
0
0

More than 3 years have passed since last update.

Apache 設定後、PHPが動作しない時の対処法

Posted at

PHPが動作しなくなった時の解決方法をメモで記載しました。

環境

macOS Catalina
Apache 2.4.43 (Unix)
PHP バージョン7.2

背景

macにデフォルトであるApacheを停止し、
Homebrew で新たに Apache httpd をインストールして環境を構築したかった。

Apache の設定ファイルをいぢった後、PHPのバージョンを確認したら以下のエラー文で怒られました。

$ php -v 

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

下記URLの記事を参考にして、コマンドを実行しても解決しなかったので別の方法を試しました。

参考記事

Calling `brew switch` is disabled! Use `brew link` @-versioned formulae instead.

解決方法

先ずは Homebrewに悪いところがないか お医者さんに見てもらう。

$ brew doctor

そうすると以下の文章が表示されました。

Some installed formulae are deprecated or disabled. 
・・・
php@7.2

インストールしたformulae(パッケージ)が非推奨もしくは無効らしい。
私の場合、php@7.2 を下記コマンドでアンインストール。

$ brew uninstall php@7.2

インストールするPHPを検索

$ brew search php

そしてインストール

$ brew install php@7.2

インストールしたらパスを通し、紐付ける。

$ export PATH="/usr/local/opt/php@7.2/bin:$PATH
$ brew link php72

意図したバージョンが表示されるか確認

$ php -v

Apache を再起動

$ sudo apachectl restart

ターミナルを再起動すると、動きました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0