Nginx

安装

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文件
赞(0) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Nginx》
文章链接:https://blog.78cat.cn/3830.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

觉得文章有用就打赏一下文章作者

感谢您的支持,我将持续输出干货满满的内容

支付宝扫一扫

微信扫一扫