Mac安装nginx+php-fpm

第一步:安装brew

访问地址:
https://brew.sh/


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

第二步:安装nginx

brew install nginx

第三步:配置hosts

127.0.0.1       augu.xiaocx.my
127.0.0.1       xdf.xiaocx.my
127.0.0.1       wtk.xiaocx.my

第四步: 配置 Nginx文件夹下的,xdf.com.conf

server {
    listen       80;
    server_name  xdf.xiaocx.my;
    root         /Users/jihaichuan/Work/2018/xdf2/api;

    index        index.php index.html index.htm;

    client_max_body_size 20m;
    fastcgi_read_timeout 600;


    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";



    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
    #    root   /var/www/smallcx;
    #    index  index.html index.htm;
        if (!-e $request_filename) {
              rewrite  ^(.*)$  /index.php?s=$1  last;
              break;
        }
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        #root   /var/www/www.xiaocx.org;
    }

    location @rewrite {
        rewrite ^ /index.php;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # 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  $document_root$fastcgi_script_name;
        include        fastcgi_params;


        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
             set $real_script_name $1;
             set $path_info $2;
        }
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

第五步: 配置php-fpm

vim /etc/php-fpm.d/www.conf

#把user打开,改成
user=nginx

第六步: 修改nginx.conf 文件目前权限

# jihaichuan 是当前用户
# staff 属于用户组
user jihaichuan staff;

第七步:批量修改文件所属组

#nginx目前所属权限
chown jihaichuan:staff /usr/local/etc/nginx

#项目源代码所属权限
chown jihaichuan:staff /Work/2018

第八步: 重启Nginx 、PHP-fpm

#nginx
sudo nginx -t
sudo nginx -s reload


#php-fpm  我记得这个好想是通过杀死进程来处理的

猜你喜欢

转载自my.oschina.net/u/575762/blog/1635559
今日推荐