CentOS 8 にNginx公式リポジトリを使用してNginxをインストールしてみました。
nginx: Linux packages
http://nginx.org/en/linux_packages.html#RHEL-CentOS
環境
・CentOS Linux release 8.2.2004 (Core)
・Kernel 4.18.0-193.6.3.el8_2.x86_64
- リポジトリの作成
- Install
- 自動起動の設定と起動
- Firewallの許可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@centos8 ~]# vi /etc/yum.repos.d/nginx.repo [root@centos8 ~]# cat /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true |
安定版が有効です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
[root@centos8 ~]# dnf info nginx nginx stable repo 13 kB/s | 16 kB 00:01 Available Packages Name : nginx Epoch : 1 Version : 1.18.0 Release : 1.el8.ngx Architecture : x86_64 Size : 806 k Source : nginx-1.18.0-1.el8.ngx.src.rpm Repository : nginx-stable Summary : High performance web server URL : http://nginx.org/ License : 2-clause BSD-like license Description : nginx [engine x] is an HTTP and reverse proxy server, as well as : a mail proxy server. [root@centos8 ~]# dnf -y install nginx Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: nginx x86_64 1:1.18.0-1.el8.ngx nginx-stable 806 k Transaction Summary ================================================================================ Install 1 Package Total download size: 806 k Installed size: 3.6 M Downloading Packages: nginx-1.18.0-1.el8.ngx.x86_64.rpm 362 kB/s | 806 kB 00:02 -------------------------------------------------------------------------------- Total 361 kB/s | 806 kB 00:02 warning: /var/cache/dnf/nginx-stable-614ef03fac352fea/packages/nginx-1.18.0-1.el8.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY nginx stable repo 1.4 kB/s | 1.5 kB 00:01 Importing GPG key 0x7BD9BF62: Userid : "nginx signing key <signing-key@nginx.com>" Fingerprint: 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 From : https://nginx.org/keys/nginx_signing.key Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: nginx-1:1.18.0-1.el8.ngx.x86_64 1/1 Installing : nginx-1:1.18.0-1.el8.ngx.x86_64 1/1 Running scriptlet: nginx-1:1.18.0-1.el8.ngx.x86_64 1/1 ---------------------------------------------------------------------- Thanks for using nginx! Please find the official documentation for nginx here: * http://nginx.org/en/docs/ Please subscribe to nginx-announce mailing list to get the most important news about nginx: * http://nginx.org/en/support.html Commercial subscriptions for nginx are available on: * http://nginx.com/products/ ---------------------------------------------------------------------- Verifying : nginx-1:1.18.0-1.el8.ngx.x86_64 1/1 Installed: nginx-1:1.18.0-1.el8.ngx.x86_64 Complete! |
AppStream repositoryと比べるとインストールされるファイルも設定情報の配置もかなり異なりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
[root@centos8 ~]# repoquery --list nginx /etc/logrotate.d/nginx /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/fastcgi_params /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/modules /etc/nginx/nginx.conf /etc/nginx/scgi_params /etc/nginx/uwsgi_params /etc/nginx/win-utf /etc/sysconfig/nginx /etc/sysconfig/nginx-debug /usr/lib/.build-id /usr/lib/.build-id/25 /usr/lib/.build-id/25/6232e97c72486552b6d3e6191b227e0cc4346e /usr/lib/.build-id/e3 /usr/lib/.build-id/e3/ecb20ef2cf6bb52027480d1802530bda5b311c /usr/lib/systemd/system/nginx-debug.service /usr/lib/systemd/system/nginx.service /usr/lib64/nginx /usr/lib64/nginx/modules /usr/libexec/initscripts/legacy-actions/nginx /usr/libexec/initscripts/legacy-actions/nginx/check-reload /usr/libexec/initscripts/legacy-actions/nginx/upgrade /usr/sbin/nginx /usr/sbin/nginx-debug /usr/share/doc/nginx-1.16.1 /usr/share/doc/nginx-1.16.1/COPYRIGHT /usr/share/man/man8/nginx.8.gz /usr/share/nginx /usr/share/nginx/html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html /var/cache/nginx /var/log/nginx /etc/logrotate.d/nginx /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/fastcgi_params /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/modules /etc/nginx/nginx.conf /etc/nginx/scgi_params /etc/nginx/uwsgi_params /etc/nginx/win-utf /etc/sysconfig/nginx /etc/sysconfig/nginx-debug /usr/lib/.build-id /usr/lib/.build-id/72 /usr/lib/.build-id/72/32b3d274d95e3739c1690a6344d3aac4c6272b /usr/lib/.build-id/7f /usr/lib/.build-id/7f/0259e101e7ab850dee7e6ac2907ac62f6f5917 /usr/lib/systemd/system/nginx-debug.service /usr/lib/systemd/system/nginx.service /usr/lib64/nginx /usr/lib64/nginx/modules /usr/libexec/initscripts/legacy-actions/nginx /usr/libexec/initscripts/legacy-actions/nginx/check-reload /usr/libexec/initscripts/legacy-actions/nginx/upgrade /usr/sbin/nginx /usr/sbin/nginx-debug /usr/share/doc/nginx-1.18.0 /usr/share/doc/nginx-1.18.0/COPYRIGHT /usr/share/man/man8/nginx.8.gz /usr/share/nginx /usr/share/nginx/html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html /var/cache/nginx /var/log/nginx /etc/logrotate.d/nginx /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/fastcgi_params /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/modules /etc/nginx/nginx.conf /etc/nginx/scgi_params /etc/nginx/uwsgi_params /etc/nginx/win-utf /etc/sysconfig/nginx /etc/sysconfig/nginx-debug /usr/lib/.build-id /usr/lib/.build-id/e3 /usr/lib/.build-id/e3/e9b610b96f554494b198949418df1363c43164 /usr/lib/.build-id/eb /usr/lib/.build-id/eb/c89ae3a5e4ab485465f9128d261a1d937e0ca5 /usr/lib/systemd/system/nginx-debug.service /usr/lib/systemd/system/nginx.service /usr/lib64/nginx /usr/lib64/nginx/modules /usr/libexec/initscripts/legacy-actions/nginx /usr/libexec/initscripts/legacy-actions/nginx/check-reload /usr/libexec/initscripts/legacy-actions/nginx/upgrade /usr/sbin/nginx /usr/sbin/nginx-debug /usr/share/doc/nginx-1.16.0 /usr/share/doc/nginx-1.16.0/COPYRIGHT /usr/share/man/man8/nginx.8.gz /usr/share/nginx /usr/share/nginx/html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html /var/cache/nginx /var/log/nginx /etc/logrotate.d/nginx /etc/nginx/fastcgi.conf /etc/nginx/fastcgi.conf.default /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params.default /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/mime.types.default /etc/nginx/nginx.conf /etc/nginx/nginx.conf.default /etc/nginx/scgi_params /etc/nginx/scgi_params.default /etc/nginx/uwsgi_params /etc/nginx/uwsgi_params.default /etc/nginx/win-utf /usr/bin/nginx-upgrade /usr/lib/.build-id /usr/lib/.build-id/2d /usr/lib/.build-id/2d/da6018ae12edb856ad3d2cf61bf586b6b4873c /usr/lib/systemd/system/nginx.service /usr/lib64/nginx/modules /usr/sbin/nginx /usr/share/doc/nginx /usr/share/doc/nginx/CHANGES /usr/share/doc/nginx/README /usr/share/doc/nginx/README.dynamic /usr/share/licenses/nginx /usr/share/licenses/nginx/LICENSE /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx-upgrade.8.gz /usr/share/man/man8/nginx.8.gz /usr/share/nginx/html/404.html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html /usr/share/nginx/html/nginx-logo.png /usr/share/nginx/html/poweredby.png /usr/share/vim/vimfiles/ftdetect/nginx.vim /usr/share/vim/vimfiles/indent/nginx.vim /usr/share/vim/vimfiles/syntax/nginx.vim /var/lib/nginx /var/lib/nginx/tmp /var/log/nginx |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@centos8 ~]# cat /etc/nginx/nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
[root@centos8 ~]# cat /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/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 /usr/share/nginx/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; #} } |
1 2 3 |
[root@centos8 ~]# systemctl enable nginx Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service -> /usr/lib/systemd/system/nginx.service. [root@centos8 ~]# systemctl start nginx |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@centos8 ~]# firewall-cmd --permanent --add-service=http success [root@centos8 ~]# firewall-cmd --reload success [root@centos8 ~]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: ens160 sources: services: cockpit dhcpv6-client http ssh ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: |
http://IP_Address/ にアクセスするとトップページが表示されました。
1 2 3 4 5 6 7 8 9 10 |
[root@centos8 ~]# curl -I http://192.168.1.1 HTTP/1.1 200 OK Server: nginx/1.18.0 Date: Sat, 18 Jul 2020 07:21:00 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 21 Apr 2020 15:07:54 GMT Connection: keep-alive ETag: "5e9f0c4a-264" Accept-Ranges: bytes |
1 2 3 4 5 6 |
[root@centos8 ~]# nginx -V nginx version: nginx/1.18.0 built by gcc 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC) built with OpenSSL 1.1.1c FIPS 28 May 2019 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' |