Linux服务器开发——Nginx(一)基础

本文详细介绍了Nginx的安装过程,包括必要的依赖库安装,如zlib、openssl和pcre,以及如何通过源码编译隐藏Nginx版本信息。同时,提供了Nginx的一些基础命令,如配置测试、重启、关闭和服务状态检查。

目录

 

简介

Nginx优点

安装

一些基础命令


简介

最主流的web服务器之一,目前强势压apache,并发高,响应快,390,腾讯,阿里等都在用,nb,感谢俄罗斯大佬。

Nginx优点

安装

nginx下载地址:http://nginx.org/en/download.html

查看zlib是否安装:dpkg -l | grep zlib        安装命令:sudo apt-get install zlib1g-dev

安装openssl:sudo apt-get install openssl libssl-dev

安装pcre:sudo apt-get install libpcre3 libpcre3-dev

安装pcre库支持rewrite,也可以安装源码,安装源码时需要制定pcre路径为解压源码的路径,而不是编译后的路径,否则会报错

隐藏Nginx版本信息:cd nginx-1.4.7

sed -i -e 's/1.4.7//g' -e 's/nginx\//WS/g' -e 's/"NGINX"/"WS"/g' src/core/nginx.h

或者如下操作:

1,修改src/core/nginx.h(Nginx内部名称的)
    #define NGINX_VERSION "1.12.0"
    #define NGINX_VER "nginx/" NGINX_VERSION

2,修改src/http/ngx_http_header_filter_module.c(HTTP ResponseHeader)
    static u_char ngx_http_server_string[] = "Server: nginx" CRLF

3,修改src/http/ngx_http_special_response.c(修改错误页的底部Footer)
    static u_char ngx_http_error_tail[] = 下的nginx信息

预编译命令:

useradd www ;./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
确定用户 组 访问状态  s加密等  注意修改路径

安装 :make&&make install

检查配置命令:/usr/local/nginx/sbin/nginx -t   会提示:   xxxx...is successful

启动命令:/usr/local/nginx/sbin/nginx    默认端口80

用浏览器访问本机地址:http://192.168.0.127  显示下图,说明安装ok

如果不ok,返回服务器,关闭防火墙

查看防火墙状态ufw status      inactive状态是防火墙关闭状态 active是开启状态

ufw enable开启防火墙          ufw disable关闭防火墙

重新连接,成功

一些基础命令

测试配置:/usr/local/nginx/sbin/nginx -t

重启命令:/usr/local/nginx/sbin/nginx -s reload

pid关闭命令:kill -9 xxxx

名字关闭:pkill -9 nginx

查看版本:/usr/local/nginx/sbin/nginx -v

查看安装config:/usr/local/nginx/sbin/nginx -V

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值