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爸爸會讓你啃老的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章