系統環境
操作系統:64位CentOS Linux release 7.2.1511 (Core)
安裝nginx依賴包
[root@localhost ~]# yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl—devel
必須要安裝,時間可能有點久。
下載nginx
下載地址:http://nginx.org/en/download.html

下載最新的nginx-1.13.6(寫筆記時,這個版本是最新的),下載好之后,在centos系統中創建/soft目錄
[root@localhost ~]# mkdir /soft
利用工具WinSCP,將下載好的nginx包拷貝到centos下的/soft目錄
解壓nginx
[root@localhost ~]# cd /soft
[root@localhost soft]# tar -zxvf nginx-1.13.6.tar.gz
編譯和安裝nginx
[root@localhost soft]# cd nginx-1.13.6/
[root@localhost nginx-1.13.6]# ./configure --prefix=/usr/local/nginx
指定安裝在/usr/local/nginx目錄下,不指定也沒關系,默認就是這個目錄。
[root@localhost nginx-1.13.6]# make && make install
查看nginx版本號:
[root@localhost ~]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx -h

開啟80端口
[root@localhost conf]# firewall-cmd --zone=public --add-port=80/tcp --permanent
[root@localhost conf]# firewall-cmd --reload
啟動和停止nginx
啟動
[root@localhost sbin]# ./nginx
停止
[root@localhost sbin]# ./nginx -s stop
重啟
[root@localhost sbin]# ./nginx -s reload
瀏覽
在瀏覽器地址欄輸入http://192.168.1.100/

參考網址
https://www.cnblogs.com/lxg0/p/6979274.html
簡單配置
下面這段配置是最最最簡單的負載均衡配置,文件名nginx_fzjh.conf,只要在我們啟動nginx的時候,指定這個配置文件就行了([root@localhost sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx_fzjh.conf)
worker_processes 4; events{ worker_connections 1024; } http{ server { listen 80; server_name myserver; location / { proxy_pass http://mysite; } } upstream mysite { #ip_hash; server 10.101.56.52:80;# weight=5; server 10.101.56.52:8089;# weight=3; #server x.x.x.x:80 weight=1; } }
只看不回復,詛咒你釘釘0.0000000001厘米。
