1、服務器環境:centos7.5
2、安裝nginx
首先下載:wget http://nginx.org/download/nginx-1.14.0.tar.gz
解壓:tar zxvf nginx-1.14.0.tar.gz得到解壓包nginx-1.14.0
進入nginx-1.14.0,執行編譯命令:./configure  --with-stream --without-http
(注意:要系統支持c編譯環境,安裝方法yum -y install gcc gcc-c++)
make
make install
3、修改配置文件,nginx默認安裝路徑:/usr/local/nginx
vim /usr/local/nginx/conf/nginx.conf,內容如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
 #use epoll;
 worker_connections 1024;
}
stream {
  upstream socket{
  server 192.168.1.155:8000;
  server 192.168.1.154:8000;
 }
 server {
  listen 80;
  proxy_pass socket;
 }
} 
4、啟動:/usr/local/nginx/sbin/nginx
停止:/usr/local/nginx/sbin/nginx -s stop
退出:/usr/local/nginx/sbin/nginx -s quit
重啟:/usr/local/nginx/sbin/nginx -s reload
