mac 配置nginx

安装nginx

brew install nginx

      配置目录:/usr/local/etc/nginx

      日志目录:/usr/local/var/log

fpm 命令

sudo lsof -i:端口        查看端口号 

sudo kill -9 进程号      杀进程

sudo php-fpm             启动php-fpm

nginx 命令

sudo nginx           启动nginx

ps -ef|grep nginx    查看nginx的进程

nginx -s reload      重启nginx

nginx -s stop        关闭nginx

nginx搭建多站点示例配置

user lmf staff; #用户名 和数组
worker_processes  8;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8084;
        server_name  localhost:8084;
        location / {
            root   /Users/lmf/Desktop/mfweb/public;
            index  index.html index.htm index.php;
            try_files uriuri/ /index.php?$query_string;
        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root   html;
        }

        location ~ .*\.(js|css|png|woff2|ttf)$ {
            # 静态文件返回路径
            root /Users/lmf/Desktop/mfweb/public ;
        }

        location ~ \.php$ {
           root           /Users/lmf/Desktop/mfweb/public;
           fastcgi_pass   127.0.0.1:9001;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }

    }

    server {

        listen       8085;
        server_name  localhost:8085;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location / {
            root  /Users/lmf/Desktop/mfpush;
            index  index.php index.html index.htm;

            #因为是ci框架 重写去除index.php
            if (!-e $request_filename){
               rewrite  ^(.*)$  /index.php?s=$1  last;  
              break;
            }
            autoindex on;
        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root  html;
        }

        location ~ \.php$ {
           root           /Users/lmf/Desktop/mfpush;
           fastcgi_pass   127.0.0.1:9001;
           fastcgi_index  index.php;
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }

    }
    include servers/*;
}

配置成功后就可以进行更深一步的反向代理什么的了

mac系统真的恶心 我之前用apache,也对nginx接触的不深,配置环境恶心,任重而道远,吾将上下而求索

我发誓,下次购入笔记本绝对不是mac,windows不香吗?云服务器不香?还是太年轻,最后补充一点,脑子放开一些,多实践,baidu爸爸和Google爸爸会让你啃老的

发布了45 篇原创文章 · 获赞 3 · 访问量 7118

猜你喜欢

转载自blog.csdn.net/qq_38228582/article/details/103064070
今日推荐