Nginx 开源版安装

下载 tar.gz安装包,上传。

解压

sh 复制代码
[root@localhost ~]# tar zxvf nginx-1.21.6.tar.gz
nginx-1.21.6/
nginx-1.21.6/auto/
nginx-1.21.6/conf/
nginx-1.21.6/contrib/
nginx-1.21.6/src/
... ...

安装gcc

sh 复制代码
[root@localhost nginx-1.21.6]# yum install -y gcc
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.nju.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
base                                                                                                                                                                 

进入Nginx 目录,配置

sh 复制代码
# 后面是安装目录
[root@localhost nginx-1.21.6]# ./configure --prefix=/usr/local/nginx

安装 perl 库
yum install -y pcre pcre-devel

安装zlib库
yum install -y zlib zlib-devel

编译

sh 复制代码
./configure --prefix=/usr/local/nginx

make
make install

查看

sh 复制代码
[root@localhost nginx-1.21.6]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  include  lib  lib64  libexec  nginx  sbin  share  src


[root@localhost local]# cd nginx/sbin/
[root@localhost sbin]# ls
nginx
# 启动nginx
[root@localhost sbin]# ./nginx

配置系统服务
vi /usr/lib/systemd/system/nginx.service

服务脚本内容

sh 复制代码
[unit]
Description=nginx - web server
After=network.target remote-fs.target nss-Tookup,target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
wantedBy=multi-user.target

重新加载系统服务

选择语言
systemctl daemon-reload

sh 复制代码
systemctl start nginx 
systemctl status nginx
systemctl reload nginx
systemctl stop nginx
相关推荐
ARM|X86+FPGA工业主板厂家7 分钟前
基于嵌入式 GPU 的智能服务机器人
linux·运维·arm开发·fpga开发·机器人
pt104328 分钟前
网络自动化Python课程:Python与Linux密钥和敏感信息管理介绍
运维·自动化
严谨的麻辣烫35 分钟前
2026 年静态 IP 为什么重新受到关注?从住宅代理安全问题看固定网络出口
运维·服务器·tcp/ip·网络安全
云智慧AIOps社区37 分钟前
2026年智能巡检机器人行业格局:三类厂商阵营、选型维度与产品推荐
运维·人工智能·机器人·巡检机器人
shengchanxian11 小时前
2026年9月服务器装配流水线厂家技术测评:对标国标的硬件评判逻辑
运维·服务器·服务器装配流水线厂家
云运维笔记2 小时前
Zabbix 监控实战:Nginx、MySQL 与 Java 程序配置指南
mysql·nginx·zabbix
挨踢诗人2 小时前
金蝶云星空 × 乐企平台 直连数电票集成解决方案(农产品收购发票自动化)
运维·自动化
Acrellea2 小时前
适配新标准!AIM-T500L 助力算力中心 800V 直流系统安全运维
运维·安全·系统安全
楠楠子呀2 小时前
Walink 技术博客:从原理到实战的完整指南
运维·自动化·testlink