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
相关推荐
一梦浮华28 分钟前
自学嵌入式 day30 IPC:进程间通信
linux·运维·服务器
精英的英1 小时前
在Ubuntu 24.04主机上创建Ubuntu 14.04编译环境的完整指南
linux·运维·ubuntu
求索小沈1 小时前
ubuntu22.04安装anaconda
linux·运维·服务器
斯普信专业组1 小时前
K8s环境下基于Nginx WebDAV与TLS/SSL的文件上传下载部署指南
nginx·kubernetes·ssl
JAVA拾贝1 小时前
Prometheus+Grafana运维监控并实现钉钉告警
运维·钉钉·grafana·prometheus·运维监控
数通Dinner1 小时前
异步Websocket构建聊天室
运维·网络·websocket·网络协议·信息与通信
字节跳动开源2 小时前
AI 体验走查 - 火山引擎存储的 AI UX 探索之路
开源
云动雨颤2 小时前
Python 自动化办公神器|一键转换所有文档为 PDF
运维·python
九分源码2 小时前
基于PHP+MySQL组合开发开源问答网站平台源码系统 源码开源可二次开发 含完整的搭建指南
mysql·开源·php
Fanmeang2 小时前
OSPF高级特性之FRR
运维·网络·华为·ip·ospf·spf·frr