NGINX的编译安装
2023-02-18 16:33:43 时间
实现步骤:
-
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
相关文章
- 驱动开发:内核LDE64引擎计算汇编长度
- 参加面试前,一定要知道的互联网黑话
- 官宣!流计算开发管理框架 StreamPark 成功进入 Apache 孵化器
- Galaxy Release (v 22.05),新历史面板发布
- 页面加载代码
- Shell:变量数值计算(上)
- Shell:变量数值计算(下)
- ES6躬行记(12)——数组
- ES6躬行记(11)——对象
- ES6躬行记(10)——正则表达式
- ES6躬行记(9)——字符串
- ES6躬行记(8)——数字
- ES6躬行记(7)——代码模块化
- ES6躬行记(6)——Symbol
- ES6躬行记(5)——对象字面量的扩展
- ES6躬行记(4)——模板字面量
- ES6躬行记(3)——解构
- ES6躬行记(2)——扩展运算符和剩余参数
- ES6躬行记(1)——let和const
- 【翻译】停止学习框架(Stop Learning Frameworks)