乐忧商城踩坑之Linux下安装nginx服务器

4 篇文章 0 订阅
1 篇文章 0 订阅

把nginx软件传输到Linux虚拟机上面
解压 tar -zxvf nginx-1.5.9.tar.gz 过后
进入
cd nginx-1.5.9 nginx目录
输入下方命令 配置环境
./configure --prefix=/opt/nginx --sbin-path=/usr/bin/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.

安装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=<path> options.

解决办法:

yum -y install openssl openssl-devel

执行编译安装
make && make install

编译完成后
输入 nginx 启动nginx

查看nginx是否启动
ps -ef | grep nginx

root      6937     1  0 18:01 ?        00:00:00 nginx: master process nginx
nobody    6938  6937  0 18:01 ?        00:00:00 nginx: worker process
root      6941  2173  0 18:01 pts/0    00:00:00 grep nginx

看到2个进程说明启动成功

第一个master进程起到本地监控的作用监控管理nginx

worker进程作为正真服务的进程

chkconfig iptables off 开机时不启动防火墙
临时关闭防火墙 service iptables off

查看防火墙状态
service iptables status
重启后运行
iptables:未运行防火墙。

配置域名完成后

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
   
    keepalive_timeout  65;

    gzip  on;//>
	server {
        listen       80;
        server_name  manage.leyou.com;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
			proxy_pass http://127.0.0.1:9001;
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
        }
    }
	server {
        listen       80;
        server_name  api.leyou.com;

        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
			proxy_pass http://127.0.0.1:10010;
			proxy_connect_timeout 600;
			proxy_read_timeout 600;
        }
    }
}

配置的地址需要在
/opt/nginx/conf
修改配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值