1. 程式人生 > >Mac 裝nginx

Mac 裝nginx

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=<path> 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中操作差不多