安装nginx

总结

yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install

具体

单独安装nginx,来处理大量的下载请求。单独在Centos7安装nginx遇到的rewrite和HTTP cache错误解决办法:

向Linux传入文件:nginx-1.19.1.tar.gz
解压文件

进入解压后的文件夹执行下面命令:
./configure

安装Nginx时报错

./configure: error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
–without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
–with-http_ssl_module --with-openssl= options.

解决办法:

yum -y install openssl openssl-devel

总结:

yum -y install pcre-devel openssl openssl-devel

./configure

make

make install

后面两个命令可以用如下命令代替:
make && make install

进入文件夹
/usr/local/nginx/conf
编辑配置文件
vi nginx.conf

这个位置添加
添加如下代码(woniusales根据项目名称改,域名为自己的域名,

upstream woniusales {
          #ip_hash;
          server 192.168.40.128:8080 weight=1;
          server 192.168.40.128:28080 weight=1;
}

两台服务器(端口不一样)

添加完后的效果
在这里插入图片描述
继续修改

        location /woniusales {
            root   html;
            index  index.html index.htm;
            proxy_pass http://woniusales/woniusales;
       }

修改完后的效果
在这里插入图片描述
在这里插入图片描述
图中第一个woniu是指上面可执行的woniu应用,第二个woniu是我们定义的nginx的访问地址(这个可以随意改)

显示nginx位置(命令)

whereis nginx

[root@localhost sbin]# whereis nginx
nginx: /usr/local/nginx

执行测试配置命令

/usr/local/nginx/sbin/nginx -t

[root@localhost sbin]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

特别强调一下:进到sbin目录下,通过./nginx启动.
上面的 /usr/local/nginx/sbin/nginx -t 不是启动nginx的操作,该操作只是用来测试nginx的配置是否正确

关闭nginx命令: ./nginx -s stop

服务器nginx 引入ssl配置时,报错:

nginx启动报"ssl parameter requires ngx_http_ssl_module"

原因:nginx缺少http_ssl_module模块,编译安装的时候带上–with-http_ssl_module配置就行了
使用nginx -V查询当前Nginx的编译配置信息,configure arguments: 后面为当前运行Nginx的配置信息

1、查找配置位置

(base) [root@iZxpl4sxxnloovZ nginx-1.8.0]# nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
configure arguments: --prefix=/usr/local/nginx

2、 切换到源码目录:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值