仕事も落ち着いて時間ができたので、勉強のつもりでCnetOS 7にNginxをインストールしてみました。
nginx
https://ja.wikipedia.org/wiki/Nginx
Official Red Hat/CentOS packages
https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
Red Hat/CentOSにはオフィシャルパッケージが提供されています。
- リポジトリの追加
- インストール
- 自動起動の設定
- 起動
- Firewalldの設定
変数を使わずに直接URLを記述しています。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# vi /etc/yum.repos.d/nginx.repo # cat /etc/yum.repos.d/nginx.repo [nginx] name=nginx baseurl=http://nginx.org/packages/centos/7/x86_64/ gpgcheck=0 enabled=1 # yum info nginx Available Packages Name : nginx Arch : x86_64 Epoch : 1 Version : 1.14.0 Release : 1.el7_4.ngx Size : 750 k Repo : nginx 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. |
ちなみにepel repoにもパッケージがありましたが、バージョンが1.12.2でした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# yum info nginx Available Packages Name : nginx Arch : x86_64 Epoch : 1 Version : 1.12.2 Release : 2.el7 Size : 530 k Repo : epel/x86_64 Summary : A high performance web server and reverse proxy server URL : http://nginx.org/ License : BSD Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and : IMAP protocols, with a strong focus on high concurrency, performance and low : memory usage. |
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 |
# yum install nginx Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.14.0-1.el7_4.ngx will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================== Package Arch Version Repository Size ====================================================================================== Installing: nginx x86_64 1:1.14.0-1.el7_4.ngx nginx 750 k Transaction Summary ====================================================================================== Install 1 Package Total download size: 750 k Installed size: 2.6 M Is this ok [y/d/N]: y Downloading packages: nginx-1.14.0-1.el7_4.ngx.x86_64.rpm | 750 kB 00:00:09 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:nginx-1.14.0-1.el7_4.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 : 1:nginx-1.14.0-1.el7_4.ngx.x86_64 1/1 Installed: nginx.x86_64 1:1.14.0-1.el7_4.ngx Complete! # 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/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.14.0 /usr/share/doc/nginx-1.14.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 |
1 2 |
# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# systemctl start nginx # systemctl status nginx * nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2018-09-21 14:28:38 JST; 5s ago Docs: http://nginx.org/en/docs/ Process: 1606 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 1607 (nginx) CGroup: /system.slice/nginx.service |-1607 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf `-1608 nginx: worker process Sep 21 14:28:38 www2.rootlinks.net systemd[1]: Starting nginx - high performance w.... Sep 21 14:28:38 www2.rootlinks.net systemd[1]: Started nginx - high performance we.... Hint: Some lines were ellipsized, use -l to show in full. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# firewall-cmd --permanent --add-service=http success # firewall-cmd --reload success # firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: ens33 sources: services: ssh dhcpv6-client http ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: |