安装nginx 

1.安装brew命令

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.使用brew 安装nginx

brew install nginx

3.修改配置nginx 文件 (文件应该在 /usr/local/etc/nginx/nginx.conf)

server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /you/web/path; #配置web目录
            #root /usr/local/var/www;
            autoindex on;
            index  index.html index.htm index.php; #添加php默认
        }

(开启PHP支持)修改为如下

location ~ \.php$ {
            root           /you/web/path;
            #root /usr/local/var/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
 }

4.启动nginx

sudo nginx

5.有些情况需要打开,php-fpm 否则会报服务器错误~

sudo php-fpm

 

相关文章:

  • 2021-07-13
  • 2021-08-25
  • 2022-01-12
  • 2021-08-16
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
  • 2021-08-29
猜你喜欢
  • 2021-09-05
  • 2021-12-28
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2019-08-02
  • 2022-01-07
相关资源
相似解决方案