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

相关推荐
欲买桂花同载酒5821 天前
程序人生-Hello’s P2P
运维·服务器·数据库
八月的雨季 最後的冰吻1 天前
FFmepg-- 38-Jitter Buffer固定值c程序分析
服务器·音视频
tryqaaa_1 天前
md5和sha1常见绕过【详细附新生赛题目】
web安全·php·web
NineData1 天前
AI时代的数据对比:DBA还需要盯着屏幕看差异吗?
运维·数据库
Rsun045511 天前
React相关面试题
前端·react.js·前端框架
jyfool1 天前
Ubuntu 远程桌面配置踩坑实录:从 TightVNC 到 x11vnc 的折腾之旅
linux·运维·ubuntu
鹏多多.1 天前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter·ios·前端框架
网硕互联的小客服1 天前
服务器防火墙是如何区分正常流量和攻击流量?
运维·服务器·网络