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

相关推荐
谙忆10246 小时前
前端图片直传对象存储:OSS/S3 预签名 URL、STS 临时凭证与回调校验
前端
RisunJan6 小时前
Linux命令-rlogin(远程登录)
linux·运维
深圳恒讯7 小时前
菲律宾云服务器与传统VPS的架构差异
运维·服务器·架构
蓝天下的守望者7 小时前
svt_apb_if里的宏定义问题
运维·服务器·数据库
小林ixn7 小时前
从“玩具工具”到“跨语言利器”:MCP 协议实战解析
运维·服务器·网络
CHNE_TAO_EMSM7 小时前
Android studio 打开文件时自动下载源码
前端·javascript·android studio
小顿的企业观察8 小时前
中企出海战略规划,正在从“走出去”转向“走进去”
大数据·运维·人工智能·产品运营·制造
数智化转型推荐官8 小时前
2026统一身份管理系统五大发展趋势解读
java·运维·微服务
看菜鸡互8 小时前
探索用 SlideML 让大模型生成 PPT 的实验方法
java·运维
一孤程8 小时前
Airtest自动化测试第五篇:小程序与Web测试——跨平台自动化全覆盖
前端·自动化测试·小程序·自动化·测试·airtest