一、環(huán)境說明
操作系統(tǒng)版本:OpenEuler22.03 SP2 LTS
Nginx版本:1.24.0
安裝位置:/app/nginx
Selinux配置:關(guān)閉或設(shè)置為permissive
二、Nginx安裝
# 安裝必要依賴
dnf -y install tar gcc make pcre pcre-devel zlib zlib-devel openssl openssl-devel
# 創(chuàng)建nginx安裝文件夾
mkdir /app/nginx
# 下載nginx源碼包 (下載到了/app下)
wget https://nginx.org/download/nginx-1.24.0.tar.gz
# 解壓源碼包
tar -zxvf nginx-1.24.0.tar.gz
# 安裝nginx
cd /app/nginux-1.24.0;
# 配置nginx安裝路徑及安裝模塊
./configure --prefix=/app/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_gzip_static_module --with-pcre
#--prefix 指定安裝路徑
#--with-http_stub_status_module 允許查看nginx狀態(tài)的模塊
# --with-http_ssl_module 支持https的模塊
# 編譯&&安裝
make && make install
修改nginx運行用戶為root:
vi /app/nginx/config/nginx.conf
# 移除user nobody 前的“#”,修改noby為root
設(shè)置nginx開機自啟:
# 創(chuàng)建啟動腳本
vi /etc/systemd/system/nginx.service
nginx.service內(nèi)容:
[Unit]
Description=nginx
After=network.target[Service]
Type=forking
ExecStart=/app/nginx/sbin/nginx -c /app/nginx/conf/nginx.conf
ExecReload=/app/nginx/sbin/nginx -s reload
ExecStop=/app/nginx/sbin/nginx -s quit
PrivateTmp=true[Install]
WantedBy=multi-user.target
# 重載配置
systemctl daemon-reload
# 加入自啟
systemctl enable nginx
# 啟動nginx
systemctl start nginx
防火墻放行端口:文章來源:http://www.zghlxwxcb.cn/news/detail-761512.html
# 配置防火墻放行5432端口
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --add-port=443/tcp --permanent
# 重新加載防火墻配置文件
sudo firewall-cmd --reload
本文作者: Mr Liu
本文鏈接: https://it-liupp.gitee.io/2023/12/20/openeuler-install-nginx/
博客園鏈接:https://www.cnblogs.com/boyliupan/p/17934108.html
版權(quán)聲明: 本博客所有文章除特別聲明外,均采用 BY-NC-SA 許可協(xié)議。轉(zhuǎn)載請注明出處!文章來源地址http://www.zghlxwxcb.cn/news/detail-761512.html
到了這里,關(guān)于OpenEuler22.03源碼編譯安裝nginx1.24.0的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!