2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

macにbrewでnginxとPHP7.2をインストールした

Posted at

インストール

nginxのインストール
brew install nginx

※以下のメッセージを探す。ドキュメントルート(ファイルを置く場所)と設定ファイルの場所。
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080

phpのインストール
brew install php72

設定変更

設定変更
/usr/local/etc/nginx/nginx.conf

変更前

nginx.conf
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

変更後

nginx.conf
        location ~ \.php$ {
            root           /usr/local/var/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/var/www$fastcgi_script_name;
            include        fastcgi_params;
        }

起動

起動
nginxの起動
brew services start nginx

phpの起動
brew services start php@7.2

動作確認

以下のURLにアクセスする
http://127.0.0.1:8080/

停止

nginxの停止
nginx -s stop

phpの停止
brew services stop php@7.2

参考

新しいmacにbrewを使ってnginxをインストールする
https://qiita.com/amemolee/items/56332100f182088687cf
CentOS + nginx + PHP環境でのnginxの設定めも
https://qiita.com/alegriaghost/items/57f99539a3554b4fbd80

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?