centos7安装nginx-1.13.6 新手入门,图文解析

系统环境

操作系统: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厘米。

原文地址:https://www.cnblogs.com/subendong/p/7856178.html