suse 12 编译部署 Nginx

2024-05-13 03:58
文章标签 编译 部署 nginx suse

本文主要是介绍suse 12 编译部署 Nginx,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

      • 编译前准备
        • 创建nginx用户
        • 下载nginx源码包
        • 安装编译环境依赖
      • 编译nginx
      • 配置nginx为systemctl管理

Linux:~ # cat /etc/os-release
NAME="SLES"
VERSION="12-SP3"
VERSION_ID="12.3"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP3"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp3"

编译前准备

创建nginx用户
Linux:~ # useradd -ms /sbin/nologin nginx
Linux:~ # groupadd nginx
下载nginx源码包
Linux:~ # wget -c http://nginx.org/download/nginx-1.16.0.tar.gz
Linux:~ # tar xf nginx-1.16.0.tar.gz -C /usr/local/
安装编译环境依赖

gcc环境

Linux:~ # zypper in gcc gcc-c++ make

安装pcre软件包(使 nginx 支持 http rewrite 模块)

Linux:~ # wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
Linux:~ # tar xf pcre-8.44.tar.gz -C /usr/local/
  • 如果是Centos发行版,执行 yum install -y pcre pcre-devel

安装zlib

Linux:~ # zypper in libz1 zlib-devel
  • 如果是Centos发行版,执行 yum install -y zlib zlib-devel

安装gd

http_image_filter_module 需要gd库

Linux:~ # wget -c https://github.com/libgd/libgd/releases/download/gd-2.3.0/libgd-2.3.0.tar.gz
Linux:~ # tar xf libgd-2.3.0.tar.gz -C /usr/local/
Linux:~ # cd /usr/local/libgd-2.3.0/
Linux:/usr/local/libgd-2.3.0 # ./configure \
--bindir=/usr/sbin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--libdir=/usr/lib64 \
--mandir=/usr/share/man &&\
make && \
make install
  • 如果是Centos发行版,执行 yum install -y gd gd-devel

安装 openssl (使 nginx 支持 ssl

Linux:~ # zypper in openssl libopenssl-devel
  • 如果是Centos发行版,执行 yum install -y openssl openssl-devel

编译nginx

Linux:~ # cd /usr/local/nginx-1.16.0/
Linux:/usr/local/nginx-1.16.0 # ./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-pcre=/usr/local/pcre-8.44 \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module && \
make && \
make install

配置nginx为systemctl管理

Linux:~ # cat > /usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
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
PrivateTmp=true[Install]
WantedBy=multi-user.target
EOF
Linux:~ # systemctl daemon-reload
Linux:~ # systemctl enable nginx --now
Linux:~ # ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
Linux:~ # nginx -v
nginx version: nginx/1.16.0

这篇关于suse 12 编译部署 Nginx的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/984616

相关文章

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

nginx启动命令和默认配置文件的使用

《nginx启动命令和默认配置文件的使用》:本文主要介绍nginx启动命令和默认配置文件的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录常见命令nginx.conf配置文件location匹配规则图片服务器总结常见命令# 默认配置文件启动./nginx

Windows的CMD窗口如何查看并杀死nginx进程

《Windows的CMD窗口如何查看并杀死nginx进程》:本文主要介绍Windows的CMD窗口如何查看并杀死nginx进程问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录Windows的CMD窗口查看并杀死nginx进程开启nginx查看nginx进程停止nginx服务

Nginx Location映射规则总结归纳与最佳实践

《NginxLocation映射规则总结归纳与最佳实践》Nginx的location指令是配置请求路由的核心机制,其匹配规则直接影响请求的处理流程,下面给大家介绍NginxLocation映射规则... 目录一、Location匹配规则与优先级1. 匹配模式2. 优先级顺序3. 匹配示例二、Proxy_pa

Windows 系统下 Nginx 的配置步骤详解

《Windows系统下Nginx的配置步骤详解》Nginx是一款功能强大的软件,在互联网领域有广泛应用,简单来说,它就像一个聪明的交通指挥员,能让网站运行得更高效、更稳定,:本文主要介绍W... 目录一、为什么要用 Nginx二、Windows 系统下 Nginx 的配置步骤1. 下载 Nginx2. 解压

Nginx 413修改上传文件大小限制的方法详解

《Nginx413修改上传文件大小限制的方法详解》在使用Nginx作为Web服务器时,有时会遇到客户端尝试上传大文件时返回​​413RequestEntityTooLarge​​... 目录1. 理解 ​​413 Request Entity Too Large​​ 错误2. 修改 Nginx 配置2.1

Web技术与Nginx网站环境部署教程

《Web技术与Nginx网站环境部署教程》:本文主要介绍Web技术与Nginx网站环境部署教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Web基础1.域名系统DNS2.Hosts文件3.DNS4.域名注册二.网页与html1.网页概述2.HTML概述3.

NGINX 配置内网访问的实现步骤

《NGINX配置内网访问的实现步骤》本文主要介绍了NGINX配置内网访问的实现步骤,Nginx的geo模块限制域名访问权限,仅允许内网/办公室IP访问,具有一定的参考价值,感兴趣的可以了解一下... 目录需求1. geo 模块配置2. 访问控制判断3. 错误页面配置4. 一个完整的配置参考文档需求我们有一

使用Nginx配置文件服务器方式

《使用Nginx配置文件服务器方式》:本文主要介绍使用Nginx配置文件服务器方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1. 为什么选择 Nginx 作为文件服务器?2. 环境准备3. 配置 Nginx 文件服务器4. 将文件放入服务器目录5. 启动 N

Nginx路由匹配规则及优先级详解

《Nginx路由匹配规则及优先级详解》Nginx作为一个高性能的Web服务器和反向代理服务器,广泛用于负载均衡、请求转发等场景,在配置Nginx时,路由匹配规则是非常重要的概念,本文将详细介绍Ngin... 目录引言一、 Nginx的路由匹配规则概述二、 Nginx的路由匹配规则类型2.1 精确匹配(=)2