MacOS 下 Nginx 安装记录

2017-03-21 08:19:54来源:CSDN作者:testcs_dn人点击

之前写过:

CentOS6.5下Nginx1.7.4安装记录

CentOS 6.5 下 Tengine 安装记录

最近工作办公电脑换了 Mac,刚好有机会实践一下。

安装非常简单:

sudo port install nginx
或者使用:

sudo brew install nginx
使用brew可能还需要:

brew search nginx
port 和 brew 是 Mac 下两大包管理工具,使用它们安装软件非常的方便,类似 CentOS下的 yum ,Ubuntu 下的 apt-get 。

安装完成会输出以下提示:我是使用 port 安装的:

nginx has the following notes:    A set of sample configuration files has been installed in /opt/local/share/nginx/examples.        Additionally, the files nginx.conf, mime.types, fastcgi.conf have been copied to /opt/local/etc/nginx if they didn't    exist yet.    Adjust these files to your needs before starting nginx.
查看可执行文件 目录:

which nginx/opt/local/sbin/nginx

/opt/local/share/nginx/examples 目录下是配置示例文件;

/opt/local/etc/nginx 实际使用的配置文件 在这个目录下;

编辑配置&重新加载配置:

sudo vi nginx.conf sudo nginx -s reload
配置文件 示例:我改了下端口和默认文档

#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       88;        server_name  localhost;        #charset koi8-r;        #access_log  logs/host.access.log  main;        location / {            root   share/nginx/html;            index  default.htm 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   share/nginx/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           share/nginx/html;        #    fastcgi_pass   127.0.0.1:9000;        #    fastcgi_index  index.php;        #    include        fastcgi.conf;        #}        # 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   share/nginx/html;    #        index  index.html index.htm;    #    }    #}}

======================文档信息========================

版权声明:非商用自由转载-保持署名-注明出处

署名(BY) :testcs_dn(微wx笑)

文章出处:[无知人生,记录点滴](http://blog.csdn.NET/testcs_dn)

==============欢迎关注我的个人微信订阅号(微wx笑)============

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台