#はじめに
Amazon Linux2にNginxをソースコードビルドしてインストールしたときのメモ
#環境
Amazon Linux 2 AMI (HVM)
Kernel 4.14
SSD Volume Type
64 ビット x86
#ビルドの準備
ビルドに必要なコンパイラをインストールします。-develはmoduleを追加するときに必要になるのでオプションで付けておきます。Nginxにはサードパーティモジュールが提供されています。サードパーティモジュールはNginxをコンパイルするときに、一緒にビルドする必要があります。
$yum install -y gcc gcc-c++ libxslt-devel gd-devel GeoIP-devel
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
You need to be root to perform this command.
ルートじゃないとエラーが出ますので、ルートになってから再実行します。
$sudo su
$yum install -y gcc gcc-c++ libxslt-devel gd-devel GeoIP-devel
Installed:
GeoIP-devel.x86_64 0:1.5.0-11.amzn2.0.2 gcc.x86_64 0:7.3.1-13.amzn2 gcc-c++.x86_64 0:7.3.1-13.amzn2 gd-devel.x86_64 0:2.0.35-27.amzn2
libxslt-devel.x86_64 0:1.1.28-6.amzn2
Dependency Installed:
cpp.x86_64 0:7.3.1-13.amzn2 dejavu-fonts-common.noarch 0:2.33-6.amzn2 dejavu-sans-fonts.noarch 0:2.33-6.amzn2
expat-devel.x86_64 0:2.1.0-12.amzn2 fontconfig.x86_64 0:2.13.0-4.3.amzn2 fontconfig-devel.x86_64 0:2.13.0-4.3.amzn2
fontpackages-filesystem.noarch 0:1.44-8.amzn2 freetype-devel.x86_64 0:2.8-14.amzn2.1 gd.x86_64 0:2.0.35-27.amzn2
glibc-devel.x86_64 0:2.26-57.amzn2 glibc-headers.x86_64 0:2.26-57.amzn2 kernel-headers.x86_64 0:4.14.262-200.489.amzn2
libICE.x86_64 0:1.0.9-9.amzn2.0.2 libSM.x86_64 0:1.2.2-2.amzn2.0.2 libX11.x86_64 0:1.6.7-3.amzn2.0.2
libX11-common.noarch 0:1.6.7-3.amzn2.0.2 libX11-devel.x86_64 0:1.6.7-3.amzn2.0.2 libXau.x86_64 0:1.0.8-2.1.amzn2.0.2
libXau-devel.x86_64 0:1.0.8-2.1.amzn2.0.2 libXext.x86_64 0:1.3.3-3.amzn2.0.2 libXpm.x86_64 0:3.5.12-1.amzn2.0.2
libXpm-devel.x86_64 0:3.5.12-1.amzn2.0.2 libXt.x86_64 0:1.1.5-3.amzn2.0.2 libatomic.x86_64 0:7.3.1-13.amzn2
libcilkrts.x86_64 0:7.3.1-13.amzn2 libgcrypt-devel.x86_64 0:1.5.3-14.amzn2.0.2 libgpg-error-devel.x86_64 0:1.12-3.amzn2.0.3
libitm.x86_64 0:7.3.1-13.amzn2 libjpeg-turbo-devel.x86_64 0:2.0.90-2.amzn2.0.1 libmpc.x86_64 0:1.0.1-3.amzn2.0.2
libmpx.x86_64 0:7.3.1-13.amzn2 libpng-devel.x86_64 2:1.5.13-8.amzn2 libquadmath.x86_64 0:7.3.1-13.amzn2
libsanitizer.x86_64 0:7.3.1-13.amzn2 libuuid-devel.x86_64 0:2.30.2-2.amzn2.0.5 libxcb.x86_64 0:1.12-1.amzn2.0.2
libxcb-devel.x86_64 0:1.12-1.amzn2.0.2 libxml2-devel.x86_64 0:2.9.1-6.amzn2.5.4 libxslt.x86_64 0:1.1.28-6.amzn2
mpfr.x86_64 0:3.1.1-4.amzn2.0.2 xorg-x11-proto-devel.noarch 0:2018.4-1.amzn2.0.2 xz-devel.x86_64 0:5.2.2-1.amzn2.0.2
zlib-devel.x86_64 0:1.2.7-18.amzn2
#ビルドをするときに必要なライブラリをダウンロードします。
##PCRE(正規表現の処理)
###PCRE:Perl Compatible Regular Expressionsをインストールします。
$cd /usr/local/src
$yum -y install pcre pcre-devel
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00:00
Package pcre-8.32-17.amzn2.0.2.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.x86_64 0:8.32-17.amzn2.0.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
pcre-devel x86_64 8.32-17.amzn2.0.2 amzn2-core 480 k
Transaction Summary
========================================================================================================================================================================
Install 1 Package
Total download size: 480 k
Installed size: 1.4 M
Downloading packages:
pcre-devel-8.32-17.amzn2.0.2.x86_64.rpm | 480 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : pcre-devel-8.32-17.amzn2.0.2.x86_64 1/1
Verifying : pcre-devel-8.32-17.amzn2.0.2.x86_64 1/1
Installed:
pcre-devel.x86_64 0:8.32-17.amzn2.0.2
Complete!
##OpenSSL(SSL/TLS通信)
$yum -y install openssl openssl-devel
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Package 1:openssl-1.0.2k-19.amzn2.0.10.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-19.amzn2.0.10 will be installed
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-19.amzn2.0.10.x86_64
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.15.1-37.amzn2.2.4 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-37.amzn2.2.4 for package: krb5-devel-1.15.1-37.amzn2.2.4.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-37.amzn2.2.4.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-37.amzn2.2.4.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-37.amzn2.2.4.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-37.amzn2.2.4.x86_64
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.amzn2.0.2 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-19.amzn2 will be installed
---> Package libkadm5.x86_64 0:1.15.1-37.amzn2.2.4 will be installed
---> Package libselinux-devel.x86_64 0:2.5-12.amzn2.0.2 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-6 for package: libselinux-devel-2.5-12.amzn2.0.2.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-12.amzn2.0.2.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.amzn2.0.2 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.5-8.1.amzn2.0.2 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
openssl-devel x86_64 1:1.0.2k-19.amzn2.0.10 amzn2-core 1.5 M
Installing for dependencies:
keyutils-libs-devel x86_64 1.5.8-3.amzn2.0.2 amzn2-core 37 k
krb5-devel x86_64 1.15.1-37.amzn2.2.4 amzn2-core 272 k
libcom_err-devel x86_64 1.42.9-19.amzn2 amzn2-core 32 k
libkadm5 x86_64 1.15.1-37.amzn2.2.4 amzn2-core 179 k
libselinux-devel x86_64 2.5-12.amzn2.0.2 amzn2-core 187 k
libsepol-devel x86_64 2.5-8.1.amzn2.0.2 amzn2-core 77 k
libverto-devel x86_64 0.2.5-4.amzn2.0.2 amzn2-core 12 k
Transaction Summary
========================================================================================================================================================================
Install 1 Package (+7 Dependent packages)
Total download size: 2.3 M
Installed size: 4.5 M
Downloading packages:
(1/8): keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64.rpm | 37 kB 00:00:00
(2/8): krb5-devel-1.15.1-37.amzn2.2.4.x86_64.rpm | 272 kB 00:00:00
(3/8): libcom_err-devel-1.42.9-19.amzn2.x86_64.rpm | 32 kB 00:00:00
(4/8): libkadm5-1.15.1-37.amzn2.2.4.x86_64.rpm | 179 kB 00:00:00
(5/8): libselinux-devel-2.5-12.amzn2.0.2.x86_64.rpm | 187 kB 00:00:00
(6/8): libsepol-devel-2.5-8.1.amzn2.0.2.x86_64.rpm | 77 kB 00:00:00
(7/8): libverto-devel-0.2.5-4.amzn2.0.2.x86_64.rpm | 12 kB 00:00:00
(8/8): openssl-devel-1.0.2k-19.amzn2.0.10.x86_64.rpm | 1.5 MB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 10 MB/s | 2.3 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libkadm5-1.15.1-37.amzn2.2.4.x86_64 1/8
Installing : libverto-devel-0.2.5-4.amzn2.0.2.x86_64 2/8
Installing : libcom_err-devel-1.42.9-19.amzn2.x86_64 3/8
Installing : libsepol-devel-2.5-8.1.amzn2.0.2.x86_64 4/8
Installing : libselinux-devel-2.5-12.amzn2.0.2.x86_64 5/8
Installing : keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64 6/8
Installing : krb5-devel-1.15.1-37.amzn2.2.4.x86_64 7/8
Installing : 1:openssl-devel-1.0.2k-19.amzn2.0.10.x86_64 8/8
Verifying : keyutils-libs-devel-1.5.8-3.amzn2.0.2.x86_64 1/8
Verifying : libselinux-devel-2.5-12.amzn2.0.2.x86_64 2/8
Verifying : libsepol-devel-2.5-8.1.amzn2.0.2.x86_64 3/8
Verifying : libcom_err-devel-1.42.9-19.amzn2.x86_64 4/8
Verifying : libverto-devel-0.2.5-4.amzn2.0.2.x86_64 5/8
Verifying : 1:openssl-devel-1.0.2k-19.amzn2.0.10.x86_64 6/8
Verifying : libkadm5-1.15.1-37.amzn2.2.4.x86_64 7/8
Verifying : krb5-devel-1.15.1-37.amzn2.2.4.x86_64 8/8
Installed:
openssl-devel.x86_64 1:1.0.2k-19.amzn2.0.10
Dependency Installed:
keyutils-libs-devel.x86_64 0:1.5.8-3.amzn2.0.2 krb5-devel.x86_64 0:1.15.1-37.amzn2.2.4 libcom_err-devel.x86_64 0:1.42.9-19.amzn2
libkadm5.x86_64 0:1.15.1-37.amzn2.2.4 libselinux-devel.x86_64 0:2.5-12.amzn2.0.2 libsepol-devel.x86_64 0:2.5-8.1.amzn2.0.2
libverto-devel.x86_64 0:0.2.5-4.amzn2.0.2
Complete!
##Nginxnのソースコードをダウンロードします。
$cd /usr/local/src
$wget http://nginx.org/download/nginx-1.20.0.tar.gz
--2022-02-19 14:30:37-- http://nginx.org/download/nginx-1.20.0.tar.gz
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5704::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1061070 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.20.0.tar.gz’
100%[==============================================================================================================================>] 1,061,070 1.88MB/s in 0.5s
2022-02-19 14:30:38 (1.88 MB/s) - ‘nginx-1.20.0.tar.gz’ saved [1061070/1061070]
##Nginxのソースコードを解凍します。
$tar xzvf nginx-1.20.0.tar.gz
nginx-1.20.0/
nginx-1.20.0/auto/
nginx-1.20.0/conf/
nginx-1.20.0/contrib/
nginx-1.20.0/src/
nginx-1.20.0/configure
nginx-1.20.0/LICENSE
nginx-1.20.0/README
nginx-1.20.0/html/
nginx-1.20.0/man/
nginx-1.20.0/CHANGES.ru
nginx-1.20.0/CHANGES
nginx-1.20.0/man/nginx.8
nginx-1.20.0/html/50x.html
nginx-1.20.0/html/index.html
nginx-1.20.0/src/core/
nginx-1.20.0/src/event/
nginx-1.20.0/src/http/
nginx-1.20.0/src/mail/
nginx-1.20.0/src/misc/
nginx-1.20.0/src/os/
nginx-1.20.0/src/stream/
nginx-1.20.0/src/stream/ngx_stream.c
nginx-1.20.0/src/stream/ngx_stream.h
nginx-1.20.0/src/stream/ngx_stream_access_module.c
nginx-1.20.0/src/stream/ngx_stream_core_module.c
nginx-1.20.0/src/stream/ngx_stream_geo_module.c
nginx-1.20.0/src/stream/ngx_stream_geoip_module.c
nginx-1.20.0/src/stream/ngx_stream_handler.c
nginx-1.20.0/src/stream/ngx_stream_limit_conn_module.c
nginx-1.20.0/src/stream/ngx_stream_log_module.c
nginx-1.20.0/src/stream/ngx_stream_map_module.c
nginx-1.20.0/src/stream/ngx_stream_proxy_module.c
nginx-1.20.0/src/stream/ngx_stream_realip_module.c
nginx-1.20.0/src/stream/ngx_stream_return_module.c
nginx-1.20.0/src/stream/ngx_stream_script.c
nginx-1.20.0/src/stream/ngx_stream_script.h
nginx-1.20.0/src/stream/ngx_stream_set_module.c
nginx-1.20.0/src/stream/ngx_stream_split_clients_module.c
nginx-1.20.0/src/stream/ngx_stream_ssl_module.c
nginx-1.20.0/src/stream/ngx_stream_ssl_module.h
nginx-1.20.0/src/stream/ngx_stream_ssl_preread_module.c
nginx-1.20.0/src/stream/ngx_stream_upstream.c
nginx-1.20.0/src/stream/ngx_stream_upstream.h
nginx-1.20.0/src/stream/ngx_stream_upstream_hash_module.c
nginx-1.20.0/src/stream/ngx_stream_upstream_least_conn_module.c
nginx-1.20.0/src/stream/ngx_stream_upstream_random_module.c
nginx-1.20.0/src/stream/ngx_stream_upstream_round_robin.c
nginx-1.20.0/src/stream/ngx_stream_upstream_round_robin.h
nginx-1.20.0/src/stream/ngx_stream_upstream_zone_module.c
nginx-1.20.0/src/stream/ngx_stream_variables.c
nginx-1.20.0/src/stream/ngx_stream_variables.h
nginx-1.20.0/src/stream/ngx_stream_write_filter_module.c
nginx-1.20.0/src/os/unix/
nginx-1.20.0/src/os/unix/ngx_alloc.c
nginx-1.20.0/src/os/unix/ngx_alloc.h
nginx-1.20.0/src/os/unix/ngx_atomic.h
nginx-1.20.0/src/os/unix/ngx_channel.c
nginx-1.20.0/src/os/unix/ngx_channel.h
nginx-1.20.0/src/os/unix/ngx_daemon.c
nginx-1.20.0/src/os/unix/ngx_darwin.h
nginx-1.20.0/src/os/unix/ngx_darwin_config.h
nginx-1.20.0/src/os/unix/ngx_darwin_init.c
nginx-1.20.0/src/os/unix/ngx_darwin_sendfile_chain.c
nginx-1.20.0/src/os/unix/ngx_dlopen.c
nginx-1.20.0/src/os/unix/ngx_dlopen.h
nginx-1.20.0/src/os/unix/ngx_errno.c
nginx-1.20.0/src/os/unix/ngx_errno.h
nginx-1.20.0/src/os/unix/ngx_file_aio_read.c
nginx-1.20.0/src/os/unix/ngx_files.c
nginx-1.20.0/src/os/unix/ngx_files.h
nginx-1.20.0/src/os/unix/ngx_freebsd.h
nginx-1.20.0/src/os/unix/ngx_freebsd_config.h
nginx-1.20.0/src/os/unix/ngx_linux.h
nginx-1.20.0/src/os/unix/ngx_freebsd_init.c
nginx-1.20.0/src/os/unix/ngx_freebsd_sendfile_chain.c
nginx-1.20.0/src/os/unix/ngx_gcc_atomic_amd64.h
nginx-1.20.0/src/os/unix/ngx_gcc_atomic_ppc.h
nginx-1.20.0/src/os/unix/ngx_gcc_atomic_sparc64.h
nginx-1.20.0/src/os/unix/ngx_gcc_atomic_x86.h
nginx-1.20.0/src/os/unix/ngx_linux_aio_read.c
nginx-1.20.0/src/os/unix/ngx_linux_config.h
nginx-1.20.0/src/os/unix/ngx_linux_init.c
nginx-1.20.0/src/os/unix/ngx_linux_sendfile_chain.c
nginx-1.20.0/src/os/unix/ngx_os.h
nginx-1.20.0/src/os/unix/ngx_posix_config.h
nginx-1.20.0/src/os/unix/ngx_posix_init.c
nginx-1.20.0/src/os/unix/ngx_process.c
nginx-1.20.0/src/os/unix/ngx_process.h
nginx-1.20.0/src/os/unix/ngx_process_cycle.c
nginx-1.20.0/src/os/unix/ngx_process_cycle.h
nginx-1.20.0/src/os/unix/ngx_readv_chain.c
nginx-1.20.0/src/os/unix/ngx_recv.c
nginx-1.20.0/src/os/unix/ngx_send.c
nginx-1.20.0/src/os/unix/ngx_setaffinity.c
nginx-1.20.0/src/os/unix/ngx_setaffinity.h
nginx-1.20.0/src/os/unix/ngx_setproctitle.c
nginx-1.20.0/src/os/unix/ngx_setproctitle.h
nginx-1.20.0/src/os/unix/ngx_shmem.c
nginx-1.20.0/src/os/unix/ngx_shmem.h
nginx-1.20.0/src/os/unix/ngx_socket.c
nginx-1.20.0/src/os/unix/ngx_socket.h
nginx-1.20.0/src/os/unix/ngx_solaris.h
nginx-1.20.0/src/os/unix/ngx_solaris_config.h
nginx-1.20.0/src/os/unix/ngx_solaris_init.c
nginx-1.20.0/src/os/unix/ngx_solaris_sendfilev_chain.c
nginx-1.20.0/src/os/unix/ngx_sunpro_amd64.il
nginx-1.20.0/src/os/unix/ngx_sunpro_atomic_sparc64.h
nginx-1.20.0/src/os/unix/ngx_sunpro_sparc64.il
nginx-1.20.0/src/os/unix/ngx_thread.h
nginx-1.20.0/src/os/unix/ngx_sunpro_x86.il
nginx-1.20.0/src/os/unix/ngx_thread_cond.c
nginx-1.20.0/src/os/unix/ngx_thread_id.c
nginx-1.20.0/src/os/unix/ngx_thread_mutex.c
nginx-1.20.0/src/os/unix/ngx_time.c
nginx-1.20.0/src/os/unix/ngx_time.h
nginx-1.20.0/src/os/unix/ngx_udp_recv.c
nginx-1.20.0/src/os/unix/ngx_udp_send.c
nginx-1.20.0/src/os/unix/ngx_udp_sendmsg_chain.c
nginx-1.20.0/src/os/unix/ngx_user.c
nginx-1.20.0/src/os/unix/ngx_user.h
nginx-1.20.0/src/os/unix/ngx_writev_chain.c
nginx-1.20.0/src/misc/ngx_cpp_test_module.cpp
nginx-1.20.0/src/misc/ngx_google_perftools_module.c
nginx-1.20.0/src/mail/ngx_mail.c
nginx-1.20.0/src/mail/ngx_mail.h
nginx-1.20.0/src/mail/ngx_mail_auth_http_module.c
nginx-1.20.0/src/mail/ngx_mail_core_module.c
nginx-1.20.0/src/mail/ngx_mail_handler.c
nginx-1.20.0/src/mail/ngx_mail_imap_handler.c
nginx-1.20.0/src/mail/ngx_mail_imap_module.c
nginx-1.20.0/src/mail/ngx_mail_imap_module.h
nginx-1.20.0/src/mail/ngx_mail_parse.c
nginx-1.20.0/src/mail/ngx_mail_pop3_handler.c
nginx-1.20.0/src/mail/ngx_mail_pop3_module.c
nginx-1.20.0/src/mail/ngx_mail_pop3_module.h
nginx-1.20.0/src/mail/ngx_mail_proxy_module.c
nginx-1.20.0/src/mail/ngx_mail_realip_module.c
nginx-1.20.0/src/mail/ngx_mail_smtp_handler.c
nginx-1.20.0/src/mail/ngx_mail_smtp_module.c
nginx-1.20.0/src/mail/ngx_mail_smtp_module.h
nginx-1.20.0/src/mail/ngx_mail_ssl_module.c
nginx-1.20.0/src/mail/ngx_mail_ssl_module.h
nginx-1.20.0/src/http/modules/
nginx-1.20.0/src/http/ngx_http.c
nginx-1.20.0/src/http/ngx_http.h
nginx-1.20.0/src/http/ngx_http_cache.h
nginx-1.20.0/src/http/ngx_http_config.h
nginx-1.20.0/src/http/ngx_http_copy_filter_module.c
nginx-1.20.0/src/http/ngx_http_core_module.c
nginx-1.20.0/src/http/ngx_http_core_module.h
nginx-1.20.0/src/http/ngx_http_file_cache.c
nginx-1.20.0/src/http/ngx_http_header_filter_module.c
nginx-1.20.0/src/http/ngx_http_parse.c
nginx-1.20.0/src/http/ngx_http_postpone_filter_module.c
nginx-1.20.0/src/http/ngx_http_request.c
nginx-1.20.0/src/http/ngx_http_request.h
nginx-1.20.0/src/http/ngx_http_request_body.c
nginx-1.20.0/src/http/ngx_http_script.c
nginx-1.20.0/src/http/v2/
nginx-1.20.0/src/http/ngx_http_script.h
nginx-1.20.0/src/http/ngx_http_special_response.c
nginx-1.20.0/src/http/ngx_http_upstream.c
nginx-1.20.0/src/http/ngx_http_upstream.h
nginx-1.20.0/src/http/ngx_http_upstream_round_robin.c
nginx-1.20.0/src/http/ngx_http_upstream_round_robin.h
nginx-1.20.0/src/http/ngx_http_variables.c
nginx-1.20.0/src/http/ngx_http_variables.h
nginx-1.20.0/src/http/ngx_http_write_filter_module.c
nginx-1.20.0/src/http/v2/ngx_http_v2.c
nginx-1.20.0/src/http/v2/ngx_http_v2.h
nginx-1.20.0/src/http/v2/ngx_http_v2_encode.c
nginx-1.20.0/src/http/v2/ngx_http_v2_filter_module.c
nginx-1.20.0/src/http/v2/ngx_http_v2_huff_decode.c
nginx-1.20.0/src/http/v2/ngx_http_v2_huff_encode.c
nginx-1.20.0/src/http/v2/ngx_http_v2_module.c
nginx-1.20.0/src/http/v2/ngx_http_v2_module.h
nginx-1.20.0/src/http/v2/ngx_http_v2_table.c
nginx-1.20.0/src/http/modules/ngx_http_access_module.c
nginx-1.20.0/src/http/modules/ngx_http_addition_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_auth_basic_module.c
nginx-1.20.0/src/http/modules/ngx_http_auth_request_module.c
nginx-1.20.0/src/http/modules/ngx_http_autoindex_module.c
nginx-1.20.0/src/http/modules/ngx_http_browser_module.c
nginx-1.20.0/src/http/modules/ngx_http_charset_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_chunked_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_dav_module.c
nginx-1.20.0/src/http/modules/ngx_http_degradation_module.c
nginx-1.20.0/src/http/modules/ngx_http_empty_gif_module.c
nginx-1.20.0/src/http/modules/ngx_http_fastcgi_module.c
nginx-1.20.0/src/http/modules/perl/
nginx-1.20.0/src/http/modules/ngx_http_flv_module.c
nginx-1.20.0/src/http/modules/ngx_http_geo_module.c
nginx-1.20.0/src/http/modules/ngx_http_geoip_module.c
nginx-1.20.0/src/http/modules/ngx_http_grpc_module.c
nginx-1.20.0/src/http/modules/ngx_http_gunzip_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_gzip_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_gzip_static_module.c
nginx-1.20.0/src/http/modules/ngx_http_headers_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_image_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_index_module.c
nginx-1.20.0/src/http/modules/ngx_http_limit_conn_module.c
nginx-1.20.0/src/http/modules/ngx_http_limit_req_module.c
nginx-1.20.0/src/http/modules/ngx_http_log_module.c
nginx-1.20.0/src/http/modules/ngx_http_map_module.c
nginx-1.20.0/src/http/modules/ngx_http_memcached_module.c
nginx-1.20.0/src/http/modules/ngx_http_mirror_module.c
nginx-1.20.0/src/http/modules/ngx_http_mp4_module.c
nginx-1.20.0/src/http/modules/ngx_http_not_modified_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_proxy_module.c
nginx-1.20.0/src/http/modules/ngx_http_random_index_module.c
nginx-1.20.0/src/http/modules/ngx_http_range_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_realip_module.c
nginx-1.20.0/src/http/modules/ngx_http_referer_module.c
nginx-1.20.0/src/http/modules/ngx_http_rewrite_module.c
nginx-1.20.0/src/http/modules/ngx_http_scgi_module.c
nginx-1.20.0/src/http/modules/ngx_http_secure_link_module.c
nginx-1.20.0/src/http/modules/ngx_http_slice_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_split_clients_module.c
nginx-1.20.0/src/http/modules/ngx_http_ssi_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_ssi_filter_module.h
nginx-1.20.0/src/http/modules/ngx_http_ssl_module.c
nginx-1.20.0/src/http/modules/ngx_http_ssl_module.h
nginx-1.20.0/src/http/modules/ngx_http_static_module.c
nginx-1.20.0/src/http/modules/ngx_http_stub_status_module.c
nginx-1.20.0/src/http/modules/ngx_http_sub_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_try_files_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_hash_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_ip_hash_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_keepalive_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_random_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_least_conn_module.c
nginx-1.20.0/src/http/modules/ngx_http_upstream_zone_module.c
nginx-1.20.0/src/http/modules/ngx_http_userid_filter_module.c
nginx-1.20.0/src/http/modules/ngx_http_uwsgi_module.c
nginx-1.20.0/src/http/modules/ngx_http_xslt_filter_module.c
nginx-1.20.0/src/http/modules/perl/Makefile.PL
nginx-1.20.0/src/http/modules/perl/nginx.pm
nginx-1.20.0/src/http/modules/perl/nginx.xs
nginx-1.20.0/src/http/modules/perl/ngx_http_perl_module.c
nginx-1.20.0/src/http/modules/perl/ngx_http_perl_module.h
nginx-1.20.0/src/http/modules/perl/typemap
nginx-1.20.0/src/event/modules/
nginx-1.20.0/src/event/ngx_event.c
nginx-1.20.0/src/event/ngx_event.h
nginx-1.20.0/src/event/ngx_event_accept.c
nginx-1.20.0/src/event/ngx_event_connect.c
nginx-1.20.0/src/event/ngx_event_connect.h
nginx-1.20.0/src/event/ngx_event_openssl.c
nginx-1.20.0/src/event/ngx_event_openssl.h
nginx-1.20.0/src/event/ngx_event_openssl_stapling.c
nginx-1.20.0/src/event/ngx_event_pipe.c
nginx-1.20.0/src/event/ngx_event_pipe.h
nginx-1.20.0/src/event/ngx_event_posted.c
nginx-1.20.0/src/event/ngx_event_posted.h
nginx-1.20.0/src/event/ngx_event_timer.c
nginx-1.20.0/src/event/ngx_event_timer.h
nginx-1.20.0/src/event/ngx_event_udp.c
nginx-1.20.0/src/event/modules/ngx_devpoll_module.c
nginx-1.20.0/src/event/modules/ngx_epoll_module.c
nginx-1.20.0/src/event/modules/ngx_eventport_module.c
nginx-1.20.0/src/event/modules/ngx_kqueue_module.c
nginx-1.20.0/src/event/modules/ngx_poll_module.c
nginx-1.20.0/src/event/modules/ngx_select_module.c
nginx-1.20.0/src/event/modules/ngx_win32_poll_module.c
nginx-1.20.0/src/event/modules/ngx_win32_select_module.c
nginx-1.20.0/src/core/nginx.c
nginx-1.20.0/src/core/nginx.h
nginx-1.20.0/src/core/ngx_array.c
nginx-1.20.0/src/core/ngx_array.h
nginx-1.20.0/src/core/ngx_buf.c
nginx-1.20.0/src/core/ngx_buf.h
nginx-1.20.0/src/core/ngx_conf_file.c
nginx-1.20.0/src/core/ngx_conf_file.h
nginx-1.20.0/src/core/ngx_config.h
nginx-1.20.0/src/core/ngx_connection.c
nginx-1.20.0/src/core/ngx_connection.h
nginx-1.20.0/src/core/ngx_core.h
nginx-1.20.0/src/core/ngx_cpuinfo.c
nginx-1.20.0/src/core/ngx_crc.h
nginx-1.20.0/src/core/ngx_crc32.c
nginx-1.20.0/src/core/ngx_crc32.h
nginx-1.20.0/src/core/ngx_crypt.c
nginx-1.20.0/src/core/ngx_crypt.h
nginx-1.20.0/src/core/ngx_cycle.c
nginx-1.20.0/src/core/ngx_cycle.h
nginx-1.20.0/src/core/ngx_file.c
nginx-1.20.0/src/core/ngx_file.h
nginx-1.20.0/src/core/ngx_hash.c
nginx-1.20.0/src/core/ngx_hash.h
nginx-1.20.0/src/core/ngx_inet.c
nginx-1.20.0/src/core/ngx_inet.h
nginx-1.20.0/src/core/ngx_list.c
nginx-1.20.0/src/core/ngx_list.h
nginx-1.20.0/src/core/ngx_log.c
nginx-1.20.0/src/core/ngx_log.h
nginx-1.20.0/src/core/ngx_md5.c
nginx-1.20.0/src/core/ngx_md5.h
nginx-1.20.0/src/core/ngx_module.c
nginx-1.20.0/src/core/ngx_module.h
nginx-1.20.0/src/core/ngx_murmurhash.c
nginx-1.20.0/src/core/ngx_murmurhash.h
nginx-1.20.0/src/core/ngx_open_file_cache.c
nginx-1.20.0/src/core/ngx_open_file_cache.h
nginx-1.20.0/src/core/ngx_output_chain.c
nginx-1.20.0/src/core/ngx_palloc.c
nginx-1.20.0/src/core/ngx_palloc.h
nginx-1.20.0/src/core/ngx_parse.c
nginx-1.20.0/src/core/ngx_parse.h
nginx-1.20.0/src/core/ngx_parse_time.c
nginx-1.20.0/src/core/ngx_queue.c
nginx-1.20.0/src/core/ngx_parse_time.h
nginx-1.20.0/src/core/ngx_proxy_protocol.c
nginx-1.20.0/src/core/ngx_proxy_protocol.h
nginx-1.20.0/src/core/ngx_queue.h
nginx-1.20.0/src/core/ngx_radix_tree.c
nginx-1.20.0/src/core/ngx_radix_tree.h
nginx-1.20.0/src/core/ngx_rbtree.c
nginx-1.20.0/src/core/ngx_rbtree.h
nginx-1.20.0/src/core/ngx_regex.c
nginx-1.20.0/src/core/ngx_regex.h
nginx-1.20.0/src/core/ngx_resolver.c
nginx-1.20.0/src/core/ngx_resolver.h
nginx-1.20.0/src/core/ngx_rwlock.c
nginx-1.20.0/src/core/ngx_rwlock.h
nginx-1.20.0/src/core/ngx_sha1.c
nginx-1.20.0/src/core/ngx_sha1.h
nginx-1.20.0/src/core/ngx_shmtx.c
nginx-1.20.0/src/core/ngx_shmtx.h
nginx-1.20.0/src/core/ngx_slab.c
nginx-1.20.0/src/core/ngx_slab.h
nginx-1.20.0/src/core/ngx_spinlock.c
nginx-1.20.0/src/core/ngx_string.c
nginx-1.20.0/src/core/ngx_string.h
nginx-1.20.0/src/core/ngx_syslog.c
nginx-1.20.0/src/core/ngx_syslog.h
nginx-1.20.0/src/core/ngx_thread_pool.c
nginx-1.20.0/src/core/ngx_thread_pool.h
nginx-1.20.0/src/core/ngx_times.c
nginx-1.20.0/src/core/ngx_times.h
nginx-1.20.0/contrib/README
nginx-1.20.0/contrib/geo2nginx.pl
nginx-1.20.0/contrib/unicode2nginx/
nginx-1.20.0/contrib/vim/
nginx-1.20.0/contrib/vim/ftdetect/
nginx-1.20.0/contrib/vim/ftplugin/
nginx-1.20.0/contrib/vim/indent/
nginx-1.20.0/contrib/vim/syntax/
nginx-1.20.0/contrib/vim/syntax/nginx.vim
nginx-1.20.0/contrib/vim/indent/nginx.vim
nginx-1.20.0/contrib/vim/ftplugin/nginx.vim
nginx-1.20.0/contrib/vim/ftdetect/nginx.vim
nginx-1.20.0/contrib/unicode2nginx/koi-utf
nginx-1.20.0/contrib/unicode2nginx/unicode-to-nginx.pl
nginx-1.20.0/contrib/unicode2nginx/win-utf
nginx-1.20.0/conf/fastcgi.conf
nginx-1.20.0/conf/fastcgi_params
nginx-1.20.0/conf/koi-utf
nginx-1.20.0/conf/koi-win
nginx-1.20.0/conf/mime.types
nginx-1.20.0/conf/nginx.conf
nginx-1.20.0/conf/scgi_params
nginx-1.20.0/conf/uwsgi_params
nginx-1.20.0/conf/win-utf
nginx-1.20.0/auto/cc/
nginx-1.20.0/auto/define
nginx-1.20.0/auto/endianness
nginx-1.20.0/auto/feature
nginx-1.20.0/auto/have
nginx-1.20.0/auto/have_headers
nginx-1.20.0/auto/headers
nginx-1.20.0/auto/include
nginx-1.20.0/auto/init
nginx-1.20.0/auto/install
nginx-1.20.0/auto/lib/
nginx-1.20.0/auto/make
nginx-1.20.0/auto/module
nginx-1.20.0/auto/modules
nginx-1.20.0/auto/nohave
nginx-1.20.0/auto/options
nginx-1.20.0/auto/os/
nginx-1.20.0/auto/sources
nginx-1.20.0/auto/stubs
nginx-1.20.0/auto/summary
nginx-1.20.0/auto/threads
nginx-1.20.0/auto/types/
nginx-1.20.0/auto/unix
nginx-1.20.0/auto/types/sizeof
nginx-1.20.0/auto/types/typedef
nginx-1.20.0/auto/types/uintptr_t
nginx-1.20.0/auto/types/value
nginx-1.20.0/auto/os/conf
nginx-1.20.0/auto/os/darwin
nginx-1.20.0/auto/os/freebsd
nginx-1.20.0/auto/os/linux
nginx-1.20.0/auto/os/solaris
nginx-1.20.0/auto/os/win32
nginx-1.20.0/auto/lib/conf
nginx-1.20.0/auto/lib/geoip/
nginx-1.20.0/auto/lib/google-perftools/
nginx-1.20.0/auto/lib/libatomic/
nginx-1.20.0/auto/lib/libgd/
nginx-1.20.0/auto/lib/libxslt/
nginx-1.20.0/auto/lib/make
nginx-1.20.0/auto/lib/openssl/
nginx-1.20.0/auto/lib/pcre/
nginx-1.20.0/auto/lib/perl/
nginx-1.20.0/auto/lib/zlib/
nginx-1.20.0/auto/lib/zlib/conf
nginx-1.20.0/auto/lib/zlib/make
nginx-1.20.0/auto/lib/zlib/makefile.bcc
nginx-1.20.0/auto/lib/zlib/makefile.msvc
nginx-1.20.0/auto/lib/zlib/makefile.owc
nginx-1.20.0/auto/lib/perl/conf
nginx-1.20.0/auto/lib/perl/make
nginx-1.20.0/auto/lib/pcre/conf
nginx-1.20.0/auto/lib/pcre/make
nginx-1.20.0/auto/lib/pcre/makefile.bcc
nginx-1.20.0/auto/lib/pcre/makefile.msvc
nginx-1.20.0/auto/lib/pcre/makefile.owc
nginx-1.20.0/auto/lib/openssl/conf
nginx-1.20.0/auto/lib/openssl/make
nginx-1.20.0/auto/lib/openssl/makefile.bcc
nginx-1.20.0/auto/lib/openssl/makefile.msvc
nginx-1.20.0/auto/lib/libxslt/conf
nginx-1.20.0/auto/lib/libgd/conf
nginx-1.20.0/auto/lib/libatomic/conf
nginx-1.20.0/auto/lib/libatomic/make
nginx-1.20.0/auto/lib/google-perftools/conf
nginx-1.20.0/auto/lib/geoip/conf
nginx-1.20.0/auto/cc/acc
nginx-1.20.0/auto/cc/bcc
nginx-1.20.0/auto/cc/ccc
nginx-1.20.0/auto/cc/clang
nginx-1.20.0/auto/cc/conf
nginx-1.20.0/auto/cc/gcc
nginx-1.20.0/auto/cc/icc
nginx-1.20.0/auto/cc/msvc
nginx-1.20.0/auto/cc/name
nginx-1.20.0/auto/cc/owc
nginx-1.20.0/auto/cc/sunc
##configure(Makefile生成)
$cd /usr/local/src
$cd nginx-1.20.0
$ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
$./configure
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ 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"
##Make
$cd /usr/local/src/nginx-1.20.0
$make
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]: Leaving directory `/usr/local/src/nginx-1.20.0'
##インストール
$sudo make install
make -f objs/Makefile install
make[1]: Entering directory `/usr/local/src/nginx-1.20.0'
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]: Leaving directory `/usr/local/src/nginx-1.20.0'
##インストールの確認
$cd /usr/local/src
$nginx -v
bash: nginx: command not found
nginxは見つからないとエラーになった。
##Makefileの確認
$cat /usr/local/src/nginx-1.20.0/Makefile
default: build
clean:
rm -rf Makefile objs
.PHONY: default clean
build:
$(MAKE) -f objs/Makefile
install:
$(MAKE) -f objs/Makefile install
modules:
$(MAKE) -f objs/Makefile modules
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`
.PHONY: build install modules upgrade
/usr/local/nginx/sbin/nginxにnxginxが生成されているようだ。
$cd /usr/local/nginx/sbin
$ls -lrt
total 8960
-rwxr-xr-x 1 root root 4584248 Feb 19 14:40 nginx.old
-rwxr-xr-x 1 root root 4584248 Feb 19 14:41 nginx
$./nginx -v
nginx version: nginx/1.20.0
nginxを/usr/sbinにコピーする
$cp nginx /usr/sbin
$nginx -v
nginx version: nginx/1.20.0
##nginxを起動する
$systemctl start nginx
Failed to start nginx.service: Unit not found.
nginxサービスがないというエラーになる。
##nginxをサービス登録します。
$cd /usr/lib/systemd/system/
$vi nginx.service
nginx.serviceの内容は以下になります。
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
Restart=always
[Install]
WantedBy=multi-user.target
##systemdを再読み込みします。
$systemctl daemon-reload
$systemctl enable nginx.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
$systemctl start nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
また、別のエラーが発生した。
##nginxのステータスを確認してみる
$systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: activating (start) since Sat 2022-02-19 15:11:54 UTC; 1s ago
Process: 20451 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 20450 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Control: 20455 (nginx)
CGroup: /system.slice/nginx.service
mq20455 /usr/sbin/nginx
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal systemd[1]: nginx.service holdoff time over, scheduling restart.
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal nginx[20451]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal nginx[20451]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Feb 19 15:11:54 ip-172-31-22-226.ec2.internal nginx[20455]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:11:55 ip-172-31-22-226.ec2.internal nginx[20455]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:11:55 ip-172-31-22-226.ec2.internal nginx[20455]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
どうやら、ポート80のソケットのバインドに失敗しているようだ。
#AWSコンソールにて、EC2のセキュリティグループのインバウンドルールにHTTP(ポート80)を追加する。
##エラーは解消されず・・・
systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: activating (start) since Sat 2022-02-19 15:20:16 UTC; 2s ago
Process: 22359 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 22358 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Control: 22363 (nginx)
CGroup: /system.slice/nginx.service
mq22363 /usr/sbin/nginx
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal systemd[1]: nginx.service holdoff time over, scheduling restart.
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal nginx[22359]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal nginx[22359]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal nginx[22363]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:20:16 ip-172-31-22-226.ec2.internal nginx[22363]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:20:17 ip-172-31-22-226.ec2.internal nginx[22363]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:20:17 ip-172-31-22-226.ec2.internal nginx[22363]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 15:20:18 ip-172-31-22-226.ec2.internal nginx[22363]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
##lsofで調べてみる
$sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 19679 root 6u IPv4 72610 0t0 TCP *:http (LISTEN)
nginx 19680 nobody 6u IPv4 72610 0t0 TCP *:http (LISTEN)
nginxは起動しているようだ・・・
##エラー内容が若干変わった
$systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: activating (start) since Sat 2022-02-19 15:26:57 UTC; 38s ago
Process: 3199 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 3196 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 3194 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nginx.service
tq3201 nginx: master process /usr/sbin/nginx
mq3202 nginx: worker process
Feb 19 15:26:57 ip-172-31-22-226.ec2.internal systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Feb 19 15:26:57 ip-172-31-22-226.ec2.internal systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 19 15:26:57 ip-172-31-22-226.ec2.internal nginx[3196]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
Feb 19 15:26:57 ip-172-31-22-226.ec2.internal nginx[3196]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Feb 19 15:26:58 ip-172-31-22-226.ec2.internal systemd[1]: Can't open PID file /run/nginx.pid (yet?) after start: No such file or directory
PIDファイルが開けないようだ。
##Makefileを確認
$cat /usr/local/src/nginx-1.20.0/Makefile
default: build
clean:
rm -rf Makefile objs
.PHONY: default clean
build:
$(MAKE) -f objs/Makefile
install:
$(MAKE) -f objs/Makefile install
modules:
$(MAKE) -f objs/Makefile modules
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`
.PHONY: build install modules upgrade
Makefileの/usr/local/nginx/logs/nginx.pidとnginx.serviceのPIDFile=/run/nginx.pidは一致させる必要があるのかも知れない。とりあえず、nginx.serviceのPIDFile=/run/nginx.pidをPIDFile=/usr/local/nginx/logs/nginx.pidに変更してみる。
$vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
#PIDFile=/run/nginx.pid ←コメントアウト
PIDFile=/usr/local/nginx/logs/nginx.pid ←追加
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
Restart=always
[Install]
WantedBy=multi-user.target
##デーモンをリロードする。
$systemctl daemon-reload
##nginx.serviceの起動にやっと成功した!!
$systemctl restart nginx.service
$systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-02-19 15:45:11 UTC; 24s ago
Process: 3540 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 3537 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 3535 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 3543 (nginx)
CGroup: /system.slice/nginx.service
tq3543 nginx: master process /usr/sbin/nginx
mq3545 nginx: worker process
#はまりポイント
最もはまったポイントですが、systemctl restart nginx.serviceでエラーになったり、プロンプトが戻ってこなかったりしました。systemctl status nginx.serviceで状態を見るとpidファイルのオープンに失敗していました。Makefileの/usr/local/nginx/logs/nginx.pidとnginx.serviceのPIDFile=/run/nginx.pidは一致させる必要があるのかも知れない。とりあえず、nginx.serviceのPIDFile=/run/nginx.pidをPIDFile=/usr/local/nginx/logs/nginx.pidに変更してから、systemctl daemon reloadすると、無事に成功しました。
###Makefile:/usr/local/src/nginx-1.20.0/Makefile
kill -USR2 cat /usr/local/nginx/logs/nginx.pid
###nginx.service:/usr/lib/systemd/system/nginx.service
PIDFile=/usr/local/nginx/logs/nginx.pid
#↑↑↑ こんな風にnginx.pidを一致させる必要がありました!!!
#おわりに
無事にAmazon Linux2にNginxをソースコードビルドして起動することに成功しました。
では、また。