RedHat Linux6版本下nginx的配置安装(源码编译的形式),实现负载均衡

关于nginx

    Nginx功能丰富,可作为HTTP服务器,也可作为反向代理服务器,邮件服务器。支持FastCGI、
SSL、Virtual Host、URL Rewrite、Gzip等功能。并且支持很多第三方的模块扩展。	
    Nginx的稳定性、功能集、示例配置文件和低系统资源的消耗让他后来居上,在全球活跃的网
站中有12.18%的使用比率,大约为2220万个网站。

环境设定

server1 172.25.78.1 nginx+httpd
server2 172.25.78.2 后端服务器1 httpd
server3 172.25.78.3 后端服务器2 httpd

1.nginx的安装配置

[root@server1 ~]# ls   # 获取软件包
nginx-1.15.8.tar.gz
[root@server1 ~]# cd nginx-1.15.8
[root@server1 nginx-1.15.8]# vim src/core/nginx.h  # 隐藏版本号,防止黑客攻击 1
4 #define NGINX_VER          "nginx/"
[root@server1 nginx-1.15.8]# vim auto/cc/gcc  # 关闭debug日志,如果不关闭的话,生成的日志非常多,占用磁盘空间
# debug
# CFLAGS="$CFLAGS -g"
[root@server1 nginx-1.15.8]# ./configure --prefix=/usr/local/nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_stub_status_module  # 自定义添加模块编译nginx
[root@server1 nginx-1.15.8]# make && make install
[root@server1 nginx-1.15.8]# cd /usr/local/
[root@server1 local]# du -sh nginx    # 可以看到nginx非常小,如果打开debug日志的话,就会大得多,实际生产环境也不开debug日志
992K	nginx
[root@server1 local]# cd nginx/
[root@server1 nginx]# sbin/nginx   # 开启nginx服务,出现这种情况的原因可能是,nginx的默认生成端口是80,与httpd端口冲突,解决方案是把httpd卸载掉或者把httpd的服务关闭	
nginx: [emerg] bind() to 0.0.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值