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
相关推荐
杨杨杨大侠1 小时前
第1篇:走进日志框架的世界 - 从HelloWorld到企业级应用
java·开源·apache log4j
VVVVWeiYee1 小时前
TCP/UDP详解(一)
运维·网络·tcp/ip·udp·信息与通信
谢尔登2 小时前
【计算机网络】 IPV4和IPV6区别
运维·服务器·计算机网络
努力努力再努力wz2 小时前
【c++进阶系列】:万字详解多态
java·linux·运维·开发语言·c++
杭州泽沃电子科技有限公司2 小时前
工业环境电缆火灾预防的分布式光纤在线监测
运维·人工智能·科技·安全
zzz.103 小时前
Linux问答题:调优系统性能
linux·运维·云原生
Code_流苏3 小时前
DeepSeek V3.1深度解析:一个模型两种思维,迈向Agent时代的第一步!
开源·agent·思维·模型设计·deepseek·深度思索·dpv3.1
Lovyk3 小时前
完整实验命令解析:从集群搭建到负载均衡配置
linux·运维·服务器
Yyyy4823 小时前
MyCAT高可用
java·运维
Fireworkitte4 小时前
Ubuntu 系统 tar 包源码安装 Nginx
linux·nginx·ubuntu