首页 > 系统相关 >NGINX的编译安装

NGINX的编译安装

时间:2022-11-03 14:12:14浏览次数:32  
标签:http nginx -- apps NGINX 编译 conf 安装 CentOS8

实现步骤:

  • 1.安装编译工具

  • 2.创建运行NGINX的转有程序

  • 3.下载源码包并解压

  • 4.使用configure脚本生成makefile文件

  • 5.编译安装

  • 6.创建service文件

说明:

  源码安装需要提前准备标准的编译器,GCC的全称是(GNU Compiler collection),其有GNU开发,并以GPL即LGPL许可,是自由的类UNIX即苹果电脑Mac OS X操作系统的标准编译器,因为GCC原本只能处理C语言,所以原名为GNU C语言编译器,后来得到快速发展,可以处理C++,Fortran,pascal,objectiveC,java以及Ada等其他语言,此外还需要Automake工具,以完成自动创建Makefile的工作,Nginx的一些模块需要依赖第三方库,比如: pcre(支持rewrite),zlib(支持gzip模块)和openssl(支持ssl模块)等。

范例:CentOS8 编译安装nginx1.8

#安装编译工具
[root@CentOS8 ~]# yum -y install gcc make  pcre-devel openssl-devel zlib-devel


#创建转有用户
[root@CentOS8 ~]# useradd -r -s /sbin/nologin nginx

[root@CentOS8 ~]# id nginx
uid=988(nginx) gid=984(nginx) groups=984(nginx)

#下载软件包
地址:
https://nginx.org/en/download.html

http://nginx.org/download/

#解压源码包并编译
[root@CentOS8 nginx-1.18.0]#  mkdir /apps/nginx -p

[root@CentOS8 nginx-1.18.0]# ./configure --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --prefix=/apps/nginx

[root@CentOS8 nginx-1.18.0]# make -j 4 && make isntall
Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/apps/nginx"
  nginx binary file: "/apps/nginx/sbin/nginx"
  nginx modules path: "/apps/nginx/modules"
  nginx configuration prefix: "/apps/nginx/conf"
  nginx configuration file: "/apps/nginx/conf/nginx.conf"
  nginx pid file: "/apps/nginx/logs/nginx.pid"
  nginx error log file: "/apps/nginx/logs/error.log"
  nginx http access log file: "/apps/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

#创建service文件
[root@CentOS8 conf]# mkdir run

[root@CentOS8 conf]# vim conf/nginx.conf
pid        run/nginx.pid;


[root@CentOS8 ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/apps/nginx/run/nginx.pid
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target

标签:http,nginx,--,apps,NGINX,编译,conf,安装,CentOS8
From: https://www.cnblogs.com/heyongshen/p/16854271.html

相关文章

  • Elasticsearch安装部署
    本文只分享windows下安装流程安装版本为:elasticsearch-8.4.3kibana-8.4.3kibana汉化   双击运行 bin文件下的elas......
  • 如何在VM虚拟机里安装Linux系统
    很多企业在做数据抓取的时候往往需要多台服务器同时运行,在降低成本的同时还能方便操控服务器就显得尤为重要。这篇文章介绍了在VMware虚拟机里安装Linux操作系统的方法,文中......
  • LVS + keepalived + nginx + tomcat 实现主从热备 + 负载均衡
    前言首先声明下,由于这两天找资料,看了不少博客,但是出于不细心,参考者的博客地址没有记录下来,所有文中要是出现了与大家博客相同的地方,那么请大家在评论区说明并附上博客......
  • Ubuntu如何安装桌面
    1.源列表在哪?这个命令就可以修改了,通常你需要换源的时候需要。通常推荐使用阿里源、清华源等/etc/apt/sources.list就是源列表所在地址了。sudovi/etc/apt/sources.list......
  • nginx实现请求的负载均衡 + keepalived实现nginx的高可用
    前言使用集群是网站解决高并发、海量数据问题的常用手段。当一台服务器的处理能力、存储空间不足时,不要企图去换更强大的服务器,对大型网站而言,不管多么强大的服务器,都满......
  • chromedriver下载与安装方法,亲测可用
    chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.htmlhttp://npm.taobao.org/mirrors/chromedriver/两个地址都可以下载,根据自己的chrome浏览器的......
  • Windows 环境下安装python2.7虚拟环境
    1、检查是否安装virtualenv,不存在的话使用pipinstallvirtualenv安装2、创建虚拟环境virtualenv-ppython解释器路径虚拟环境目录3、切换到虚拟环境目录,并激活......
  • Python3-环境篇-01-Python3安装
     1.在python官网下载合适的python(windows)​编辑我这里下载了截至目前最新的3.10.2版本,推荐下载下方的稳定版本​编辑2选择合适的版本​编辑3安装Python(我这里默认安装路径,......
  • pd18.1.0虚拟机如何一键安装Windows 11 懒人版
    pd18.1.0虚拟机如何一键安装Windows11懒人版?入手了Mac电脑后,由于需要用到Windows软件,又嫌安装双系统太复杂,这时候Mac就用到了安装虚拟机,目前最好用的虚拟机是ParallelsD......
  • 在CentOS7下安装Oracle11教程
    前言安装oracle时,发现网上的文章总是缺少一些信息,导致安装不顺利,因为我对一些文章进行了整合,用以备忘。Oracle安装首先下载linux版本的oracle安装文件,然后通过XFTP上传......