Centos 7源码编译安装Nginx

Centos 7源码编译安装Nginx

前言

Nginx是一款轻量级的Web 服务器,其特点是,高效,开源,稳定性强,高并发(能够支持高达 50,000 个并发连接数的响应)常见的linux web服务有Linux Apche Nginx Tomcat
Nginx官网:www.nginx.org

下载nginx包

[root@Kling ~]# wget  http://nginx.org/download/nginx-1.18.0.tar.gz

安装依赖库

[root@Kling ~]# yum install-y gcc-c++   pcre-devel zlib-devel

创建nginx用户

[root@Kling ~]# useradd -s /sbin/nologin nginx -M(-M不创建宿主目录)
[root@Kling ~]# tail -1 /etc/passwd
nginx:x:1004:1005::/home/nginx:/sbin/nologin

解压Ngnix包

[root@Kling ~]# tar -zxvf nginx-1.18.0.tar.gz -C /usr/src (-C解压到指定目录)

安装

[root@Kling nginx-1.18.0]# ./configure --prefix= /usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
 --prefix= /usr/local/nginx ——指定安装位置
 --user=nginx  ——运行用户
-- group=nginx ——运行用户组
 --with-http_stub——状态以及模块 

创建Nginx链接

[root@Kling nginx-1.18.0]# ln -s /usr/local/nginx/sbin/nginx  /usr/sbin/
[root@Kling nginx-1.18.0]# 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@Kling nginx-1.18.0]# 

访问一个没有的页面会看到nginx的版本号这样不安全
在这里插入图片描述

[root@Kling ~]# vim /usr/local/nginx/conf/nginx.conf

隐藏版本号

在这里插入图片描述

检查语法并重新加载配置文件

[root@Kling ~]# 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@Kling ~]# nginx -s reload
[root@Kling ~]# 

验证

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值