Skip to content

Instantly share code, notes, and snippets.

@yukikim
Last active September 20, 2019 02:28
Show Gist options
  • Save yukikim/4c5868fc5ff49e678be5e0ae265febf0 to your computer and use it in GitHub Desktop.
Save yukikim/4c5868fc5ff49e678be5e0ae265febf0 to your computer and use it in GitHub Desktop.
nginxインストール CentOS7

====Nginx インストール===================================

$ sudo yum install http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

repoファイル作成

$ sudo vi /etc/yum.repos.d/nginx.repo

以下を記述する

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1

$ sudo yum install nginx

$ sudo yum update

$ sudo yum install --enablerepo=nginx nginx

サービス有効化

$ sudo systemctl enable nginx

nginx起動

$ sudo systemctl start nginx

設定ファイル

/etc/nginx/conf.d/default.conf

公開ファイル

/usr/share/nginx/html/index.html

起動

$ sudo systemctl start nginx

停止

$ sudo systemctl stop nginx

再起動

$ sudo systemctl restart nginx

再起動しても設定ファイルが反映されない場合など

$ sudo nginx -s reload

状態の確認

$ sudo systemctl status nginx

=======================================================

listenしているサービスを確認

$ ss -lt

http(ポート80)の許可

$ sudo firewall-cmd --add-service=http --permanent

$ sudo firewall-cmd --reload

https(443)の許可

$ sudo firewall-cmd --add-service=https --permanent 

$ sudo firewall-cmd --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment