MAC 通过brew 安装Nginx+Php7.3

MAC 通过brew 安装Nginx+Php7.3

安装Nginx

brew  install nginx

查看安装路径: nginx -V(大写)

nginx -V

开启nginx:

 cd /usr/local/Cellar/nginx/1.17.8/bin
 ./nginx

关闭nginx

 ./nginx -s stop

1.2 安装PHP

 brew install php@7.3

查看php版本

➜  magento230_shoes git:(master) php -v
PHP 7.3.14 (cli) (built: Jan 24 2020 03:06:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.14, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.14, Copyright (c) 1999-2018, by Zend Technologies
➜  magento230_shoes git:(master)

启动

 brew services start php@7.3
      Service `php@7.3` already started, use `brew services restart php@7.3` to restart.

停止php7.3

 brew services stop php@7.3
Stopping `php@7.3`... (might take a while)
==> Successfully stopped `php@7.3` (label: homebrew.mxcl.php@7.3)

重新启动:

   ➜  /  brew services restart php@7.3
      Stopping `php@7.3`... (might take a while)
      ==> Successfully stopped `php@7.3` (label: homebrew.mxcl.php@7.3)
      ==> Successfully started `php@7.3` (label: homebrew.mxcl.php@7.3)
      ➜  /

Nginx和PHP-FPM结合

nginx -V
nginx配置目录,nginx配置相关的文件都在这个目录:/usr/local/etc/nginx/nginx.conf
访问日志路径:/usr/local/var/log/nginx/access.log
错误日志路径:/usr/local/var/log/nginx/error.log
默认服务器根目录:/usr/local/var/www

备份配置文件 cp nginx.conf nginx.back.conf
修改nginx.conf 配置
vim nginx.conf
测试php动态脚本:
1.配置文件语法检测
nginx -t

2.配置index.php默认首页的优选级
  location / {
    index index.php index.html
  }
Nginx支持PHP程序:
  location ~ \.php$ {
    fastcgi_index index.php;
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注