Linux Is Not Matrix——Nginx安装

  这几天一直也都没闲着,忙了好几天的考评模板配置的复用,现在又在研究根据各种条件抽出考试题型分值模板的算法,虽然知道是用回溯法,但是这个过程还是要一步一步的写写才行。

  好了,今天没有算法的事情,只是交待一下失踪时间去劣势路抗压去了。

  这几天依然在研究linux,为了保证咱们的项目以后能够上线稳定运行,并且能保证在用户极大的时候依然可以正常运行,这样就需要我们使用多台服务器来处理用户的访问请求。

  在网上查了很多资料,这就是传说中的负载均衡。

  实现负载均衡的方案有很多种,比较常用的是LVS、Nginx、haproxy。虽然也是看了很多资料,想要确定一种比较适合我们系统的方案,但是实在是由于这方面的经验太少了,根本看不懂他们的比较有什么区别- -。

  所以呢,为了学习,这几种都上,Nginx的配置相对简单一些,就先从Nginx开始。

  首先要下载Nginx的压缩包传到linux上,或是直接使用wget命令,后面跟上下载地址。

wget -c http://nginx.org/download/nginx-1.9.8.tar.gz

  解压之后,文件夹中有一个configure文件,我们直接执行这个文件

 ./configure
  这时候很可能会报错,比如我报了两种错误。

./configure: error:the HTTP gzip module requires the zlib library.

You can eitherdisable the module by using --without-http_gzip_module

option, or installthe zlib library into the system, or build the zlib library

statically from thesource with nginx by using --with-zlib=<path> option.


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

You can eitherdisable the module by using --without-http_rewrite_module

option, or installthe PCRE library into the system, or build the PCRE library

statically from thesource with nginx by using --with-pcre=<path> option.

  英语提示写的很清楚,缺少zlib和PCRE这两种包。使用yum进行安装即可。这里我没有直接安装PCRE,而是找了一个openssl的解决方案,也不知道是为什么可以解决的- -

yum install -y zlib-devel
yum  -y install openssl openssl-devel

  执行之后就可以make && make install进行编译了,在经过很长很长的编译之后,我们可以测试一下Nginx。

ln-s /usr/local/nginx/sbin/nginx /usr/bin/nginx
nginx -t

 可能会报错

  nginx: [alert] couldnot open error log file: open() "/usr/local/nginx/logs/error.log"failed (2: No such file or directory)

  2015/12/22 18:48:06[emerg] 13105#0: open() "/usr/local/nginx/logs/access.log" failed (2:No such file or directory)

 

  可能由于没有创建文件夹的权限,导致logs文件夹没有创建成功,我们手动创建一下就可以了。

 

  也可能是由于Nginx.pid丢失造成的,重新指定一下Nginx的配置文件

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  再次测试Nginx,测试成功。

  nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok

  nginx: configurationfile /usr/local/nginx/conf/nginx.conf test is successful

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值