首页 > 系统相关 >redhat 7.3 本地安装nginx

redhat 7.3 本地安装nginx

时间:2023-11-15 13:31:54浏览次数:30  
标签:http redhat nginx -- react 7.3 yum root

系统配置

操作系统

[[email protected] sbin]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)

nginx版本

nginx-1.16.1

配置本地yum源

服务器无网络,挂载光盘做为yum源

创建本地源文件夹

mkdir -p /mnt/cdrom
挂载镜像文件至指定的目录
mount /dev/cdrom /mnt/cdrom

备份本地源

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]#cp -rf /etc/yum.repos.d  /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')

删除默认原本地源

[[email protected] yum.repos.d]#rm -rf /etc/yum.repos.d/*

配置本地源,创建Media.repo文件,配置内容:

[[email protected] yum.repos.d]#vi /etc/yum.repos.d/local.repo

[local]

name=local

baseurl=file:///mnt/cdrom

gpgcheck=1

enabled=1

gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

加载本地yum源&测试

清除yum缓存

yum clean all

缓存本地yum源

yum makecache

测试yum本地源

yum list

订阅插件提示:This system is not registered with an entitlement server. You can use subscription-manager to register.

这个Red Hat Subscription Manager订阅管理器,它会让你一直register,解决办法:禁用就好

[[email protected] yum.repos.d]#vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0

安装nginx

创建nginx用户组及用户

[[email protected] yum.repos.d]# groupadd app01
[[email protected] yum.repos.d]# useradd -g app01 app01

安装依赖环境

安装gcc环境

yum install gcc-c++

安装PCRE库,用于解析正则表达式

yum install -y pcre pcre-devel

zlib压缩和解压缩依赖

yum install -y zlib zlib-devel

SSL 安全的加密的套接字协议层,用于HTTP安全传输,也就是https

yum install -y openssl openssl-devel

安装Nginx

去官网下载对应的Nginx包,推荐使用稳定版本

http://nginx.org/en/download.html

redhat 7.3 本地安装nginx_本地源

上传Nginx到Linux

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

[[email protected] nginx]# tar zxvf nginx-1.16.1.tar.gz

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

[[email protected] nginx]#cd nginx-1.16.1/

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

[[email protected] nginx-1.16.1]#mkdir -p /etc/nginx
[[email protected] nginx-1.16.1]#mkdir -p /var/cache/nginx

开始configure Nginx。

[[email protected] nginx-1.16.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

注:\ 代表在命令行中换行,用于提高可读性

配置命令:

命令

解释

-prefix

指定Nginx安装目录

-pid-path

指向Nginx的pid

-lock-path

锁定安装文件,防止被恶意褚篡改或误操作

-error-log

错误日志

–http-log-path

http日志

–with-http_gzip_static_module

启用gzip模块,在线实时压缩输出数据流

–http-client-body-temp-path

设定客户端请求的临时目录

–http-proxy-temp-path

设定http代理临时目录

–http-fastcgi-temp-path

设定fastcgi临时目录

–http-uwsgi-temp-path

设定uwsgi临时目录

–http-scgi-temp-path

设定scgi临时目录

--user 

nginx用户

--group 

nginx用户组

 接着继续编译

[[email protected] nginx-1.16.1]#make

安装Nginx。

[[email protected] nginx-1.16.1]#make install

配置systemctl控制的Nginx服务,将以下下内容复制输入到新建的nginx.service文件中

[[email protected] nginx-1.16.1]# vi /usr/lib/systemd/system/nginx.service
[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=/var/run/ninx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

使用systemctl来操作nginx服务,并开机启动。

[[email protected] nginx-1.16.1]#systemctl enable nginx.service

 尝试管理Nginx。

[[email protected] nginx-1.16.1]#systemctl status nginx  #查看Nginx状态
[[email protected] nginx-1.16.1]#systemctl start nginx        #启动Mginx服务
[[email protected] nginx-1.16.1]#systemctl stop nginx         #停止Nginx服务

标签:http,redhat,nginx,--,react,7.3,yum,root
From: https://blog.51cto.com/u_15395826/8389253

相关文章

  • nginx-rust 基于rust 开发nginx 模块
    nginx-rust是nginx官方出的可以让我们基于rust开发nginx模块,目前还处于早期阶段,对于nginx类型的生成官方基于了bindgen工具这个工具我以前也简单介绍过,定于header包装如下图 说明目前来说官方提供的集成还是比较全的,同时对于标准nginx模块开发需要的数据类型也提供了......
  • cmake nginx 本地开发调试
    主要是学习下如何基于cmake进行nginx的本地调试,也方便学习如何开发nginx模块参考配置CMakeLists.txtcmake_minimum_required(VERSION3.10)project(ngx_hello_module) #PathtotheNginxsourcecodeset(NGINX_SOURCE_PATH${CMAKE_SOURCE_DIR}/ngi......
  • Linux基础43 nginx多server优先级, nginx禁止IP访问, nginx的alias, nginx的try_file
    Nginx常见问题一、nginx多server优先级在开始处理一个http请求时,nginx会去除header头中的Host变量,与nginx.conf中的每个server_name进行匹配,以此决定到底由哪一个server来处理这个请求,但nginx如果配置多个相同的server_name,会导致server_name出现优先级访问冲突。1.准备多个......
  • nginx返回静态文件乱码中文不显示
    如果遇到自己部署的服务出现页面中文乱码不显示的问题,在server块中,location同级添加一个charsetutf-8即可。示例:server{ listen8001;#监听的端口 server_namea.www.com;#服务名,我这里是做的二级域名,不重要,是你的服务器地址就是了 charsetutf-8;#重点就是这里啦~在......
  • 使用 nginx 和 rtmp 插件搭建视频直播和点播服务器
    使用nginx和rtmp模块,可以很容易地搭建一个视频直播和点播服务器出来。下面我们来看一下具体实施步骤:1.安装nginx和rtmp模块有关nginx的编译和安装比较简单,这里就不介绍了,看参考文献。这里提示以下几点:(1)安装好nginx后,配置文件在这里:/usr/local/nginx/conf/nginx.co......
  • Nginx 禁止页面缓存
    location^~/vue{add_headerCache-Control"no-cache,private,no-store,must-revalidate,max-stale=0,post-check=0,pre-check=0";indexindex.html;alias/home/zhuge/project/test/dist/;try_files......
  • Linux安装Nginx
    1.在/usr/local建nginx文件夹,下载nginx压缩文件nginx下载地址:http://nginx.org/download找稳定版本执行命令cd/usr/localmkdirnginxwgethttp://nginx.org/download/nginx-1.24.0.tar.gztar-zxvfnginx-1.24.0.tar.gz2.安装编译工具、库文件yum-yinstallmak......
  • 通过NGINX搭建TiDB负载均衡
    作者:像风一样的男子前言目前TIDB的负载均衡官网推荐使用HAProxy,社区主流也是HAProxy,本文尝试使用nginx四层代理tidb提供TCP协议下的负载均衡能力,因为nginx安装编译需要自己添加模块,很多小伙伴觉得麻烦,本文使用基于Nginx的openresty来安装,可以实现一键安装并打包各个模块,快速......
  • Centos7 nginx反向代理gitea和grafana&钉钉告警
    1安装nginxyuminstall-ygccmakepcre-develzlib-developenssl-develwgethttps://nginx.org/download/nginx-1.20.1.tar.gztar-zxvfnginx-1.20.1.tar.gzcdnginx-1.20.1./configure--prefix=/usr/local/nginx--with-http_ssl_modulemakemakeinstallvi/etc/system......
  • nginx启动报错权限不够
    -bash:/u01/nginx/sbin/nginx:权限不够解决方案:这个错误提示表明你尝试执行/u01/nginx/sbin/nginx时没有足够的权限来执行该命令。这通常是因为当前用户对该文件没有执行权限。要解决这个问题,你可以使用sudo命令以超级用户的身份来执行该命令。比如:bashCopyCodesud......