1. 개요
Linux에서는 yum install하여 Nginx를 쉽게 설치할 수 있는데 직접 소스를 컴파일하여 설치해 보려고 합니다.
가장 최신 안정(stable) 버전인 1.4.5를 받아서 컴파일을 하였습니다.
2. configure
# ./configure --prefix=/home/nginx checking for OS + Linux 2.6.32-279.el6.x86_64 x86_64 checking for C compiler ... found + using GNU C compiler + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) checking for gcc -pipe switch ... found checking for gcc builtin atomic operations ... found checking for C99 variadic macros ... found checking for gcc variadic macros ... found checking for unistd.h ... found checking for inttypes.h ... found checking for limits.h ... found checking for sys/filio.h ... not found checking for sys/param.h ... found checking for sys/mount.h ... found checking for sys/statvfs.h ... found checking for crypt.h ... found checking for Linux specific features checking for epoll ... found checking for sendfile() ... found checking for sendfile64() ... found checking for sys/prctl.h ... found checking for prctl(PR_SET_DUMPABLE) ... found checking for sched_setaffinity() ... found checking for crypt_r() ... found checking for sys/vfs.h ... found checking for nobody group ... found checking for poll() ... found checking for /dev/poll ... not found checking for kqueue ... not found checking for crypt() ... not found checking for crypt() in libcrypt ... found checking for F_READAHEAD ... not found checking for posix_fadvise() ... found checking for O_DIRECT ... found checking for F_NOCACHE ... not found checking for directio() ... not found checking for statfs() ... found checking for statvfs() ... found checking for dlopen() ... not found checking for dlopen() in libdl ... found checking for sched_yield() ... found checking for SO_SETFIB ... not found checking for SO_ACCEPTFILTER ... not found checking for TCP_DEFER_ACCEPT ... found checking for TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT ... found checking for TCP_INFO ... found checking for accept4() ... 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 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 setproctitle() ... not found checking for pread() ... found checking for pwrite() ... found checking for sys_nerr ... found checking for localtime_r() ... found checking for posix_memalign() ... found checking for memalign() ... found checking for mmap(MAP_ANON|MAP_SHARED) ... found checking for mmap("/dev/zero", MAP_SHARED) ... found checking for System V shared memory ... found checking for POSIX semaphores ... not found checking for POSIX semaphores in libpthread ... 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 ... not 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 라이브러리 에러가 발생하여, yum install pcre로 pcre 설치를 하고
다시 configure를 실행하였습니다. 하지만 계속 같은 에러가 발생합니다.
그런데 검색을 해보니 pcre-devel을 추가로 설치해야 한다는 것 같습니다.
# yum install pcre-devel Loaded plugins: fastestmirror, refresh-packagekit Loading mirror speeds from cached hostfile * base: ftp.daum.net * extras: ftp.daum.net * updates: ftp.daum.net Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:7.8-6.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================ Installing: pcre-devel x86_64 7.8-6.el6 base 318 k Transaction Summary ============================================================================================================================================ Install 1 Package(s) Total download size: 318 k Installed size: 954 k Is this ok [y/N]: y Downloading Packages: pcre-devel-7.8-6.el6.x86_64.rpm | 318 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : pcre-devel-7.8-6.el6.x86_64 1/1 Unable to connect to dbus Verifying : pcre-devel-7.8-6.el6.x86_64 1/1 Installed: pcre-devel.x86_64 0:7.8-6.el6 Complete!
과연 이제 될지 모르겠습니다. 다시 configure 를 해보았습니다.
<생략>
creating objs/Makefile 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 nginx path prefix: "/home/nginx" nginx binary file: "/home/nginx/sbin/nginx" nginx configuration prefix: "/home/nginx/conf" nginx configuration file: "/home/nginx/conf/nginx.conf" nginx pid file: "/home/nginx/logs/nginx.pid" nginx error log file: "/home/nginx/logs/error.log" nginx http access log file: "/home/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"
pcre-devel 설치 후에 configure 성공하였네요.
<추가>
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
위와 같이 zlib 관련하여 오류 발생 시 zlib-devel도 설치하세요.
3. make
make[1]: Leaving directory `/down/nginx/nginx-1.4.5' make -f objs/Makefile manpage make[1]: Entering directory `/down/nginx/nginx-1.4.5' sed -e "s|%%PREFIX%%|/home/nginx|" \ -e "s|%%PID_PATH%%|/home/nginx/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/home/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/home/nginx/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/down/nginx/nginx-1.4.5'
make 도 오래 걸리지 않았습니다.
# make install make -f objs/Makefile install make[1]: Entering directory `/down/nginx/nginx-1.4.5' test -d '/home/nginx' || mkdir -p '/home/nginx' test -d '/home/nginx/sbin' || mkdir -p '/home/nginx/sbin' test ! -f '/home/nginx/sbin/nginx' || mv '/home/nginx/sbin/nginx' '/home/nginx/sbin/nginx.old' cp objs/nginx '/home/nginx/sbin/nginx' test -d '/home/nginx/conf' || mkdir -p '/home/nginx/conf' cp conf/koi-win '/home/nginx/conf' cp conf/koi-utf '/home/nginx/conf' cp conf/win-utf '/home/nginx/conf' test -f '/home/nginx/conf/mime.types' || cp conf/mime.types '/home/nginx/conf' cp conf/mime.types '/home/nginx/conf/mime.types.default' test -f '/home/nginx/conf/fastcgi_params' || cp conf/fastcgi_params '/home/nginx/conf' cp conf/fastcgi_params '/home/nginx/conf/fastcgi_params.default' test -f '/home/nginx/conf/fastcgi.conf' || cp conf/fastcgi.conf '/home/nginx/conf' cp conf/fastcgi.conf '/home/nginx/conf/fastcgi.conf.default' test -f '/home/nginx/conf/uwsgi_params' || cp conf/uwsgi_params '/home/nginx/conf' cp conf/uwsgi_params '/home/nginx/conf/uwsgi_params.default' test -f '/home/nginx/conf/scgi_params' || cp conf/scgi_params '/home/nginx/conf' cp conf/scgi_params '/home/nginx/conf/scgi_params.default' test -f '/home/nginx/conf/nginx.conf' || cp conf/nginx.conf '/home/nginx/conf/nginx.conf' cp conf/nginx.conf '/home/nginx/conf/nginx.conf.default' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' test -d '/home/nginx/html' || cp -R html '/home/nginx' test -d '/home/nginx/logs' || mkdir -p '/home/nginx/logs' make[1]: Leaving directory `/down/nginx/nginx-1.4.5'
make install 까지 잘 끝났습니다.
주의 사항