安装
https://nginx.org/en/download.html
./configure
make
make install
报错PCRE library
./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= option.
安装PCRE library
sudo yum install pcre pcre-devel
报错zlib library
./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= option.
安装zlib library
sudo yum install zlib zlib-devel
命令
./nginx # 启动
./nginx -t # 验证配置文件
./nginx -s reload # 重载配置文件
./nginx -s reopen # 重启
./nginx -s quit # 安全退出
./nginx -s stop # 强制退出
ps aux|grep nginx # 查看Nginx进程
卸载
./nginx -s stop
find / -name nginx
rm -rf <nginx路径>
chkconfig nginx off # 关闭开机自启
rm -rf /etc/init.d/nginx # 关闭开机自启
配置文件
upstream <组名> # 负载均衡
{
<server=servername1> [weight=权重值]
<server=servername2> [weight=权重值]
<server=servername3> [weight=权重值]
}
server
{
listen 443 ssl;
server_name <用户主动访问的域名>;
ssl_certificate <pem路径>;
ssl_certificate_key <key路径>;
location /
{
proxy_pass <转发的目标地址或组名>; # 反向代理
}
}
include /nginx/*.conf; # 添加nginx目录下的所有*.conf文件