Mac 装nginx

  1. 下载nginx http://nginx.org官网下载
curl -O http://nginx.org/download/nginx-1.12.1.tar.gz
wget 也可以

2.解压nginx文件

tar -zxvf nginx-1.12.1.tar.gz && cd nginx-1.12.1

3.编译nginx

前提是创建相应的文件夹/usr/local/nginx/,为安装目录
./configure --prefix=/usr/local/nginx/
checking for OS
 + Darwin 16.7.0 x86_64
checking for C compiler ... found
 + using Clang C compiler
 + clang version: 9.0.0 (clang-900.0.37)
checking for -Wl,-E switch ... not found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... not found
checking for Darwin specific features
 + kqueue found
checking for kqueue's EVFILT_TIMER ... found
checking for Darwin 64-bit kqueue millisecond timeout bug ... not found
checking for sendfile() ... found
checking for atomic(3) ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for crypt() ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... not found
checking for O_DIRECT ... not found
checking for F_NOCACHE ... found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... not found
checking for IP_TRANSPARENT ... not found
checking for IP_BINDANY ... not found
checking for IP_RECVDSTADDR ... found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... not found
checking for TCP_DEFER_ACCEPT ... not found
checking for TCP_KEEPIDLE ... not found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... not found
checking for accept4() ... not found
checking for eventfd() ... not found
checking for eventfd() (SYS_eventfd) ... not found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... not found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... not found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found but is not working
checking for System V shared memory ... found
checking for POSIX semaphores ... found but is not working
checking for POSIX semaphores in libpthread ... found but is not working
checking for POSIX semaphores in librt ... not found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.

缺少 PCRE库
mac需要装homebrew 来安装库(linux可 直接 yum)

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装Homebrew,时间有点长,成功后可安装 wget 等等需要的东西了

brew install wget   (可忽略)
brew search pcre (用之前搜索下,可以选择你想要的版本)
==> Searching local taps...
pcre ✔                     pcre++                     pcre2
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
因为之前已经装过,所以pcre后有勾
brew install pcre

安装成功后继续执行命令

./configure --prefix=/usr/local/nginx/

如中途有报什么错误就是缺少类库,缺什么 brew install packname(包名)

剩下操作与centos中操作差不多

你可能感兴趣的:(mac)