CentOSにnginxをソースからインストールしてみたメモ。

下書きのまま埋もれてました。なのでnginxのバージョンがちょっと古いです。実際にやったのはたぶん2011年の5月ごろかも。

作業の流れ

  1. ソースコードを入手
  2. ./configureして足りないライブラリを確認
  3. 足りないライブラリをインストール
  4. configureで生成されたMakefileを確認しておく
  5. ./configure --helpを確認
  6. 必要なconfigureオプションをつけて./configure
  7. make; sudo make install

気になった事

  • --prefixを指定しない場合のデフォルト値は/usr/localとは限らない。nginxの場合は/usr/local/nginxだった。
  • wiki.nginx.orgから入手した起動スクリプトには/etc/sysconfig/nginxが書かれてるけど、インストールでファイルは生成されなかった。
  • configureオプションで--lock-pathを指定しなかったけど/var/lock/subsys/nginxにロックファイルがあった。たぶん起動スクリプトlockfile=/var/lock/subsys/nginxと書いてあるからだと思う。configureオプションのとどっちが優先されるんだろう?
  • nginxというユーザー/グループを作ろうかと思ったけど、一般ユーザーと混ざったUIDになるのも嫌だったから、nginxのデフォルトでもあるnobodyを使った。

作業ログ

$ curl -LO http://nginx.org/download/nginx-1.0.2.tar.gz
$ tar xzvf nginx-1.0.2.tar.gz
$ cd nginx-1.0.2

tarballをダウンロードしてインストール作業開始。

まずは./configure

$ ./configure
checking for OS
 + Linux 2.6.18-238.9.1.el5 x86_64
checking for C compiler ... 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 accept4() ... not 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.

とりあえず./configureしてみました。どうやらPCREライブラリというのが足りない様子。

他にもnot foundがあった
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for F_READAHEAD ... not found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for dlopen() ... not found
checking for SO_SETFIB ... not found
checking for accept4() ... not found

ログを見返して気がついたけど、他にもありました。not foundだった行だけ抜粋。でも、上記のログの通り、ライブラリが足りない的な事は出てなかったのでスルーしてました。

PCREライブラリのインストール

$ yum list | grep pcre
pcre.i386                                  6.6-6.el5_6.1               installed
pcre.x86_64                                6.6-6.el5_6.1               installed
pcre-devel.i386                            6.6-6.el5_6.1               updates
pcre-devel.x86_64                          6.6-6.el5_6.1               updates
$ sudo yum install pcre-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: ftp.isu.edu.tw
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.i386 0:6.6-6.el5_6.1 set to be updated
---> Package pcre-devel.x86_64 0:6.6-6.el5_6.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                      Arch                     Version                          Repository                 Size
========================================================================================================================
Installing:
 pcre-devel                   i386                     6.6-6.el5_6.1                    updates                   181 k
 pcre-devel                   x86_64                   6.6-6.el5_6.1                    updates                   184 k

Transaction Summary
========================================================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 365 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): pcre-devel-6.6-6.el5_6.1.i386.rpm                                                         | 181 kB     00:00
(2/2): pcre-devel-6.6-6.el5_6.1.x86_64.rpm                                                       | 184 kB     00:00
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   198 kB/s | 365 kB     00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : pcre-devel                                                                                       1/2
  Installing     : pcre-devel                                                                                       2/2

Installed:
  pcre-devel.i386 0:6.6-6.el5_6.1                           pcre-devel.x86_64 0:6.6-6.el5_6.1

Complete!

pcreはinstalledなので、たぶんこっちだろうという事でpcre-develをインストール。

./configureが通るか確認

$ make clean
rm -rf Makefile objs

まずはさっきの./configureで出来たごみを消しておきます。

$ ./configure
checking for OS
 + Linux 2.6.18-238.9.1.el5 x86_64
checking for C compiler ... 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 accept4() ... not found
checking for PCRE library ... found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... found
checking for zlib library ... found
creating objs/Makefile
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 endianess ... little endianess
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 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

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

  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"

今度は./configureが通りました。最後にパス等のデフォルト値を表示してくれます。前述のnot foundは変わらず出てるみたいですが、作業中は気がつかなかったし、特にインストール指示も出てないのでスルー。

Makefile

$ cat Makefile

default:        build

clean:
        rm -rf Makefile objs

build:
        $(MAKE) -f objs/Makefile
        $(MAKE) -f objs/Makefile manpage

install:
        $(MAKE) -f objs/Makefile install

upgrade:
        /usr/local/nginx/sbin/nginx -t

        kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
        sleep 1
        test -f /usr/local/nginx/logs/nginx.pid.oldbin

        kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

出来あがったMakefileはこんな感じです。

./configureオプションを指定

$ make clean
rm -rf Makefile objs

$ cat configured
./configure \
--with-http_ssl_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module
$ ./configured
checking for OS
 + Linux 2.6.18-238.9.1.el5 x86_64
checking for C compiler ... found
checking for gcc builtin atomic operations ... found
以下略

make; sudo make install

$ make
make -f objs/Makefile
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' に入ります
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/nginx.o \
                src/core/nginx.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_log.o \
                src/core/ngx_log.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_palloc.o \
                src/core/ngx_palloc.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_array.o \
                src/core/ngx_array.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_list.o \
                src/core/ngx_list.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_hash.o \
                src/core/ngx_hash.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_buf.o \
                src/core/ngx_buf.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_queue.o \
                src/core/ngx_queue.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_output_chain.o \
                src/core/ngx_output_chain.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_string.o \
                src/core/ngx_string.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_parse.o \
                src/core/ngx_parse.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_inet.o \
                src/core/ngx_inet.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_file.o \
                src/core/ngx_file.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_crc32.o \
                src/core/ngx_crc32.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_murmurhash.o \
                src/core/ngx_murmurhash.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_md5.o \
                src/core/ngx_md5.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_rbtree.o \
                src/core/ngx_rbtree.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_radix_tree.o \
                src/core/ngx_radix_tree.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_slab.o \
                src/core/ngx_slab.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_times.o \
                src/core/ngx_times.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_shmtx.o \
                src/core/ngx_shmtx.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_connection.o \
                src/core/ngx_connection.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_cycle.o \
                src/core/ngx_cycle.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_spinlock.o \
                src/core/ngx_spinlock.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_cpuinfo.o \
                src/core/ngx_cpuinfo.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_conf_file.o \
                src/core/ngx_conf_file.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_resolver.o \
                src/core/ngx_resolver.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_open_file_cache.o \
                src/core/ngx_open_file_cache.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event.o \
                src/event/ngx_event.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_timer.o \
                src/event/ngx_event_timer.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_posted.o \
                src/event/ngx_event_posted.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_busy_lock.o \
                src/event/ngx_event_busy_lock.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_accept.o \
                src/event/ngx_event_accept.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_connect.o \
                src/event/ngx_event_connect.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_pipe.o \
                src/event/ngx_event_pipe.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_time.o \
                src/os/unix/ngx_time.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_errno.o \
                src/os/unix/ngx_errno.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_alloc.o \
                src/os/unix/ngx_alloc.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_files.o \
                src/os/unix/ngx_files.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_socket.o \
                src/os/unix/ngx_socket.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_recv.o \
                src/os/unix/ngx_recv.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_readv_chain.o \
                src/os/unix/ngx_readv_chain.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_udp_recv.o \
                src/os/unix/ngx_udp_recv.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_send.o \
                src/os/unix/ngx_send.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_writev_chain.o \
                src/os/unix/ngx_writev_chain.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_channel.o \
                src/os/unix/ngx_channel.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_shmem.o \
                src/os/unix/ngx_shmem.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_process.o \
                src/os/unix/ngx_process.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_daemon.o \
                src/os/unix/ngx_daemon.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_setproctitle.o \
                src/os/unix/ngx_setproctitle.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_posix_init.o \
                src/os/unix/ngx_posix_init.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_user.o \
                src/os/unix/ngx_user.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_process_cycle.o \
                src/os/unix/ngx_process_cycle.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_linux_init.o \
                src/os/unix/ngx_linux_init.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/modules/ngx_epoll_module.o \
                src/event/modules/ngx_epoll_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/os/unix/ngx_linux_sendfile_chain.o \
                src/os/unix/ngx_linux_sendfile_chain.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/event/ngx_event_openssl.o \
                src/event/ngx_event_openssl.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/src/core/ngx_regex.o \
                src/core/ngx_regex.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http.o \
                src/http/ngx_http.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_core_module.o \
                src/http/ngx_http_core_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_special_response.o \
                src/http/ngx_http_special_response.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_request.o \
                src/http/ngx_http_request.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_parse.o \
                src/http/ngx_http_parse.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_header_filter_module.o \
                src/http/ngx_http_header_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_write_filter_module.o \
                src/http/ngx_http_write_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_copy_filter_module.o \
                src/http/ngx_http_copy_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_log_module.o \
                src/http/modules/ngx_http_log_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_request_body.o \
                src/http/ngx_http_request_body.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_variables.o \
                src/http/ngx_http_variables.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_script.o \
                src/http/ngx_http_script.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_upstream.o \
                src/http/ngx_http_upstream.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_upstream_round_robin.o \
                src/http/ngx_http_upstream_round_robin.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_parse_time.o \
                src/http/ngx_http_parse_time.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_static_module.o \
                src/http/modules/ngx_http_static_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_index_module.o \
                src/http/modules/ngx_http_index_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_chunked_filter_module.o \
                src/http/modules/ngx_http_chunked_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_range_filter_module.o \
                src/http/modules/ngx_http_range_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_headers_filter_module.o \
                src/http/modules/ngx_http_headers_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_not_modified_filter_module.o \
                src/http/modules/ngx_http_not_modified_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_busy_lock.o \
                src/http/ngx_http_busy_lock.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_file_cache.o \
                src/http/ngx_http_file_cache.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_gzip_filter_module.o \
                src/http/modules/ngx_http_gzip_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/ngx_http_postpone_filter_module.o \
                src/http/ngx_http_postpone_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_ssi_filter_module.o \
                src/http/modules/ngx_http_ssi_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_charset_filter_module.o \
                src/http/modules/ngx_http_charset_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_sub_filter_module.o \
                src/http/modules/ngx_http_sub_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_addition_filter_module.o \
                src/http/modules/ngx_http_addition_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_userid_filter_module.o \
                src/http/modules/ngx_http_userid_filter_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_gzip_static_module.o \
                src/http/modules/ngx_http_gzip_static_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_autoindex_module.o \
                src/http/modules/ngx_http_autoindex_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_random_index_module.o \
                src/http/modules/ngx_http_random_index_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_auth_basic_module.o \
                src/http/modules/ngx_http_auth_basic_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_access_module.o \
                src/http/modules/ngx_http_access_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_limit_zone_module.o \
                src/http/modules/ngx_http_limit_zone_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_limit_req_module.o \
                src/http/modules/ngx_http_limit_req_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_geo_module.o \
                src/http/modules/ngx_http_geo_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_map_module.o \
                src/http/modules/ngx_http_map_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_split_clients_module.o \
                src/http/modules/ngx_http_split_clients_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_referer_module.o \
                src/http/modules/ngx_http_referer_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_rewrite_module.o \
                src/http/modules/ngx_http_rewrite_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_ssl_module.o \
                src/http/modules/ngx_http_ssl_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_proxy_module.o \
                src/http/modules/ngx_http_proxy_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_fastcgi_module.o \
                src/http/modules/ngx_http_fastcgi_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_uwsgi_module.o \
                src/http/modules/ngx_http_uwsgi_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_scgi_module.o \
                src/http/modules/ngx_http_scgi_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_memcached_module.o \
                src/http/modules/ngx_http_memcached_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_empty_gif_module.o \
                src/http/modules/ngx_http_empty_gif_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_browser_module.o \
                src/http/modules/ngx_http_browser_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_secure_link_module.o \
                src/http/modules/ngx_http_secure_link_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
                src/http/modules/ngx_http_upstream_ip_hash_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
                -o objs/src/http/modules/ngx_http_stub_status_module.o \
                src/http/modules/ngx_http_stub_status_module.c
gcc -c  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
                -o objs/ngx_modules.o \
                objs/ngx_modules.c
gcc -o objs/nginx \
        objs/src/core/nginx.o \
        objs/src/core/ngx_log.o \
        objs/src/core/ngx_palloc.o \
        objs/src/core/ngx_array.o \
        objs/src/core/ngx_list.o \
        objs/src/core/ngx_hash.o \
        objs/src/core/ngx_buf.o \
        objs/src/core/ngx_queue.o \
        objs/src/core/ngx_output_chain.o \
        objs/src/core/ngx_string.o \
        objs/src/core/ngx_parse.o \
        objs/src/core/ngx_inet.o \
        objs/src/core/ngx_file.o \
        objs/src/core/ngx_crc32.o \
        objs/src/core/ngx_murmurhash.o \
        objs/src/core/ngx_md5.o \
        objs/src/core/ngx_rbtree.o \
        objs/src/core/ngx_radix_tree.o \
        objs/src/core/ngx_slab.o \
        objs/src/core/ngx_times.o \
        objs/src/core/ngx_shmtx.o \
        objs/src/core/ngx_connection.o \
        objs/src/core/ngx_cycle.o \
        objs/src/core/ngx_spinlock.o \
        objs/src/core/ngx_cpuinfo.o \
        objs/src/core/ngx_conf_file.o \
        objs/src/core/ngx_resolver.o \
        objs/src/core/ngx_open_file_cache.o \
        objs/src/event/ngx_event.o \
        objs/src/event/ngx_event_timer.o \
        objs/src/event/ngx_event_posted.o \
        objs/src/event/ngx_event_busy_lock.o \
        objs/src/event/ngx_event_accept.o \
        objs/src/event/ngx_event_connect.o \
        objs/src/event/ngx_event_pipe.o \
        objs/src/os/unix/ngx_time.o \
        objs/src/os/unix/ngx_errno.o \
        objs/src/os/unix/ngx_alloc.o \
        objs/src/os/unix/ngx_files.o \
        objs/src/os/unix/ngx_socket.o \
        objs/src/os/unix/ngx_recv.o \
        objs/src/os/unix/ngx_readv_chain.o \
        objs/src/os/unix/ngx_udp_recv.o \
        objs/src/os/unix/ngx_send.o \
        objs/src/os/unix/ngx_writev_chain.o \
        objs/src/os/unix/ngx_channel.o \
        objs/src/os/unix/ngx_shmem.o \
        objs/src/os/unix/ngx_process.o \
        objs/src/os/unix/ngx_daemon.o \
        objs/src/os/unix/ngx_setproctitle.o \
        objs/src/os/unix/ngx_posix_init.o \
        objs/src/os/unix/ngx_user.o \
        objs/src/os/unix/ngx_process_cycle.o \
        objs/src/os/unix/ngx_linux_init.o \
        objs/src/event/modules/ngx_epoll_module.o \
        objs/src/os/unix/ngx_linux_sendfile_chain.o \
        objs/src/event/ngx_event_openssl.o \
        objs/src/core/ngx_regex.o \
        objs/src/http/ngx_http.o \
        objs/src/http/ngx_http_core_module.o \
        objs/src/http/ngx_http_special_response.o \
        objs/src/http/ngx_http_request.o \
        objs/src/http/ngx_http_parse.o \
        objs/src/http/ngx_http_header_filter_module.o \
        objs/src/http/ngx_http_write_filter_module.o \
        objs/src/http/ngx_http_copy_filter_module.o \
        objs/src/http/modules/ngx_http_log_module.o \
        objs/src/http/ngx_http_request_body.o \
        objs/src/http/ngx_http_variables.o \
        objs/src/http/ngx_http_script.o \
        objs/src/http/ngx_http_upstream.o \
        objs/src/http/ngx_http_upstream_round_robin.o \
        objs/src/http/ngx_http_parse_time.o \
        objs/src/http/modules/ngx_http_static_module.o \
        objs/src/http/modules/ngx_http_index_module.o \
        objs/src/http/modules/ngx_http_chunked_filter_module.o \
        objs/src/http/modules/ngx_http_range_filter_module.o \
        objs/src/http/modules/ngx_http_headers_filter_module.o \
        objs/src/http/modules/ngx_http_not_modified_filter_module.o \
        objs/src/http/ngx_http_busy_lock.o \
        objs/src/http/ngx_http_file_cache.o \
        objs/src/http/modules/ngx_http_gzip_filter_module.o \
        objs/src/http/ngx_http_postpone_filter_module.o \
        objs/src/http/modules/ngx_http_ssi_filter_module.o \
        objs/src/http/modules/ngx_http_charset_filter_module.o \
        objs/src/http/modules/ngx_http_sub_filter_module.o \
        objs/src/http/modules/ngx_http_addition_filter_module.o \
        objs/src/http/modules/ngx_http_userid_filter_module.o \
        objs/src/http/modules/ngx_http_gzip_static_module.o \
        objs/src/http/modules/ngx_http_autoindex_module.o \
        objs/src/http/modules/ngx_http_random_index_module.o \
        objs/src/http/modules/ngx_http_auth_basic_module.o \
        objs/src/http/modules/ngx_http_access_module.o \
        objs/src/http/modules/ngx_http_limit_zone_module.o \
        objs/src/http/modules/ngx_http_limit_req_module.o \
        objs/src/http/modules/ngx_http_geo_module.o \
        objs/src/http/modules/ngx_http_map_module.o \
        objs/src/http/modules/ngx_http_split_clients_module.o \
        objs/src/http/modules/ngx_http_referer_module.o \
        objs/src/http/modules/ngx_http_rewrite_module.o \
        objs/src/http/modules/ngx_http_ssl_module.o \
        objs/src/http/modules/ngx_http_proxy_module.o \
        objs/src/http/modules/ngx_http_fastcgi_module.o \
        objs/src/http/modules/ngx_http_uwsgi_module.o \
        objs/src/http/modules/ngx_http_scgi_module.o \
        objs/src/http/modules/ngx_http_memcached_module.o \
        objs/src/http/modules/ngx_http_empty_gif_module.o \
        objs/src/http/modules/ngx_http_browser_module.o \
        objs/src/http/modules/ngx_http_secure_link_module.o \
        objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
        objs/src/http/modules/ngx_http_stub_status_module.o \
        objs/ngx_modules.o \
        -lcrypt -lpcre -lssl -lcrypto -ldl -lz
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' から出ます
make -f objs/Makefile manpage
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' に入ります
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
                -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
                -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
                -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
                < man/nginx.8 > objs/nginx.8
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' から出ます

$ sudo make install
make -f objs/Makefile install
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' に入ります
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin'                 || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx'                 || mv '/usr/local/nginx/sbin/nginx'                     '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf'                 || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types'              || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params'          || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params          '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf'            || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params'            || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params            '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params'             || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params             '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf'              || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs'                 || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html'                 || cp -r html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' ||              mkdir -p '/usr/local/nginx/logs'
make[1]: ディレクトリ `/home/myuser/nginx-1.0.2' から出ます

シンボリックリンクを作成

$ sudo ln -s /usr/local/nginx/conf/ /etc/nginx
$ sudo ln -s /usr/local/nginx/logs/ /var/log/nginx

今回、パス関係はconfigureオプションで指定せず、デフォルトのままで入れました。設定ファイルとログが分かりにくいので、シンボリックリンクを作っておきました。

configure

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/subsys/nginx.lock --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module
Nginx のソースからインストール - ARCHIVESDRIVE HD

ただ、シンボリックリンクを作るくらいなら、このエントリーの様に、全部パスを適切なとこに指定したほうがよかったかも。

起動スクリプト

$ cat /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
   # make required directories
   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
   for opt in $options; do
       if [ `echo $opt | grep '.*-temp-path'` ]; then
           value=`echo $opt | cut -d "=" -f 2`
           if [ ! -d "$value" ]; then
               # echo "creating" $value
               mkdir -p $value && chown -R $user $value
           fi
       fi
   done
}

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    make_dirs
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    sleep 1
    start
}

reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

$ sudo chmod ugo+x /etc/init.d/nginx

http://wiki.nginx.org/RedHatNginxInitScript
このスクリプトをベースに、主にパスを調節。

環境

CentOS CentOS release 5.6
nginx 1.0.2