DevOps AI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
No Result
View All Result
Home DevOps & Cloud

Setup NGINX trên Centos7 không qua yum install

Hiếu Tạ by Hiếu Tạ
1 Tháng 5, 2025
in DevOps & Cloud
0
Setup NGINX trên Centos7 không qua yum install
Share on FacebookShare on Twitter

Một số lý do gì đó mà bạn không thể install nginx khi dùng lệnh yum install nginx. Nếu lười fix, suy nghĩ thì follow theo bài viết này để tiến hành cài nginx, setup config để chuẩn bị cho các mục đích như reverse proxy cho lẹ….

Cài đặt nginx

Step 1: Chạy Nginx 1.16.0 yêu cầu một số gói từ kho lưu trữ. Cài đặt bằng lệnh này:

yum install 
gcc 
zlib-devel 
openssl-devel 
make 
pcre-devel 
libxml2-devel 
libxslt-devel 
libgcrypt-devel 
gd-devel 
perl-ExtUtils-Embed 
GeoIP-devel

Related Post

Logging tomcat application trên ELK

Logging tomcat application trên ELK

30 Tháng 4, 2025
Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

1 Tháng 5, 2025

Series AWS EKS – Bài 4 – EKS Self Managed Node và EKS Managed Node Group

1 Tháng 5, 2025

Step 2: download nginx ở github. Này mình chọn version 1.16

curl -L https://github.com/nginx/nginx/archive/release-1.16.0.tar.gz > nginx-release-1.16.0.tar.gz
tar xf nginx-release-1.16.0.tar.gz

Step 3: Auto configure nginx
Tiếp tục cd vào thư mục vừa giải nén. Thực thi lệnh dưới đây, bạn có thể custom user/group của nginx cũng như đường dẫn sẽ cài nginx

auto/configure 
--with-pcre
--prefix=/u01/app/nginx/nginx-release-1.16.0/nginx
--user=root
--group=root
--with-threads
--with-file-aio
--with-http_ssl_module
--with-http_v2_module
--with-http_realip_module
--with-http_addition_module
--with-http_xslt_module=dynamic
--with-http_image_filter_module
--with-http_geoip_module=dynamic
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_auth_request_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_degradation_module
--with-http_slice_module
--with-http_stub_status_module
--without-http_charset_module
--with-http_perl_module
--with-mail=dynamic
--with-mail_ssl_module
--with-stream=dynamic
--with-stream_ssl_module
--with-stream_realip_module
--with-stream_geoip_module=dynamic
--with-stream_ssl_preread_module

Step 4: Thực thi tuần tự 2 câu lệnh make và make install

Sau khi chạy xong thì nó sẽ tự generate ra folder nginx như hình, folder nằm dựa trên đường dẫn bạn đã cấu hình ở lệnh auto/configure bên trên

Cấu hình với systemd

Để tạo file service, thực thi tuần tự theo các lệnh sau:

cd /etc/systemd/system

vi nginx.service

[Unit]
Description=nginx 1.16.0
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/u01/app/nginx/sysconfig/nginx-1.16.0
ExecStart=/u01/app/nginx/nginx-release-1.16.0/nginx/sbin/nginx $CLI_OPTIONS
ExecReload=/u01/app/nginx/nginx-release-1.16.0/nginx/sbin/nginx -s reload
ExecStop=/u01/app/nginx/nginx-release-1.16.0/nginx/sbin/nginx -s quit

[Install]
WantedBy=multi-user.target

cd /u01/app/nginx
mkdir sysconfig

vi nginx-1.66.0

# Command line options to use when starting nginx
#CLI_OPTIONS=""

systemctl daemon-reload

systemctl start nginx

Cài đặt Sites-Available

Để tiện hơn cho việc cấu hình các domain,… thay vì các bạn dùng chung nginx.conf thì thường ta sẽ setup thêm các conf

Step 1: Cấu hình sites-available, enabled

cd vào /u01/app/nginx/nginx-release-1.16.0/nginx

mkdir sites-available

mkdir sites-enabled

Thêm include /u01/app/nginx/nginx-release-1.16.0/nginx/sites-enabled/*; vào file /config/nginx.conf

cd sites-available

vi example.conf

server {
listen 80;
root /u01/app/html;
index index.html index.htm index.nginx.debian.html;

location / {
    try_files $uri $uri/ =404;
}
}

Step 2: Tạo symlink

ln -s /u01/app/nginx/nginx-release-1.16.0/nginx/sites-available/example.conf /u01/app/nginx/nginx-release-1.16.0/nginx/sites-enabled/

Step 3: Làm mẫu một file html để test

cd /u01/app

mkdir html

vi index.html => thêm vào nội dung test site-available

systemctl restart nginx

Chúc mọi người thành công!!!

Tags: centosnginxreverse proxy
Hiếu Tạ

Hiếu Tạ

Graduated as a Software Engineer. I have more than 3-year experience in developing software and DevOps, used to many services of AWS, and Azure, K8S, and using Windows or Linux on-premies proficiently to set up servers, proxy, build and deploy multiple programming languages (Java, GO, NET,...)..... Experience with CMS such SiteCore, ElasticPath, AEM... Implement CICD via Jenkins scripting, infrastructure as code via Terraform, and AWS Cloud Formation.

Related Posts

Logging tomcat application trên ELK
DevOps & Cloud

Logging tomcat application trên ELK

by Hiếu Tạ
30 Tháng 4, 2025
Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04
DevOps & Cloud

Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

by devopsify
1 Tháng 5, 2025
Series AWS EKS – Bài 4 – EKS Self Managed Node và EKS Managed Node Group
DevOps & Cloud

Series AWS EKS – Bài 4 – EKS Self Managed Node và EKS Managed Node Group

by Hiếu Tạ
1 Tháng 5, 2025
Next Post
Demo mount Amazon EFS vào nhiều EC2

Demo mount Amazon EFS vào nhiều EC2

Để lại một bình luận Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Recommended

Các website demo hay được sử dụng cho thực hành Automation Test

Các website demo hay được sử dụng cho thực hành Automation Test

11 Tháng 6, 2025
Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

1 Tháng 5, 2025
Cài đặt Maven trên Windows

Cài đặt Maven trên Windows

11 Tháng 6, 2025
Cài đặt Grafana – Loki – Promtail monitoring log Container

Cài đặt Grafana – Loki – Promtail monitoring log Container

1 Tháng 5, 2025
Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

16 Tháng 6, 2025
MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

16 Tháng 6, 2025
DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

13 Tháng 6, 2025
GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

11 Tháng 6, 2025
DevOpsify

Cộng đồng DevOps Việt Nam chia sẽ kiến thức giúp tăng tốc quá trình phát triển ứng dụng và tự động hóa trong lĩnh vực Cloud DevOps & AI.

Bài viết mới

  • Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent
  • MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật
  • DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

Categories

  • AI & Automation
  • Bảo mật
  • Chưa phân loại
  • DevOps & Cloud
  • Tin tức
No Result
View All Result
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud

© 2025 DevOpsify