Nginx
正向代理与反向代理
正向代理:正向代理的对象是客户端;
反向代理:反向代理的对象是服务端;
常用的Web服务器介绍
apache、Nginx、tomcat、weblogic、iis、jboss、websphere、jetty、netty、lighttpd、glassfish、resin 等。
安装
解压 tar zxvf ngnginx-1.17.0.tar.gz
设置安装目录 ./configure --prefix=/usr/lcoal/nginx
常见错误:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决方法:yum -y install pcre-devel
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决方法:yum install -y zlib-devel
如果yum无法执行,请查看:
安装并且编译 make && make install
目录介绍
conf: 配置文件
html:存静态文件
logs:日志文件
sbin:脚本文件
启动与停止
启动
./nginx -c /usr/local/nginx/conf/nginx.conf -c 标识指定文件启动;
./nginx 默认加载当前目录conf下nginx.conf文件;
停止
脚本
./nginx -s stop 停止
./nginx -s quit 退出
./nginx -s reload 重新加载
发送信号方式
查找进程 ps -ef |grep nginx 找到master进程号通过 kill -QUIT xxxx 停止;原理:nginx会关闭请求,处理当前剩余请求后再停止。
kill -9 xxxx
kill -TERM xxxx