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

相关推荐
m0_748233642 分钟前
RabbitMQ 进阶
android·前端·后端
likfishdn8 分钟前
Linux的文件与目录管理
linux·运维·服务器
渲染101专业云渲染9 分钟前
川翔云电脑优势总结
服务器·3d·电脑·blender·maya
不想有bug的小菜鸟11 分钟前
vue3使用iframe全屏展示pdf效果
前端·pdf
m0_7482386312 分钟前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
u01005596013 分钟前
前端代理,解决跨域问题讲解
前端
quitv18 分钟前
react脚手架配置别名
前端·javascript·react.js
m0_5287238126 分钟前
前端如何进行性能优化
前端·性能优化
chian-ocean27 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
化作繁星28 分钟前
在 Vue 3 中,如何缓存和复用动态组件
前端·vue.js·缓存