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
相关推荐
白鲸开源9 小时前
Ubuntu 22 下 DolphinScheduler 3.x 伪集群部署实录
java·ubuntu·开源
算家计算10 小时前
模糊高清修复真王炸!ComfyUI-SeedVR2-Kontext(画质修复+P图)本地部署教程
人工智能·开源·aigc
weiwenhao11 小时前
关于 nature 编程语言
人工智能·后端·开源
LH_R17 小时前
OneTerm开源堡垒机实战(四):访问授权与安全管控
运维·后端·安全
Raymond运维18 小时前
MariaDB源码编译安装(二)
运维·数据库·mariadb
NocoBase18 小时前
GitHub 上 Star 数量前 10 的开源项目管理工具
开源·github·资讯
算家计算1 天前
7B参数拿下30个世界第一!Hunyuan-MT-7B本地部署教程:腾讯混元开源业界首个翻译集成模型
人工智能·开源
FIT2CLOUD飞致云1 天前
SQLBot开源智能问数系统成功进入GitHub趋势榜主榜,Star数突破2,000个!
开源
JuiceFS1 天前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
chen9452 天前
mysql 3节点mgr集群部署
运维·后端