基于Centos7的Nginx源码安装

目录

1、准备安装环境

2、获取tar包:

3、解压创建软链接

4、创建用户和组

5、执行安装

6、创建服务脚本

7、开启nginx:​编辑​编辑


1、准备安装环境

bash 复制代码
yum insatall -y make gcc gcc-c++ pcre-devel
#pcre-devel -- pcre库
#安装openssl-devel
yum install -y openssl-devel

2、获取tar包:

Index of /download/

3、解压创建软链接

bash 复制代码
tar -xf nginx-1.22.0.tar.gz -C /usr/local/
ln -s /usr/local/nginx-1.22.0/ /usr/local/nginx

4、创建用户和组

bash 复制代码
groupadd -r nginx
useradd nginx -u 996 -r -g 996 -c "nginx user"

5、执行安装

bash 复制代码
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

make && make

6、创建服务脚本

bash 复制代码
#vim /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/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=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

#systemctl daemon-reload

7、开启nginx:

相关推荐
大文说跨境3 分钟前
多账号环境隔离方案技术选型:指纹浏览器、VPS 与云手机的三种架构对比
java·开发语言·前端
咕白m6255 分钟前
使用 C# 将 TIFF 转换为 PDF
前端·c#
全栈项目管理程序猿7 分钟前
ArcGIS JS 基础教程(28):图层渲染顺序管理
前端·javascript
huakoh11 分钟前
MCP 工具报错走哪条通道:三条探针的最小复现检查
前端
用户0333074139518 分钟前
ParadeDB 的 pg_search 0.26 把十词 BM25 搜索从 129ms 降到 29ms
前端
帷幕落秋21 分钟前
内存、虚拟内存与 OOM
linux·运维
Joy T21 分钟前
从 Nginx 到 Gateway 再到微服务:一次 AI 请求的完整链路
nginx·微服务·gateway·controller·路由转发·ai service·接口错误排查
不爱说话郭德纲27 分钟前
从“点点点”到一键出包:我把 uni-app x Android 离线打包做成了脚本
android·前端·uni-app
mengge.cloud31 分钟前
Redis
运维·服务器·数据库·redis·缓存·云计算
Lstone736434 分钟前
从 Jetpack Compose 到 CMP:跨平台开发学习笔记
前端