mac下安装nginx笔记

命令行执行:

brew search nginx

会出现:

nginx
homebrew/nginx/accept-language-nginx-module
homebrew/nginx/accesskey-nginx-module
homebrew/nginx/ajp-nginx-module
homebrew/nginx/anti-ddos-nginx-module
homebrew/nginx/array-var-nginx-module
homebrew/nginx/auth-digest-nginx-module
homebrew/nginx/auth-ldap-nginx-module
homebrew/nginx/auth-pam-nginx-module
homebrew/nginx/auto-keepalive-nginx-module
homebrew/nginx/autols-nginx-module
homebrew/nginx/cache-purge-nginx-module
homebrew/nginx/captcha-nginx-module
homebrew/nginx/counter-zone-nginx-module
homebrew/nginx/ctpp2-nginx-module
homebrew/nginx/dav-ext-nginx-module
homebrew/nginx/dosdetector-nginx-module
homebrew/nginx/echo-nginx-module
homebrew/nginx/eval-nginx-module
homebrew/nginx/extended-status-nginx-module
homebrew/nginx/fancyindex-nginx-module
homebrew/nginx/geoip2-nginx-module
homebrew/nginx/headers-more-nginx-module
homebrew/nginx/healthcheck-nginx-module
homebrew/nginx/http-accounting-nginx-module
homebrew/nginx/http-flood-detector-nginx-module
homebrew/nginx/http-remote-passwd-nginx-module
homebrew/nginx/log-if-nginx-module
homebrew/nginx/lua-nginx-module
homebrew/nginx/mod-zip-nginx-module
homebrew/nginx/mogilefs-nginx-module
homebrew/nginx/mp4-h264-nginx-module
homebrew/nginx/mruby-nginx-module
homebrew/nginx/naxsi-nginx-module
homebrew/nginx/nchan-nginx-module
homebrew/nginx/nginx-full
homebrew/nginx/notice-nginx-module
homebrew/nginx/php-session-nginx-module
homebrew/nginx/push-stream-nginx-module
homebrew/nginx/realtime-req-nginx-module
homebrew/nginx/redis-nginx-module
homebrew/nginx/redis2-nginx-module
homebrew/nginx/rtmp-nginx-module
homebrew/nginx/set-misc-nginx-module
homebrew/nginx/small-light-nginx-module
homebrew/nginx/stream-lua-nginx-module
homebrew/nginx/subs-filter-nginx-module
homebrew/nginx/tcp-proxy-nginx-module
homebrew/nginx/txid-nginx-module
homebrew/nginx/unzip-nginx-module
homebrew/nginx/upload-nginx-module
homebrew/nginx/upload-progress-nginx-module
homebrew/nginx/upstream-order-nginx-module
homebrew/nginx/ustats-nginx-module
homebrew/nginx/var-req-speed-nginx-module
homebrew/nginx/vod-nginx-module
homebrew/nginx/websockify-nginx-module
homebrew/nginx/xsltproc-nginx-module

然后执行:

brew install nginx

提示:Error: Cannot write to /usr/local/Cellar

然后更换用 sudo brew install nginx就可以了

==> Installing dependencies for nginx: pcre
==> Installing nginx dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.38.el_capitan.bottle
######################################################################## 100.0%
==> Pouring pcre-8.38.el_capitan.bottle.tar.gz





======= nginx的默认配置=======
#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8080;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #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   html;
        }

        # 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  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

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


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    include servers/*;
}

猜你喜欢

转载自juliana-only.iteye.com/blog/2384278