Nginx 开源版安装

下载 tar.gz安装包,上传。

解压

sh 复制代码
[root@localhost ~]# tar zxvf nginx-1.21.6.tar.gz
nginx-1.21.6/
nginx-1.21.6/auto/
nginx-1.21.6/conf/
nginx-1.21.6/contrib/
nginx-1.21.6/src/
... ...

安装gcc

sh 复制代码
[root@localhost nginx-1.21.6]# yum install -y gcc
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.nju.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
base                                                                                                                                                                 

进入Nginx 目录,配置

sh 复制代码
# 后面是安装目录
[root@localhost nginx-1.21.6]# ./configure --prefix=/usr/local/nginx

安装 perl 库
yum install -y pcre pcre-devel

安装zlib库
yum install -y zlib zlib-devel

编译

sh 复制代码
./configure --prefix=/usr/local/nginx

make
make install

查看

sh 复制代码
[root@localhost nginx-1.21.6]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  include  lib  lib64  libexec  nginx  sbin  share  src


[root@localhost local]# cd nginx/sbin/
[root@localhost sbin]# ls
nginx
# 启动nginx
[root@localhost sbin]# ./nginx

配置系统服务
vi /usr/lib/systemd/system/nginx.service

服务脚本内容

sh 复制代码
[unit]
Description=nginx - web server
After=network.target remote-fs.target nss-Tookup,target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/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=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
wantedBy=multi-user.target

重新加载系统服务

选择语言
systemctl daemon-reload

sh 复制代码
systemctl start nginx 
systemctl status nginx
systemctl reload nginx
systemctl stop nginx
相关推荐
小黑_深呼吸21 分钟前
Prometheus实战教程:k8s平台-Mysql监控案例
运维·学习·kubernetes·prometheus
说私域38 分钟前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的低集中度市场运营策略研究
人工智能·小程序·开源·零售
疯狂的挖掘机1 小时前
记一次从windows连接远程Linux系统来控制设备采集数据方法
linux·运维·windows
忧郁的狐狸1 小时前
Jenkins 安装与配置指南
运维·jenkins
charles_vaez1 小时前
开源模型应用落地-模型上下文协议(MCP)-Resources-资源的使用逻辑
深度学习·语言模型·自然语言处理·开源
sy_cora1 小时前
IEEE 列表会议第五届机器人、自动化与智能控制国际会议
运维·人工智能·机器人·自动化
一个没有感情的程序猿2 小时前
当 PyIceberg 和 DuckDB 遇见 AWS S3 Tables:打造 Serverless 数据湖“开源梦幻组合”
开源·serverless·aws
yzx9910132 小时前
Gensim 是一个专为 Python 设计的开源库
开发语言·python·开源
数巨小码人2 小时前
Linux常见命令
大数据·linux·运维·服务器·elasticsearch·搜索引擎
时序数据说2 小时前
IoTDB集群的一键启停功能详解
大数据·数据库·开源·时序数据库·iotdb