基于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:

相关推荐
妮妮喔妮21 小时前
supabase的webhook报错
开发语言·前端·javascript
cccccc语言我来了21 小时前
C++轻量级消息队列服务器
java·服务器·c++
xiaoshuaishuai821 小时前
C# Codex 脚本编写
java·服务器·数据库·c#
yivifu21 小时前
手搓HTML双行夹批效果
前端·html·html双行夹注
Ai173163915791 天前
GB200 NVL72超节点深度解析:架构、生态与产业格局
大数据·服务器·人工智能·神经网络·机器学习·计算机视觉·架构
奔跑的卡卡1 天前
Web开发与AI融合-第一篇:Web开发与AI融合的时代序幕
前端·人工智能
思茂信息1 天前
CST交叉cable的串扰(crosstalk)仿真
服务器·开发语言·人工智能·php·cst
IT_陈寒1 天前
Redis批量删除的大坑,差点让我加班到天亮
前端·人工智能·后端
weixin_449173651 天前
Linux -- 项目中查找日志的常用Linux命令
linux·运维·服务器
帆张芳显1 天前
智表ZCELL产品V3.6 版发布,新增系统预置右键菜单操作、页签栏操作等功能
前端·canva可画·excel插件