简述nginx:
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。
其特点是占有内存少,并发能力强,
Nginx作为负载均衡服务:既可以在内部直接支持 Rails 和 PHP 程序对外进行服务,也可以支持作为 HTTP代理服务对外进行服务。
Nginx采用C进行编写,不论是系统资源开销还是CPU使用效率都比 Perlbal 要好很多。
处理静态文件,索引文件以及自动索引;打开文件描述符缓冲。无缓存的反向代理加速,简单的负载均衡和容错。
1.nginx的基础配置
1.下载nginx并解压
安装包:
nginx-1.15.7.tar.gz
#1.在官网上下载nginx
[root@server1 ~]# ls
nginx-1.15.7.tar.gz
#2.解压
[root@server1 ~]# tar zxf nginx-1.15.7.tar.gz
[root@server1 ~]# ls
nginx-1.15.7 nginx-1.15.7.tar.gz
2.隐藏版本号
隐藏版本号:是为了防止被黑客攻击
[root@server1 ~]# cd nginx-1.15.7
[root@server1 nginx-1.15.7]# vim src/core/nginx.h
3.关闭debug日志
关闭debug日志:因为日志量太多了,过于繁琐
[root@server1 nginx-1.15.7]# vim auto/cc/gcc
4.源码编译
(1)configure编译
#没有eorror即可; --prefix:安装目录 threads:激活线程池 file-aio:文件io http_ssl_module:ssl模块 http_stub_status_module:状态监控模块
[root@server1 nginx-1.15.7]# ./configure --prefix=/usr/local/nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_stub_status_module
(2)编译与安装
[root@server1 nginx-1.15.7]# make && make install
5.开启nginx
[root@server1 nginx-1.15.7]# cd /usr/local/nginx/
[root@server1 nginx]# ls
conf html