LoginSignup
15
19

More than 5 years have passed since last update.

CentOS7 に Nginx をインストールする

Posted at

前提

  • サーバOS: ContOS 7
  • Root 権限が付与されている、または使用可能であること
  • 外部IPアドレス(または独自ドメイン)を取得済みであること

手順

以降、管理者権限 (Root) で実行可能なユーザで行うこと。

リポジトリ作成

OS のベースリポジトリには Nginx は無いため、リポジトリを新たに追加する。
下記のとおりに、nginx.repo のファイルを作成。

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

記載内容は以下

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

記載したら Esc:wq で保存して終了。

インストール実施

# nginxをインストール (質問は全て「Y」で肯定)
sudo yum install nginx

# バージョンの確認
nginx -v

# 自動起動設定 (初回の場合はシンボリックリンクが作成される)
sudo systemctl enable nginx

# 起動
sudo systemctl start nginx

Web ブラウザ表示確認

http://外部IPアドレス または http://独自ドメイン にアクセスし、以下のように表示されたら成功

スクリーンショット 2019-01-04 16.47.44.png

Nginx のインストールは以上。

15
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
19