CentOS Stream 8にnginxをインストールする方法
1.nginxのリポジトリを追加
# vi /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
2.nginxをインストール
# yum install nginx
略 これでよろしいですか? [y/N]:y 略 インストール済み: nginx-1:1.18.0-2.el8.ngx.x86_64 完了しました!
3.nginxバージョン確認
# nginx -v
nginx version: nginx/1.18.0
4.nginxで使用するポートの変更(80ポート既に利用)
# vi /etc/nginx/conf.d/default.conf
修正前
listen 80;
修正後
listen 85;
5.nginxを自動起動にする
# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
nginxを起動
# 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 Tue 2021-03-16 18:31:10 JST; 7min ago
Docs: http://nginx.org/en/docs/
Main PID: 11607 (nginx)
Tasks: 2 (limit: 11079)
6.「welcome」画面を確認
# curl http://localhost:85
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
7.FireWallを設定
# firewall-cmd –add-port=85/tcp –permanent
success
# firewall-cmd –reload
success
8.ブラウザ確認
http://192.168.229.129:85/