CentOS6.5环境安装nginx服务器及负载均衡配置操作详解

2019-01-16 22:11:22丽君

设置host:

[root@a conf]# vi /etc/hosts

添加hosts:

127.0.0.1 web_app

启动nginx

[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

启动三部服务器的web应用:

在192.168.137.197执行指令:

[root@a PROGRAM]# curl "http://web_app/index.jsp"

测试结果如下:

常见问题及解决办法:

1、安装PCRE时提示configure: error: You need a C++ compiler for C++ support.

原因是没有安装c++编译器,采用下面的命令安装:

[root@localhost pcre-8.37]# yum install -y gcc gcc-c++

2、启动nginx失败

[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

原因是64bit的系统,但是默认取了/usr/local/lib里面的包

检查方法:

[root@localhost nginx]# cd /usr/local/ [root@localhost local]# ls /lib64/ |grep pcre libpcre.so.0 libpcre.so.0.0.1 [root@localhost local]# ls /lib/ |grep pcre

说明缺失的包在lib64

设置软连接来解决:

[root@localhost local]# ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 [root@localhost local]# cd nginx [root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

3、启动报错:

报错:nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

解决办法:sudo fuser -k 80/tcp

端口被占用,关闭占用端口

希望本文所述对大家CentOS服务器配置有所帮助。

您可能感兴趣的文章:

CentOS6.5环境下使用rsync增量同步备份文件的方法CentOS Rsync服务端与Windows cwRsync客户端实现数据同步配置方法CentOS 6.3 Rsync客户端与Win2003 cwRsyncServer服务端实现数据同步Centos rsync文件同步配置步骤分享CentOS5 + rsync 同步2台服务器的文件CentOS6.5系统简单安装与配置Nginx服务器的方法CentoS6.5环境下redis4.0.1(stable)安装和主从复制配置方法CentOS6.5服务器环境安装VPN的方法CentOS6.5平台上rsync服务器安装配置方法简述