Linux下Nginx编译安装过程详解

  • 一、Nginx介绍
  • 二、Nginx源码下载
    • 1.打开Nginx官网
    • 2.下载官网的源码包
  • 三、Nginx源码安装
    • 1.解压源码包
    • 2.安装开发包组及环境
    • 3.编译Nginx源码
  • 四、Nginx启动与检查

一、Nginx介绍

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。
从2004年发布至今,凭借开源的力量,已经接近成熟与完善。
Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。支持FastCGI、SSL、Virtual Host、URL Rewrite、Gzip等功能。并且支持很多第三方的模块扩展。Nginx的稳定性、功能集、示例配置文件和低系统资源的消耗让他后来居上,在全球活跃的网站中有12.18%的使用比率,大约为2220万个网站。

二、Nginx源码下载

1.打开Nginx官网

Nginx官网

2.下载官网的源码包


# 下载文件为nginx-1.18.0 .tar  Nginx的源码包版本为1.18.0

三、Nginx源码安装

1.解压源码包

[root@node1 ~]# ll
total 1028
-rw-------. 1 root root    1608 Mar 19 22:27 anaconda-ks.cfg
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Desktop
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Documents
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Downloads
-rw-r--r--. 1 root root     378 May  2 20:57 dvd.repo
-rw-r--r--. 1 root root       0 May  5 12:47 file
-rw-r--r--. 1 root root    1763 Mar 19 22:32 initial-setup-ks.cfg
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Music
-rw-r--r--. 1 root root 1039530 May  8 13:19 nginx-1.18.0.tar.gz
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Pictures
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Public
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Templates
drwxr-xr-x. 2 root root       6 Mar 19 22:33 Videos
[root@node1 ~]# tar -xf nginx-1.18.0.tar.gz
[root@node1 ~]# ll
total 1028
-rw-------. 1 root    root       1608 Mar 19 22:27 anaconda-ks.cfg
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Desktop
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Documents
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Downloads
-rw-r--r--. 1 root    root        378 May  2 20:57 dvd.repo
-rw-r--r--. 1 root    root          0 May  5 12:47 file
-rw-r--r--. 1 root    root       1763 Mar 19 22:32 initial-setup-ks.cfg
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Music
drwxr-xr-x. 8 ansible ansible     158 Apr 21  2020 nginx-1.18.0
-rw-r--r--. 1 root    root    1039530 May  8 13:19 nginx-1.18.0.tar.gz
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Pictures
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Public
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Templates
drwxr-xr-x. 2 root    root          6 Mar 19 22:33 Videos

2.安装开发包组及环境

yum -y groupinstall "Development Tools"
[root@node1 ~]# yum -y install pcre-devel zlib-devel make
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
ansiable                                                                                                                            0.0  B/s |   0  B     00:00
Failed to synchronize cache for repo 'ansiable', ignoring this repo.
Last metadata expiration check: 0:03:40 ago on Sat 08 May 2021 01:33:26 PM CST.
Package make-1:4.2.1-9.el8.x86_64 is already installed.
Dependencies resolved.
====================================================================================================================================================================Package                                 Arch                                Version                                      Repository                           Size
====================================================================================================================================================================
Installing:pcre-devel                              x86_64                              8.42-4.el8                                   BaseOS                              551 kzlib-devel                              x86_64                              1.2.11-10.el8                                BaseOS                               56 k
Installing dependencies:pcre-cpp                                x86_64                              8.42-4.el8                                   BaseOS                               47 kpcre-utf16                              x86_64                              8.42-4.el8                                   BaseOS                              195 kpcre-utf32                              x86_64                              8.42-4.el8                                   BaseOS                              186 kTransaction Summary
====================================================================================================================================================================
Install  5 PackagesTotal size: 1.0 M
Installed size: 2.7 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing        :                                                                                                                                            1/1 Installing       : pcre-utf32-8.42-4.el8.x86_64                                                                                                               1/5 Installing       : pcre-utf16-8.42-4.el8.x86_64                                                                                                               2/5 Installing       : pcre-cpp-8.42-4.el8.x86_64                                                                                                                 3/5 Installing       : pcre-devel-8.42-4.el8.x86_64                                                                                                               4/5 Installing       : zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5 Running scriptlet: zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5 Verifying        : pcre-cpp-8.42-4.el8.x86_64                                                                                                                 1/5 Verifying        : pcre-devel-8.42-4.el8.x86_64                                                                                                               2/5 Verifying        : pcre-utf16-8.42-4.el8.x86_64                                                                                                               3/5 Verifying        : pcre-utf32-8.42-4.el8.x86_64                                                                                                               4/5 Verifying        : zlib-devel-1.2.11-10.el8.x86_64                                                                                                            5/5
Installed products updated.Installed:pcre-devel-8.42-4.el8.x86_64    zlib-devel-1.2.11-10.el8.x86_64    pcre-cpp-8.42-4.el8.x86_64    pcre-utf16-8.42-4.el8.x86_64    pcre-utf32-8.42-4.el8.x86_64   Complete!

3.编译Nginx源码

 ./configure
checking for OS+ Linux 4.18.0-80.el8.x86_64 x86_64
checking for C compiler ... found+ using GNU C compiler+ gcc version: 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for EPOLLEXCLUSIVE ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint32_t ... found
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for clock_gettime(CLOCK_MONOTONIC) ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for ioctl(FIONREAD) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/MakefileConfiguration summary+ using system PCRE library+ OpenSSL library is not used+ using system zlib librarynginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/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"
make && make install

四、Nginx启动与检查


[root@node1 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[root@node1 sbin]# netstat -tunlp |grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      39424/nginx: master
[root@node1 sbin]# ps -ef |grep nginx
root      39424      1  0 14:01 ?        00:00:00 nginx: master process ./nginx
nobody    39425  39424  0 14:01 ?        00:00:00 nginx: worker process
root      39462   1884  0 14:02 pts/0    00:00:00 grep --color=auto nginx

Linux下Nginx编译安装过程详解相关推荐

  1. linux nginx编译详解,Linux下nginx编译安装教程和编译参数详解

    这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备 1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码 代码如下:# ...

  2. CentOS下DB2数据库安装过程详解

    这篇文章主要介绍了CentOS下DB2数据库安装过程详解,本文步骤详细,操作的命令也比较全 安装前请查看DB2版本和许可证说明来增加了解,先弄明白改安装什么版本,这里我用的是最新的Express-C版 ...

  3. Linux下Nginx编译安装后的开机自启动设置

    Linux下Nginx编译安装后的开机自启动设置 一.查看当前Nginx启动状态 二.而配置Nginx相关服务文件 三 .设置nginx命令 四.设置开机启动 五.测试开机启动 一.查看当前Nginx ...

  4. Linux下nginx编译安装,重新添加模块

    Linux下nginx编译安装,重新添加模块 前言:编译完成后的Nginx,当我们需要新的功能模块时,要怎么重新添加呢?可以按照下面的方法试试. 1.查看nginx版本以及编译安装模块 [root@# ...

  5. linux下nginx编译安装

    转载自: http://hanqunfeng.iteye.com/blog/697696 一.下载nginx 下载地址:http://www.nginx.org/ 选择nginx-0.8.36 将该下 ...

  6. linux下nginx部署以及配置详解

    1.下载源码包解压编译 启动多个,请看:在linux系统下安装两个nginx以及启动 查看nginx包路径:http://nginx.org/download/,两种下载方式: 1.在官网下载使用Xf ...

  7. linux下Redis服务器部署过程详解

    一.前言 最近公司需要使用redis缓存服务器,所以就用了一个下午的时间部署了一个linux版本的Redis缓存服务 器.Redis缓存服务器是近两年比较热门的NOSQL系统之一,它是一个key-va ...

  8. linux nginx权限配置文件,linux下nginx部署以及配置详解

    1.下载源码包解压编译 1.在官网下载使用Xftp上传到linux上(不推荐使用) 2.(推荐)在版本上选好,直接命令下载,如下:(下载nginx-1.16.1.tar.gz版本)建议到home目录执 ...

  9. linux下nginx启动不了,详解Nginx启动失败的几种错误处理

    使用Nginx做Web服务器过程中,碰到过以下几个问题: 1.nginx启动失败 启动nginx失败,报错信息如下: Starting nginx: nginx: [emerg] bind() to ...

最新文章

  1. Alpha 冲刺报告(10/10)
  2. 老电脑安装matlab 2018卡不卡,软件装C盘会变卡?Windows系统要怎么用才不卡?
  3. 在数据库恢复之前将数据库置为单用户模式
  4. Win7安装64位CentOS 6.4双系统详细过程
  5. java 拖放文字_myeclipse2014如何实现jsp中的html代码的文字拖放
  6. flink连接kafka整合hbase,scala
  7. CV Code | 计算机视觉开源周报 20190602期
  8. CI/CD是什么?如何理解持续集成、持续交付和持续部署
  9. php怎样实现表格自动缩放字体,php实现在限定区域里自动调整字体大小的类实例,字体大小实例_PHP教程...
  10. eclipse android 慢,Android编译很慢(使用Eclipse)
  11. 彻底放弃没落的MFC,对新人的忠告! by FreeWick
  12. 邓亚萍加盟人民日报社 担任人民搜索一把手
  13. verilog语言实现FPGA板的交通信号灯
  14. 陷阱技术探秘──动态汉化Windows技术的分析
  15. 关于APP抓包,Mac就不配拥有姓名吗?
  16. SpringBootApplication是哪三个注解
  17. Mysql存储引擎Innodb的读写锁、行级锁
  18. 心理学统治世界(1)——股民的圣经
  19. canvas 的save()和restore()方法
  20. 别告诉我你会记笔记——工作中如何使用笔记(笔记)

热门文章

  1. NGINX根据不同域名请求跳转同一台机器的不同项目
  2. HDU 6143 Killer Names(排列+容斥,dp)
  3. runtime的用法
  4. 影响JavaScript应用可扩展性因素
  5. 如何获取当前点击元素的某个子元素
  6. Google Code Jam 2014 总结
  7. favicon支持的图片格式
  8. 苹果CEO 斯蒂夫.乔布斯:我如何工作
  9. 卫星轨道推演计算相关知识点总结(含欧拉角、旋转矩阵、及各坐标系转化等)
  10. “全面二孩”效应消失,这十大原因导致“生不动”