首页 > 系统相关 >nginx编译安装

nginx编译安装

时间:2023-04-05 22:14:24浏览次数:42  
标签:sbin 编译 安装 nginx params usr conf local

常用版本介绍

安装

# 安装必要的库
yum install -y gcc pcre pcre-devel zlib zlib-devel

# 下载并安装
wget https://nginx.org/download/nginx-1.23.4.tar.gz
tar zxf nginx-1.23.4.tar.gz
cd nginx-1.23.4
./configure --prefix=/usr/local/nginx
make && make install

常用命令

cd /usr/local/nginx/sbin
# 查看帮助
./nginx -h
# 启动
./nginx
#快速停止
./nginx -s stop
#优雅关闭,退出前完成已经接受的请求
./nginx -s quit
#重新加载配置
./nginx -s reload

关闭防火墙

如果正常启动后不能正常访问,则可能是防火墙导致的,本地环境可以直接禁用掉防火墙

# 关闭并禁止开机启动
systemctl stop firewalld
systemctl disable firewalld

安装成系统服务

vi /usr/lib/systemd/system/nginx.service

[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.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
# 启动nginx
systemctl start nginx
systemctl status nginx

# 开机启动
systemctl enable nginx.service

目录结构

[root@localhost nginx]# tree conf/ html/ logs/ sbin/
conf/
├── fastcgi.conf
├── fastcgi.conf.default
├── fastcgi_params
├── fastcgi_params.default
├── koi-utf
├── koi-win
├── mime.types
├── mime.types.default
├── nginx.conf #主要配置文件,会引用其它配置文件
├── nginx.conf.default
├── scgi_params
├── scgi_params.default
├── uwsgi_params
├── uwsgi_params.default
└── win-utf
html/ #默认静态网站目录
├── 50x.html
└── index.html
logs/
├── access.log #访问日志
├── error.log #错误日志
└── nginx.pid #进程id
sbin/
└── nginx #主进程文件

标签:sbin,编译,安装,nginx,params,usr,conf,local
From: https://www.cnblogs.com/dylmys/p/17290740.html

相关文章

  • Linux静默安装Oracle21C
    Linux静默安装Oracle21C1、修改主机名及配置hosts[root@localhost~]#hostname #查看主机名[root@localhost~]#hostnameoracledb #修改主机名[root@localhost~]#vim/etc/hosts #修改hosts[root@localhost~]#cat/etc/hosts2、关闭selinux和防火墙[root@l......
  • 【重要】Nginx模块Lua-Nginx-Module学习笔记(三)Nginx + Lua + Redis 已安装成功(非open
    一、目标使用Redis做分布式缓存;使用luaAPI来访问redis缓存;使用nginx向客户端提供服务,ngx_lua将lua嵌入到nginx,让nginx执行lua脚本,高并发,非阻塞的处理各种请求。url请求nginx服务器,然后lua查询redis,返回json数据。二、准备工作系统环境:Ubuntu14.0(64位)Redis服务安装:ap......
  • 【精选】Nginx负载均衡学习笔记(一)实现HTTP负载均衡和TCP负载均衡(官方和OpenResty两种
    说明:很简单一个在HTTP模块中,而另外一个和HTTP是并列的Stream模块(Nginx1.9.0支持)一、两个模块的最简单配置如下1、HTTP负载均衡:http{includemime.types;default_typeapplication/octet-stream;upstreamlive_node{server127.0.......
  • Ubuntu安装opencv
    下载源码https://opencv.org/releases/下载3.x.x的版本网上的代码都用的3你下4会到处报错安装依赖sudoapt-getinstallbuild-essentialsudoapt-getinstallcmakegitlibgtk2.0-devpkg-configlibavcodec-devlibavformat-devlibswscale-devsudoapt-getinstallpy......
  • 【官方文档】Nginx模块Nginx-Rtmp-Module学习笔记(二)HLS 指令详解
    源码地址:https://github.com/Tinywan/PHP_Experience一、在Nginx配置文件的RTMP模块中配置hlshls_key_path/tmp/hlskeys;提示错误信息:nginx:[emerg]thesamepathname"/data/hlskeys"usedin/usr/local/nginx/conf/nginx.conf:178andin/usr/local/nginx/conf/nginx......
  • 【官方文档】Nginx模块Nginx-Rtmp-Module学习笔记(一) RTMP 命令详解
    源码地址:https://github.com/Tinywan/PHP_Experience说明:rtmp的延迟主要取决于播放器设置,但流式传输软件,流的比特率和网络速度(以及响应时间“ping”)可能会对延迟产生影响,具有播放器的本地rtmp服务器使用“否”缓冲区(如0.1-0.2秒缓冲区等)可能会在0.8-1.2秒之间总是延迟,当事情正......
  • PHP 文件加密Zend Guard Loader 学习和使用(如何安装ioncube扩展对PHP代码加密)
    一、大体流程图二、PHP项目文件加密 下表列出了Zend产品中的PHP版本及其内部API版本和Zend产品版本。如何加密请往后看三、如何使用第一步:确认当前环境AmaiPhalcon前,请确认您具备以下两个条件,如果您的环境不满足此条件,建议您对系统环境进行重新配置。条件1:PHP版本在5.5.X以上(......
  • Nginx鉴权功能实现
    背景鉴权的功能是防止盗链,别人一直访问你的连接,把你的服务器打爆,当鉴权失败时(md5值计算错误、时间戳过期),nginx直接返回403。鉴权主要分为四种:时间戳鉴权远程鉴权Referer黑白名单IP黑白名单在使用上,一般推荐时间戳鉴权和远程鉴权,或者两者同时使用,剩下两项规避鉴权非常容易......
  • Ubuntu安装eigen3
    Eigen是C++语言里的一个开源模版库,支持线性代数运算,矩阵和矢量运算,数值分析及其相关的算法。下载源码https://github.com/eigenteam/eigen-git-mirror编译安装mkdirbuildcdbuildcmake..make-j24sudomakeinstall编译之后只会产生头文件,头文件就有so的功能,但是......
  • Ubuntu安装ceres
    下载源码ceres-solver/ceres-solver:Alargescalenon-linearoptimizationlibrary(github.com)安装依赖sudoapt-getinstallliblapack-devlibsuitesparse-devlibcxsparse3libgflags-devlibgoogle-glog-devlibgtest-dev我还是提一下,linux经常听说什么依赖依赖,其......