首页 > 系统相关 >在 Debian 12.5 上编译安装 Nginx

在 Debian 12.5 上编译安装 Nginx

时间:2024-03-11 13:45:05浏览次数:22  
标签:http nginx -- module Nginx 12.5 local Debian

1. 更新系统软件包并安装必要的构建工具和依赖项:sudo apt update
sudo apt upgrade
sudo apt install build-essential zlib1g-dev libpcre3-dev libssl-dev
bash2. 下载 Nginx 源码包:wget http://nginx.org/download/nginx-x.y.z.tar.gz # 替换 x.y.z 为你要安装的 Nginx 版本号
tar zxf nginx-x.y.z.tar.gz
cd nginx-x.y.z
bash3. 配置 Nginx:./configure \
--prefix=/usr/local/nginx \
--user=www-data \
--group=www-data \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-file-aio \
--with-threads \
--with-compat \
--add-module=path/to/optional/module # 如果你有额外模块需要编译进去

# 注意替换 `path/to/optional/module` 为你实际的第三方模块路径
bash4. 编译和安装 Nginx:make
sudo make install
bash5. 创建系统启动所需的链接和服务文件(可选,根据你的启动方式):# 创建系统服务文件
sudo nano /etc/systemd/system/nginx.service

# 在文件中填入类似以下内容:
[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target

[Service]
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

# 保存退出,加载服务并启动 Nginx
sudo systemctl daemon-reload
sudo systemctl enable nginx
sudo systemctl start nginx

# 检查服务状态
sudo systemctl status nginx
bash注意事项:•请确保你在配置 Nginx 时包含了所有你所需要的模块,比如 SSL、HTTP2、PHP-FPM 等。•/usr/local/nginx 是 Nginx 的安装路径,你可以根据需要更改。•用户名 www-data 在 Debian 上通常是 Web 服务使用的默认用户和组,可以根据实际情况更改。•最新版 Nginx 的配置选项可能有所不同,请查阅 Nginx 官方文档以获得最新配置指南。记得根据实际情况调整命令中的路径和模块选项。同时,请始终关注 Nginx 官方发布的安全更新,并适时更新你的 Nginx 服务器。

标签:http,nginx,--,module,Nginx,12.5,local,Debian
From: https://www.cnblogs.com/jason-zhao/p/18065903

相关文章

  • 要确保请求在一次会话中被转发到相同的后端服务器上,可以使用 Nginx 的 ip_hash 或 sti
    要确保请求在一次会话中被转发到相同的后端服务器上,可以使用Nginx的ip_hash或sticky模块来实现。ip_hash模块:ip_hash 模块使用客户端IP地址作为哈希键,将同一IP地址的请求始终转发到相同的后端服务器。要启用 ip_hash 模块,只需在Nginx配置文件的 http 块或......
  • Tengine 安装 nginx-module-vts 模块
      使用Tengine作为反向代理服务器,发现Tengine日志中接口请求过慢,需要绘制grafana展示详细的接口情况------------------------------------------------------------------------------------------------------------------------------------解决思路#......
  • Ubuntu安装Nginx,并且解决问题
    Ubuntu安装Nginx,并且解决问题安装Nginxnginx-1.12.2首先下载Nginx的压缩包Nginx的压缩包然后在Ubuntu中创建一个目录,开始解压tar-zxvfnginx-1.12.2.tar.gz解压结束后在编译和安装Nginx之前,您需要安装一些依赖库。通常,Nginx需要openssl、pcre和zlib等库。sudoaptupdate......
  • nginx国密ssl测试
    文章目录文件准备编译部署nginx申请国密数字证书配置证书并测试文件准备下载文件并上传到服务器,这里使用centos7.8本文涉及的程序文件已打包可以直接下载。点击下载下载国密版opensslhttps://www.gmssl.cn/gmssl/index.jsp下载稳定版nginxhttp://nginx.org/en/download.html......
  • docekr-debian 11(bullseye)
    cat>/etc/apt/sources.list<<EOF#默认注释了源码镜像以提高aptupdate速度,如有需要可自行取消注释debhttps://mirrors.tuna.tsinghua.edu.cn/debian/bullseyemaincontribnon-free#deb-srchttps://mirrors.tuna.tsinghua.edu.cn/debian/bullseyemaincontribnon-......
  • nginx windows重启
    请注意,你需要以管理员权限运行命令提示符窗口才能执行这些命令。在Windows上重启Nginx服务,可以通过以下步骤实现:打开命令提示符窗口(按下Win+R键,输入cmd并回车)。进入Nginx安装目录的bin文件夹中。例如,如果Nginx安装在C:ginx目录下,则输入cdC:ginx\bin并回车。执行Nginx的重......
  • nginx如何配置多个vue项目?
    要在Nginx中配置多个Vue项目,您需要为每个项目设置不同的server块,并为每个项目提供不同的静态资源路径。以下是一个基本的配置示例:http{includemime.types;default_typeapplication/octet-stream;#第一个Vue项目的server配置server{l......
  • nginx部署vue项目
    第一步:打包第二步:地址映射http{server{listen8080;#设置端口号8080server_namelocalhost;#主机域名location/{......
  • nginx配置文件结构详解
    nginx配置文件(conf文件夹下nginx.conf文件为nginx配置文件)结构详解:main块(全局块):nginx全局信息,指令的相关配置events块:nginx工作模式,与用户网络连接的相关配置http块:http协议信息,代理,缓存,日志大多数功能和第三方模块的的相关配置server块:虚拟主机的相关配置(一个http块中可有......
  • 二级域名nginx 配置
     访问地址http://二级域名称.域名名称.com/server{   listen80;server_name二级域名称.一级域名xxxxx.com;location/{proxy_passhttp://localhost:8282;}}server{listen8282;server_namelocalhost;......