在CentOS/RHEL6操作系统上编译安装Nginx并配置服务

这篇文章主要讲述的是在CentOS/RHEL6操作系统上编译安装Nginx并配置服务,本文档硬件采用VMware Workstation Pro虚拟机模拟,安装步骤与现实环境无异。关于虚拟机的安装及配置不过多阐述,本文主要讲述Nginx编译安装配置和服务配置过程。在CentOS/RHEL6操作系统上编译安装Nginx并配置服务

一、环境准备

本文中提及的所有软件如何获取将在本章节讲解,如仅仅是需要参考如何编译安装Nginx请直接到Nginx官网下载软件后,跳转到本文第二章节”安装编译环境”开始阅读。
1.本文使用VMware Workstation Pro 17来模拟服务器硬件环境。
2.本文使用了RedHat Enterprise Linux(RHEL)6.10来安装Nginx。
3.编写本文时Nginx的稳定版本为nginx-1.22.1,如果有幸能被你看到这篇文章,你可以访问”Nginx官网“获取最新版本的软件。

二、安装编译环境

[root@shizhanxia.com nginx-1.22.1]#yum -y install gcc wget automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre-devel openssl-devel

三、编译安装Nginx

1,下载最新的Nginx版本

[root@shizhanxia.com nginx-1.22.1]#wget http://nginx.org/download/nginx-1.22.1.tar.gz

2,然后就是将下载下来的Nginx解压缩。

[root@shizhanxia.com nginx-1.22.1]# tar zxvf nginx-1.22.1.tar.gz

3,进入解压缩后的Nginx目录。如果你要定制版本号可以更改源码目录src/core/nginx.h文件。

[root@shizhanxia.com nginx-1.22.1]#cd nginx-1.22.1/

4,创建一个nginx目录用来存放运行的临时文件夹。

[root@shizhanxia.com nginx-1.22.1]#mkdir -p /etc/nginx
[root@shizhanxia.com nginx-1.22.1]#mkdir -p /var/cache/nginx
[root@shizhanxia.com nginx-1.22.1]#useradd app01

5,开始configure Nginx。

[root@shizhanxia.com nginx-1.22.1]#
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=app01 \
--group=app01 \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_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-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module

剩余内容需解锁观看

解锁查看全文

尊享赞助者尊享赞助者¥免费
已付费?登录刷新

原创文章,作者:保哥,如若转载,请注明出处:https://www.shizhanxia.com/593.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
保哥的头像保哥
上一篇 2024年4月23日
下一篇 2024年4月25日

发表回复

登录后才能评论
通知公告为提升体验,网站正在进行深度优化升级,已初始化所有用户数据。如您曾消费或赞赏,请联系我们。感谢您的支持、信任与理解,我们将持续提供优质服务。