วันเสาร์ที่ 16 ตุลาคม พ.ศ. 2564

Nginx for Linux Rocky

ใช้สิทธิ์ root เท่านั้น #

# dnf update && sudo dnf upgrade -y

# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y

# systemctl stop nginx

# dnf remove nginx

# dnf install dnf-utils -y

# 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

 # yum-config-manager --enable nginx-mainline

# dnf install nginx

# systemctl start nginx

# systemctl enable nginx

# nginx -v

** หมายเหตุเอาไว้หน่อยถ้ามี error (13: Permission denied) while connecting to upstream:[nginx]

# setsebool -P httpd_can_network_connect 1

** สร้างไฟล์ชื่อ domainxxx.com.conf เอาไปไว้ที่ /etc/nginx/conf.d/

upstream ForntEnd {
    server 127.0.0.1:8001;
}

server {
    listen       80;
    server_name  domainxxx.com;

    access_log /var/log/nginx/domainxxx.com_access.log main ;
    error_log /var/log/nginx/domainxxx.com_error.log ;

    location / {
        proxy_pass  http://ForntEnd;
    }
}


เพิ่ม goaccess สำหรับ Monitor log แบบเท่ๆ

# yum install goaccess

** จากนั้นท าการแก้ไขไฟล์ /etc/goaccess.conf โดยเอา # จากแถวต่อไปนี้

time-format %H:%M:%S

date-format %d/%b/%Y

log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"

** ทดสอบ

# goaccess -f /var/log/nginx/access.log

# goaccess -f /var/log/nginx/access.log > /usr/share/nginx/html/report.html