[root@localhost /]# cd /etc/nginx #定位到nginx安装目录 [root@localhost nginx]# vim nginx.conf #通过vim打开nginx.conf配置文件进行配置
在http节点中,添加配置
1 2 3 4 5 6 7
#设定负载均衡的服务器列表 upstream load_balance_server { #weigth参数表示权值,权值越高被分配到的几率越大 server 192.168.1.131:5100 weight=5; server 192.168.1.132:5100 weight=1; server 192.168.1.130:5100 weight=6; }
[root@localhost nginx]# service nginx restart Redirecting to /bin/systemctl restart nginx.service Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe"for details. [root@localhost nginx]# systemctl status nginx -l ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2017-05-18 09:34:41 CST; 6s ago Process: 121270 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE) Process: 121265 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 117382 (code=exited, status=0/SUCCESS)
May 18 09:34:41 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server... May 18 09:34:41 localhost.localdomain nginx[121270]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok May 18 09:34:41 localhost.localdomain nginx[121270]: nginx: [emerg] bind() to 0.0.0.0:5100 failed (13: Permission denied) May 18 09:34:41 localhost.localdomain nginx[121270]: nginx: configuration file /etc/nginx/nginx.conf test failed May 18 09:34:41 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1 May 18 09:34:41 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server. May 18 09:34:41 localhost.localdomain systemd[1]: Unit nginx.service entered failed state. May 18 09:34:41 localhost.localdomain systemd[1]: nginx.service failed.