我是用root用户装的

1.先安装PCRE库

可以在这里下载最新版,我这里使用的是8.33的版本然后在终端执行下面的命令。

cd ~/Download 
tar xvzf pcre-8.33.tar.gz 
cd pcre-8.12 
sudo ./configure --prefix=/usr/local 
sudo make 
sudo make install
 
或者更简单的方式:

yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

2.下载安装nginx

首先在nginx官网下载最新的源码,我这里用的是nginx-1.5.2

tar -zvxf nginx-1.5.2.tar.gz 
cd nginx-1.5.2 
./configure  --prefix=/usr/local/nginx
注: nginx默认是安装到/opt目录下,在mac系统中是没有/opt目录的,所以用--prefix指定目标目录

默认编译概要:

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

# 默认编译参数对应的安装路径(*_temp 为目录)
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

为了方便:

sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
sudo ln -s /usr/local/nginx/conf /etc/nginx
sudo ln -s /usr/local/nginx/logs/nginx.pid /var/run/nginx.pid
sudo ln -s /usr/local/nginx/logs /var/log/nginx

或者直接在编译时设定

./configure \
--prefix=/usr/local \
--sbin-path=/usr/local/sbin \
--conf-path=/etc/nginx \
--pid-path=/var/run \
--error-log-path=/var/log/nginx \
--http-log-path=/var/log/nginx

编译参数参考 Nginx InstallOption

3.启动Nginx

检查PATH环境变量

 # ~/.bash_profile export PATH=/usr/local/bin:/usr/local/sbin:$PATH

启动Nginx

 sudo nginx
查看是否启动成功 :在浏览器中输入http://localhost 回车

需要停止Nginx的时候运行

 sudo nginx -s stop

4.配置自启动

创建文件 /System/Library/LaunchDaemons/nginx.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key><string>nginx</string>
    <key>Program</key><string>/usr/local/sbin/nginx</string>
    <key>KeepAlive</key><true/>
    <key>NetworkState</key><true/>
    <key>StandardErrorPath</key><string>/var/log/system.log</string>
    <key>LaunchOnlyOnce</key><true/>
  </dict>
</plist>

载入自启动文件

 launchctl load -F /System/Library/LaunchDaemons/nginx.plist
 

mac 安装 nginx的更多相关文章

  1. mac 安装nginx

    首先准备工作,打开mac终端 1.安装brew  输入命令 curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar x ...

  2. mac 安装 nginx 环境

    1.brew search nginx 2.brew install nginx 启动nginx ,sudo nginx ;访问localhost:8080 发现已出现nginx的欢迎页面了. 备注: ...

  3. Mac安装nginx配置过程

    mac电脑系统重装了,记录一下安装nginx的过程: 1.打开终端 2.安装Command Line tools xcode-select --install 3.安装brew命令 ruby -e & ...

  4. mac 安装nginx,并配置nginx的运行环境

    1. 安装nginx // 查询有没有nginx brew search nginx //开始安装nignx brew install nginx 2. 检查nignx是否安装成功 nginx -V ...

  5. 2019.1.10 Mac安装Nginx服务器

    1.安装Homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/in ...

  6. Mac 安装nginx之后重启、停止、开启等操作

    操作系统:macOs High Sierra 10.13.6 1.我用的homebrew安装的nignx1.15.9,安装完成之后会有下面的提示: 网站根目录在:/usr/local/var/www ...

  7. Mac安装Nginx、Mysql、PHP、Redis

    安装xcode命令行工具的命令 xcode-select --install   安装homebrew: ruby -e "$(curl -fsSL https://raw.githubus ...

  8. mac安装nginx

    1,http://nginx.org/en/download.html下载http://nginx.org/download/nginx-1.2.0.tar.gz 2,tar -xf nginx-1. ...

  9. 《OD大数据实战》mac下安装nginx+php

    一.mac安装nginx + php + php-fpm  或apache + php 1. Mac 下 Nginx.MySQL.PHP-FPM 的安装配置 2. Mac下安装LNMP(Nginx+P ...

随机推荐

  1. 程序运行时间c++/matlab

    前言 一般在调试程序的过程中,需要查看代码运行速度的快慢,此时则需要计算代码的运行时间. 实验过程: c++: #include<iostream> #include<time.h& ...

  2. BZOJ3879: SvT【后缀数组+单调栈】

    Description (我并不想告诉你题目名字是什么鬼) 有一个长度为n的仅包含小写字母的字符串S,下标范围为[1,n]. 现在有若干组询问,对于每一个询问,我们给出若干个后缀(以其在S中出现的起始 ...

  3. HDU 1896:Stones(优先队列)

    Stones Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Sub ...

  4. HDU 4651 数论 partition 求自然数的拆分数

    别人的解题报告: http://blog.csdn.net/zstu_zlj/article/details/9796087 我的代码: #include <cstdio> #define ...

  5. Ubuntu 18.10安装Firefox 和 Google Chrome

    ================================ 工作环境迁移到Linux上,操作系统使用Linux Mint19.1(基于Ubuntu的), 自带的浏览器器是低版本的英文版,现在使用 ...

  6. cglib 简单 代理示例-1

    引用包cglib-xxx.jar非Maven项目还需要手动引用包asm-xxx.jar业务类(不需要定义接口)cglib代理类(实现接口MethodInterceptor) 异常信息(项目只引用了cg ...

  7. 在Spark上通过BulkLoad快速将海量数据导入到Hbase

    我们在<通过BulkLoad快速将海量数据导入到Hbase[Hadoop篇]>文中介绍了一种快速将海量数据导入Hbase的一种方法,而本文将介绍如何在Spark上使用Scala编写快速导入 ...

  8. Bloom Filter(布隆过滤器)的概念和原理

    Bloom filter 适用范围:可以用来实现数据字典,进行数据的判重,或者集合求交集 基本原理及要点: 对于原理来说很简单,位数组+k个独立hash函数.将hash函数对应的值的位数组置1,查找时 ...

  9. c# 模拟POST上传文件到服务器

    using System; using System.Collections; using System.Collections.Generic; using System.Linq; using S ...

  10. Google.ProtocolBuffers.dll 之.Net应用(一)

    原创文章,转载必需注明出处:http://www.cnblogs.com/wu-jian/ http://www.cnblogs.com/wu-jian/archive/2011/02/22/1961 ...