#安装php8.0
brew install php@8.0 
echo 'export PATH="/opt/homebrew/opt/php@8.0/bin:$PATH"' >> ~/.zshrc //添加环境变量
echo 'export PATH="/opt/homebrew/opt/php@8.0/sbin:$PATH"' >> ~/.zshrc //添加环境变量

#php-fpm和php-cgi文件目录
/opt/homebrew/Cellar/php@8.0/8.0.18/bin
#php配置文件目录
/opt/homebrew/etc/php/8.0
#安装nginx
brew install nginx 

#默认的网站目录
/opt/homebrew/var/www 
#nginx配置文件
/opt/homebrew/etc/nginx/nginx.conf

#nginx文件目录
/opt/homebrew/Cellar/nginx/1.21.6_1

#启动php-fpm和nginx
php-fpm
nginx
#nginx命令
nginx   //启动默认端口和默认配置文件
nginx -s stop  //停止
nginx -c xx.conf //加载指定配置文件

nginx配置文件

events {

}
http{
 
    server {
        listen   127.0.0.1:8000;     # 端口
        include mime.types; 
        #listen   8000;     # 端口
        #server_name  www.fund-admin.com;  # 域名
        index index.php index.html index.htm default.php default.htm default.html;
        root   "/Users/x/Documents/code/thinkphp/public"; # 项目地址

        #伪静态
        location / {
            if (!-e $request_filename){
                rewrite  ^(.*)$  /index.php?s=$1  last;   break;
            }
        }
        
        #禁止访问的文件或目录
        location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
        {
            return 404;
        }    

        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
  

}
}

最后更新于 2023-03-03