nginxのソースビルドでのインストール
nginxの動作確認環境の構築手順を記述する。
目次
nginxのソースビルドでのインストール
1.インストール
GCCのインストール
[root@Ruby ~]# yum install gcc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-18.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-18.el6 for package: gcc-4.4.7-18.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-18.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-18.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-18.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-18.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-18.el6 will be an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
gcc x86_64 4.4.7-18.el6 base 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
cpp x86_64 4.4.7-18.el6 base 3.7 M
mpfr x86_64 2.4.1-6.el6 base 157 k
ppl x86_64 0.10.2-11.el6 base 1.3 M
Updating for dependencies:
libgcc x86_64 4.4.7-18.el6 base 103 k
libgomp x86_64 4.4.7-18.el6 base 134 k
Transaction Summary
=======================================================================
Install 5 Package(s)
Upgrade 2 Package(s)
Total download size: 16 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/7): cpp-4.4.7-18.el6.x86_64.rpm | 3.7 MB 00:00
(3/7): gcc-4.4.7-18.el6.x86_64.rpm | 10 MB 00:00
(4/7): libgcc-4.4.7-18.el6.x86_64.rpm | 103 kB 00:00
(5/7): libgomp-4.4.7-18.el6.x86_64.rpm | 134 kB 00:00
(6/7): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00
(7/7): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00
-----------------------------------------------------------------------
Total 8.6 MB/s | 16 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc-4.4.7-18.el6.x86_64 1/9
Installing : ppl-0.10.2-11.el6.x86_64 2/9
Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 3/9
Installing : mpfr-2.4.1-6.el6.x86_64 4/9
Installing : cpp-4.4.7-18.el6.x86_64 5/9
Updating : libgomp-4.4.7-18.el6.x86_64 6/9
Installing : gcc-4.4.7-18.el6.x86_64 7/9
Cleanup : libgcc-4.4.7-4.el6.x86_64 8/9
Cleanup : libgomp-4.4.7-4.el6.x86_64 9/9
Verifying : cpp-4.4.7-18.el6.x86_64 1/9
Verifying : libgomp-4.4.7-18.el6.x86_64 2/9
Verifying : mpfr-2.4.1-6.el6.x86_64 3/9
Verifying : gcc-4.4.7-18.el6.x86_64 4/9
Verifying : ppl-0.10.2-11.el6.x86_64 5/9
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 6/9
Verifying : libgcc-4.4.7-18.el6.x86_64 7/9
Verifying : libgomp-4.4.7-4.el6.x86_64 8/9
Verifying : libgcc-4.4.7-4.el6.x86_64 9/9
Installed:
gcc.x86_64 0:4.4.7-18.el6
Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-18.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6
Dependency Updated:
libgcc.x86_64 0:4.4.7-18.el6 libgomp.x86_64 0:4.4.7-18.el6
Complete!
PCRE(perl互換の正規表現ライブラリ)のインストール
[root@Ruby ~]# yum install pcre pcre-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pcre.x86_64 0:7.8-6.el6 will be updated
---> Package pcre.x86_64 0:7.8-7.el6 will be an update
---> Package pcre-devel.x86_64 0:7.8-7.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
pcre-devel x86_64 7.8-7.el6 base 320 k
Updating:
pcre x86_64 7.8-7.el6 base 196 k
Transaction Summary
=======================================================================
Install 1 Package(s)
Upgrade 1 Package(s)
Total download size: 516 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): pcre-7.8-7.el6.x86_64.rpm | 196 kB 00:00
(2/2): pcre-devel-7.8-7.el6.x86_64.rpm | 320 kB 00:00
-----------------------------------------------------------------------
Total 3.6 MB/s | 516 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : pcre-7.8-7.el6.x86_64 1/3
Installing : pcre-devel-7.8-7.el6.x86_64 2/3
Cleanup : pcre-7.8-6.el6.x86_64 3/3
Verifying : pcre-7.8-7.el6.x86_64 1/3
Verifying : pcre-devel-7.8-7.el6.x86_64 2/3
Verifying : pcre-7.8-6.el6.x86_64 3/3
Installed:
pcre-devel.x86_64 0:7.8-7.el6
Updated:
pcre.x86_64 0:7.8-7.el6
Complete!
zlibのインストール
[root@Ruby ~]# yum install zlib zlib-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Package zlib-1.2.3-29.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
zlib-devel x86_64 1.2.3-29.el6 base 44 k
Transaction Summary
=======================================================================
Install 1 Package(s)
Total download size: 44 k
Installed size: 115 k
Is this ok [y/N]: y
Downloading Packages:
zlib-devel-1.2.3-29.el6.x86_64.rpm | 44 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : zlib-devel-1.2.3-29.el6.x86_64 1/1
Verifying : zlib-devel-1.2.3-29.el6.x86_64 1/1
Installed:
zlib-devel.x86_64 0:1.2.3-29.el6
Complete!
OpenSSLのインストール
[root@Ruby ~]# yum install openssl openssl-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssl.x86_64 0:1.0.1e-15.el6 will be updated
---> Package openssl.x86_64 0:1.0.1e-57.el6 will be an update
---> Package openssl-devel.x86_64 0:1.0.1e-57.el6 will be installed
--> Processing Dependency: krb5-devel for package: openssl-devel-1.0.1e-57.el6.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.10.3-65.el6 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.10.3-65.el6 for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: krb5-libs = 1.10.3-65.el6 for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.10.3-65.el6.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.4-5.el6 will be installed
--> Processing Dependency: keyutils-libs = 1.4-5.el6 for package: keyutils-libs-devel-1.4-5.el6.x86_64
---> Package krb5-libs.x86_64 0:1.10.3-10.el6_4.6 will be updated
--> Processing Dependency: krb5-libs = 1.10.3-10.el6_4.6 for package: krb5-workstation-1.10.3-10.el6_4.6.x86_64
---> Package krb5-libs.x86_64 0:1.10.3-65.el6 will be an update
---> Package libcom_err-devel.x86_64 0:1.41.12-23.el6 will be installed
--> Processing Dependency: libcom_err = 1.41.12-23.el6 for package: libcom_err-devel-1.41.12-23.el6.x86_64
---> Package libkadm5.x86_64 0:1.10.3-65.el6 will be installed
---> Package libselinux-devel.x86_64 0:2.0.94-7.el6 will be installed
--> Processing Dependency: libselinux = 2.0.94-7.el6 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: libsepol-devel >= 2.0.32-1 for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.0.94-7.el6.x86_64
--> Running transaction check
---> Package keyutils-libs.x86_64 0:1.4-4.el6 will be updated
--> Processing Dependency: keyutils-libs = 1.4-4.el6 for package: keyutils-1.4-4.el6.x86_64
---> Package keyutils-libs.x86_64 0:1.4-5.el6 will be an update
---> Package krb5-workstation.x86_64 0:1.10.3-10.el6_4.6 will be updated
---> Package krb5-workstation.x86_64 0:1.10.3-65.el6 will be an update
---> Package libcom_err.x86_64 0:1.41.12-18.el6 will be updated
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-libs-1.41.12-18.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: libss-1.41.12-18.el6.x86_64
--> Processing Dependency: libcom_err = 1.41.12-18.el6 for package: e2fsprogs-1.41.12-18.el6.x86_64
---> Package libcom_err.x86_64 0:1.41.12-23.el6 will be an update
---> Package libselinux.x86_64 0:2.0.94-5.3.el6_4.1 will be updated
--> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-python-2.0.94-5.3.el6_4.1.x86_64
--> Processing Dependency: libselinux = 2.0.94-5.3.el6_4.1 for package: libselinux-utils-2.0.94-5.3.el6_4.1.x86_64
---> Package libselinux.x86_64 0:2.0.94-7.el6 will be an update
---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be installed
--> Running transaction check
---> Package e2fsprogs.x86_64 0:1.41.12-18.el6 will be updated
---> Package e2fsprogs.x86_64 0:1.41.12-23.el6 will be an update
---> Package e2fsprogs-libs.x86_64 0:1.41.12-18.el6 will be updated
---> Package e2fsprogs-libs.x86_64 0:1.41.12-23.el6 will be an update
---> Package keyutils.x86_64 0:1.4-4.el6 will be updated
---> Package keyutils.x86_64 0:1.4-5.el6 will be an update
---> Package libselinux-python.x86_64 0:2.0.94-5.3.el6_4.1 will be updated
---> Package libselinux-python.x86_64 0:2.0.94-7.el6 will be an update
---> Package libselinux-utils.x86_64 0:2.0.94-5.3.el6_4.1 will be updated
---> Package libselinux-utils.x86_64 0:2.0.94-7.el6 will be an update
---> Package libss.x86_64 0:1.41.12-18.el6 will be updated
---> Package libss.x86_64 0:1.41.12-23.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================
Package Arch Version Repository Size
=======================================================================
Installing:
openssl-devel x86_64 1.0.1e-57.el6 base 1.2 M
Updating:
openssl x86_64 1.0.1e-57.el6 base 1.5 M
Installing for dependencies:
keyutils-libs-devel x86_64 1.4-5.el6 base 29 k
krb5-devel x86_64 1.10.3-65.el6 base 504 k
libcom_err-devel x86_64 1.41.12-23.el6 base 33 k
libkadm5 x86_64 1.10.3-65.el6 base 143 k
libselinux-devel x86_64 2.0.94-7.el6 base 137 k
libsepol-devel x86_64 2.0.41-4.el6 base 64 k
Updating for dependencies:
e2fsprogs x86_64 1.41.12-23.el6 base 554 k
e2fsprogs-libs x86_64 1.41.12-23.el6 base 121 k
keyutils x86_64 1.4-5.el6 base 39 k
keyutils-libs x86_64 1.4-5.el6 base 20 k
krb5-libs x86_64 1.10.3-65.el6 base 675 k
krb5-workstation x86_64 1.10.3-65.el6 base 814 k
libcom_err x86_64 1.41.12-23.el6 base 38 k
libselinux x86_64 2.0.94-7.el6 base 109 k
libselinux-python x86_64 2.0.94-7.el6 base 203 k
libselinux-utils x86_64 2.0.94-7.el6 base 82 k
libss x86_64 1.41.12-23.el6 base 42 k
Transaction Summary
=======================================================================
Install 7 Package(s)
Upgrade 12 Package(s)
Total download size: 6.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/19): e2fsprogs-1.41.12-23.el6.x86_64.rpm | 554 kB 00:00
(2/19): e2fsprogs-libs-1.41.12-23.el6.x86_64.rpm | 121 kB 00:00
(3/19): keyutils-1.4-5.el6.x86_64.rpm | 39 kB 00:00
(4/19): keyutils-libs-1.4-5.el6.x86_64.rpm | 20 kB 00:00
(5/19): keyutils-libs-devel-1.4-5.el6.x86_64.rpm | 29 kB 00:00
(6/19): krb5-devel-1.10.3-65.el6.x86_64.rpm | 504 kB 00:00
(7/19): krb5-libs-1.10.3-65.el6.x86_64.rpm | 675 kB 00:00
(8/19): krb5-workstation-1.10.3-65.el6.x86_64.rpm | 814 kB 00:00
(9/19): libcom_err-1.41.12-23.el6.x86_64.rpm | 38 kB 00:00
(10/19): libcom_err-devel-1.41.12-23.el6.x86_64.rpm | 33 kB 00:00
(11/19): libkadm5-1.10.3-65.el6.x86_64.rpm | 143 kB 00:00
(12/19): libselinux-2.0.94-7.el6.x86_64.rpm | 109 kB 00:00
(13/19): libselinux-devel-2.0.94-7.el6.x86_64.rpm | 137 kB 00:00
(14/19): libselinux-python-2.0.94-7.el6.x86_64.rpm | 203 kB 00:00
(15/19): libselinux-utils-2.0.94-7.el6.x86_64.rpm | 82 kB 00:00
(16/19): libsepol-devel-2.0.41-4.el6.x86_64.rpm | 64 kB 00:00
(17/19): libss-1.41.12-23.el6.x86_64.rpm | 42 kB 00:00
(18/19): openssl-1.0.1e-57.el6.x86_64.rpm | 1.5 MB 00:00
(19/19): openssl-devel-1.0.1e-57.el6.x86_64.rpm | 1.2 MB 00:00
-----------------------------------------------------------------------
Total 4.5 MB/s | 6.2 MB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libcom_err-1.41.12-23.el6.x86_64 1/31
Updating : libselinux-2.0.94-7.el6.x86_64 2/31
Updating : keyutils-libs-1.4-5.el6.x86_64 3/31
Updating : krb5-libs-1.10.3-65.el6.x86_64 4/31
Installing : libkadm5-1.10.3-65.el6.x86_64 5/31
Updating : libss-1.41.12-23.el6.x86_64 6/31
Updating : openssl-1.0.1e-57.el6.x86_64 7/31
Installing : keyutils-libs-devel-1.4-5.el6.x86_64 8/31
Updating : e2fsprogs-libs-1.41.12-23.el6.x86_64 9/31
Installing : libcom_err-devel-1.41.12-23.el6.x86_64 10/31
Installing : libsepol-devel-2.0.41-4.el6.x86_64 11/31
Installing : libselinux-devel-2.0.94-7.el6.x86_64 12/31
Installing : krb5-devel-1.10.3-65.el6.x86_64 13/31
Installing : openssl-devel-1.0.1e-57.el6.x86_64 14/31
Updating : e2fsprogs-1.41.12-23.el6.x86_64 15/31
Updating : krb5-workstation-1.10.3-65.el6.x86_64 16/31
Updating : keyutils-1.4-5.el6.x86_64 17/31
Updating : libselinux-python-2.0.94-7.el6.x86_64 18/31
Updating : libselinux-utils-2.0.94-7.el6.x86_64 19/31
Cleanup : krb5-workstation-1.10.3-10.el6_4.6.x86_64 20/31
Cleanup : e2fsprogs-1.41.12-18.el6.x86_64 21/31
Cleanup : openssl-1.0.1e-15.el6.x86_64 22/31
Cleanup : krb5-libs-1.10.3-10.el6_4.6.x86_64 23/31
Cleanup : e2fsprogs-libs-1.41.12-18.el6.x86_64 24/31
Cleanup : libss-1.41.12-18.el6.x86_64 25/31
Cleanup : libselinux-utils-2.0.94-5.3.el6_4.1.x86_64 26/31
Cleanup : libselinux-python-2.0.94-5.3.el6_4.1.x86_64 27/31
Cleanup : keyutils-1.4-4.el6.x86_64 28/31
Cleanup : keyutils-libs-1.4-4.el6.x86_64 29/31
Cleanup : libselinux-2.0.94-5.3.el6_4.1.x86_64 30/31
Cleanup : libcom_err-1.41.12-18.el6.x86_64 31/31
Verifying : e2fsprogs-1.41.12-23.el6.x86_64 1/31
Verifying : krb5-devel-1.10.3-65.el6.x86_64 2/31
Verifying : libcom_err-1.41.12-23.el6.x86_64 3/31
Verifying : krb5-libs-1.10.3-65.el6.x86_64 4/31
Verifying : e2fsprogs-libs-1.41.12-23.el6.x86_64 5/31
Verifying : krb5-workstation-1.10.3-65.el6.x86_64 6/31
Verifying : keyutils-libs-devel-1.4-5.el6.x86_64 7/31
Verifying : libcom_err-devel-1.41.12-23.el6.x86_64 8/31
Verifying : keyutils-libs-1.4-5.el6.x86_64 9/31
Verifying : openssl-devel-1.0.1e-57.el6.x86_64 10/31
Verifying : keyutils-1.4-5.el6.x86_64 11/31
Verifying : libselinux-python-2.0.94-7.el6.x86_64 12/31
Verifying : libss-1.41.12-23.el6.x86_64 13/31
Verifying : libsepol-devel-2.0.41-4.el6.x86_64 14/31
Verifying : libselinux-utils-2.0.94-7.el6.x86_64 15/31
Verifying : openssl-1.0.1e-57.el6.x86_64 16/31
Verifying : libkadm5-1.10.3-65.el6.x86_64 17/31
Verifying : libselinux-2.0.94-7.el6.x86_64 18/31
Verifying : libselinux-devel-2.0.94-7.el6.x86_64 19/31
Verifying : e2fsprogs-1.41.12-18.el6.x86_64 20/31
Verifying : libselinux-2.0.94-5.3.el6_4.1.x86_64 21/31
Verifying : openssl-1.0.1e-15.el6.x86_64 22/31
Verifying : libselinux-utils-2.0.94-5.3.el6_4.1.x86_64 23/31
Verifying : libss-1.41.12-18.el6.x86_64 24/31
Verifying : libcom_err-1.41.12-18.el6.x86_64 25/31
Verifying : e2fsprogs-libs-1.41.12-18.el6.x86_64 26/31
Verifying : libselinux-python-2.0.94-5.3.el6_4.1.x86_64 27/31
Verifying : keyutils-libs-1.4-4.el6.x86_64 28/31
Verifying : krb5-libs-1.10.3-10.el6_4.6.x86_64 29/31
Verifying : keyutils-1.4-4.el6.x86_64 30/31
Verifying : krb5-workstation-1.10.3-10.el6_4.6.x86_64 31/31
Installed:
openssl-devel.x86_64 0:1.0.1e-57.el6
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.4-5.el6 krb5-devel.x86_64 0:1.10.3-65.el6 libcom_err-devel.x86_64 0:1.41.12-23.el6 libkadm5.x86_64 0:1.10.3-65.el6 libselinux-devel.x86_64 0:2.0.94-7.el6
libsepol-devel.x86_64 0:2.0.41-4.el6
Updated:
openssl.x86_64 0:1.0.1e-57.el6
Dependency Updated:
e2fsprogs.x86_64 0:1.41.12-23.el6 e2fsprogs-libs.x86_64 0:1.41.12-23.el6 keyutils.x86_64 0:1.4-5.el6 keyutils-libs.x86_64 0:1.4-5.el6 krb5-libs.x86_64 0:1.10.3-65.el6
krb5-workstation.x86_64 0:1.10.3-65.el6 libcom_err.x86_64 0:1.41.12-23.el6 libselinux.x86_64 0:2.0.94-7.el6 libselinux-python.x86_64 0:2.0.94-7.el6 libselinux-utils.x86_64 0:2.0.94-7.el6
libss.x86_64 0:1.41.12-23.el6
Complete!
2.設定
Nginx用ユーザの作成
[root@Ruby ~]# useradd --shell /sbin/nologin nginx
Nginxソースコードのダウンロード
[root@Ruby ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
--2017-10-18 14:09:52-- http://nginx.org/download/nginx-1.12.2.tar.gz
nginx.org をDNSに問いあわせています... 95.211.80.227, 206.251.255.63
nginx.org|95.211.80.227|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 981687 (959K) [application/octet-stream]
`nginx-1.12.2.tar.gz' に保存中
100%[=================================================>] 981,687 432K/s 時間 2.2s
2017-10-18 14:09:55 (432 KB/s) - `nginx-1.12.2.tar.gz' へ保存完了 [981687/981687]
tar.gzの展開
[root@Ruby ~]# tar xvzf nginx-1.12.2.tar.gz
ソースコードのビルド
[root@Ruby ~]# cd nginx-1.12.2
[root@Ruby nginx-1.12.2]# ./configure --with-http_ssl_module --with-http_realip_module
checking for OS
+ Linux 2.6.32-431.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-18) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... 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 ... 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 EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... not found
checking for O_PATH ... not 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 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_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 ... found
checking for IP_BINDANY ... not found
checking for IP_RECVDSTADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... not found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... 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() ... 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 ... found
checking for PCRE JIT support ... not found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
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"
[root@Ruby nginx-1.12.2]# make
make -f objs/Makefile
make[1]: ディレクトリ `/root/nginx-1.12.2' に入ります
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -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
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
-o objs/src/core/ngx_buf.o \
・
・
・
・
objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
objs/src/http/modules/ngx_http_upstream_least_conn_module.o \
objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
objs/src/http/modules/ngx_http_upstream_zone_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz \
-Wl,-E
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]: ディレクトリ `/root/nginx-1.12.2' から出ます
[root@Ruby nginx-1.12.2]# make install
make -f objs/Makefile install
make[1]: ディレクトリ `/root/nginx-1.12.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]: ディレクトリ `/root/nginx-1.12.2' から出ます
設定ファイルの修正
[root@Ruby nginx-1.12.2]# cat /usr/local/nginx/conf/nginx.conf
#user nobody;
user nginx nginx;
worker_processes 1; #ワーカプロセスの起動数(一般にCPUコア数と同じにするとよい)
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024; #ワーカプロセスのトータルコネクション数(ワーカプロセスが増えた場合に注意:要OSチューニング:ulimit -a:open files)
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on; #ファイル読み込みとレスポンスにsendfileシステムコールが使われる:パフォーマンスが良い
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
起動スクリプトの作成
[root@Ruby nginx-1.12.2]# cat /etc/init.d/nginx
#!/bin/sh
#
# nginx Startup script for nginx
#
# chkconfig: - 85 15
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# description: nginx is an HTTP and reverse proxy server
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -L $0 ]; then
initscript=`/bin/readlink -f $0`
else
initscript=$0
fi
sysconfig=`/bin/basename $initscript`
if [ -f /etc/sysconfig/$sysconfig ]; then
. /etc/sysconfig/$sysconfig
fi
nginx=${NGINX:-/usr/local/nginx/sbin/nginx}
prog=`/bin/basename $nginx`
conffile=${CONFFILE:-/usr/local/nginx/conf/nginx.conf}
lockfile=${LOCKFILE:-/var/lock/subsys/nginx}
pidfile=${PIDFILE:-/usr/local/nginx/logs/nginx.pid}
SLEEPSEC=${SLEEPSEC:-1}
UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS:-5}
CHECKSLEEP=${CHECKSLEEP:-3}
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
}
upgrade() {
oldbinpidfile=${pidfile}.oldbin
configtest -q || return
echo -n $"Starting new master $prog: "
killproc -p ${pidfile} ${prog} -USR2
echo
for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do
/bin/sleep $SLEEPSEC
if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbinpidfile} ${prog} -QUIT
RETVAL=$?
echo
return
fi
done
echo $"Upgrade failed!"
RETVAL=1
}
configtest() {
if [ "$#" -ne 0 ] ; then
case "$1" in
-q)
FLAG=$1
;;
*)
;;
esac
shift
fi
${nginx} -t -c ${conffile} $FLAG
RETVAL=$?
return $RETVAL
}
rh_status() {
status -p ${pidfile} -b ${nginx} ${nginx}
}
check_reload() {
templog=`/bin/mktemp --tmpdir nginx-check-reload-XXXXXX.log`
trap '/bin/rm -f $templog' 0
/usr/bin/tail --pid=$$ -n 0 --follow=name /var/log/nginx/error.log > $templog &
/bin/sleep 1
/bin/echo -n $"Sending reload signal to $prog: "
killproc -p ${pidfile} ${prog} -HUP
/bin/echo
/bin/sleep $CHECKSLEEP
/bin/grep -E "\[emerg\]|\[alert\]" $templog
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
configtest -q || exit $RETVAL
stop
start
;;
upgrade)
rh_status >/dev/null 2>&1 || exit 0
upgrade
;;
condrestart|try-restart)
if rh_status >/dev/null 2>&1; then
stop
start
fi
;;
force-reload|reload)
reload
;;
configtest)
configtest
;;
check-reload)
check_reload
RETVAL=0
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest|check-reload}"
RETVAL=2
esac
exit $RETVAL
3.nginx
nginxの起動
[root@Ruby nginx-1.12.2]# /etc/init.d/nginx start
nginx を起動中: [ OK ]
nginxの自動起動設定
[root@Ruby nginx-1.12.2]# chkconfig nginx on
nginx起動画面
その他
◎ 設定ファイルの動作確認
[root@Ruby nginx-1.12.2]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
◎ サービス停止無しで設定ファイルおよび鍵ファイルの再読み込み
[root@Ruby nginx-1.12.2]# /usr/local/nginx/sbin/nginx -s reload
◎ ソースビルド時の有効なオプション
・–with-http_stub_status_module:nginx自体のステータスモニタリング(stub_statusデレィクティブ)
・–with-http_v2_module:HTTP/2のサポート
・–with-http_ssl_module:SSLのサポート
・–with-http_realip_module:リクエスト元IPアドレスを利用