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

相关推荐
小王C语言20 小时前
Linux基础开发工具----yum、vim和gcc/g++
linux·运维·服务器
布列瑟农的星空20 小时前
后台类项目如何挖掘前端技术亮点
前端·面试
newxtc20 小时前
【辽宁政务服务网-注册_登录安全分析报告】
运维·selenium·安全·政务·安全爆破
自由生长202420 小时前
Nginx的代理原理和使用配置
网络协议·nginx
_w_z_j_20 小时前
Linux----文件系统
linux·运维·服务器
wangbing112521 小时前
layui窗口标题
前端·javascript·layui
测试-鹏哥21 小时前
要将ITP集成到Jenkins Pipeline中,实现开发发版时自动触发自动化测试
运维·python·测试工具·ci/cd·jenkins
qq_3985865421 小时前
Utools插件实现Web Bluetooth
前端·javascript·electron·node·web·web bluetooth
李剑一21 小时前
mitt和bus有什么区别
前端·javascript·vue.js
VisuperviReborn21 小时前
React Native 与 iOS 原生通信:从理论到实践
前端·react native·前端框架