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
相关推荐
mit6.82410 分钟前
devops
运维·flask·devops
祈禾32 分钟前
Redis三大特殊数据类型
运维·服务器·数据库·redis·笔记·缓存
AAA@峥1 小时前
K8s 流量入口管理|Ingress 核心原理 + ingress-nginx 部署 + 生产实战案例合集
nginx·容器·kubernetes
mgaofeid1 小时前
Ubuntu 24.04 中文输入法安装
linux·运维·ubuntu
FIT2CLOUD飞致云2 小时前
学习笔记丨MaxKB原生工作流实现AI PPT生成
人工智能·ai·开源·智能体·maxkb
测试运维日常笔记3 小时前
RHEL/CentOS 离线部署指南:配置本地 ISO 镜像作为 YUM 仓库
linux·运维·centos
小马同学-3 小时前
负载均衡-LVS全解析
运维·负载均衡·lvs
HiDev_4 小时前
【非标自动化】硬核阅读理解620行梯形图-逆推工位逻辑
运维·自动化
dong_junshuai4 小时前
每天一个开源项目#67 Orca:4.3万星的并行 AI 编程控制台
程序员·开源·github
海兰4 小时前
【数据采集】开源的 Web 数据采集与处理Firecrawl(一)
前端·开源