Nginx(engine X)是一款高性能的HTTP服务器、反向代理服务器及邮件代理服务器。
在高连接并发的情况下,它是Apache服务器不错的替代品。它也可以作为负载均衡服务器。
注:(负载均衡有两方面的含义:首先,单个重负载的运算分担到多台节点设备上做并行处理,每个节点设备处理结束后,将结果汇总,返回给用户,系统处理能力得到大幅度提高,这就是常说的集群(clustering)技术。第二层含义就是:大量的并发访问或数据流量分担到多台节点设备上分别处理,减少用户等待响应的时间,这主要针对Web服务器、FTP服务器、企业关键应用服务器等网络应用。)
安装nginx
1.可以到http://nginx.org/en/download.html这个网址下载nginx-1.7.3.tar.gz
2.解压tar -zxvf nginx-1.7.3.tar.gz
3.进入解压后的nginx目录,输入./configure make等内容时,若要出现“报./configure: error: the HTTP rewrite module requires the PCRE library”之类的错误,则还需要继续安装一下内容
4.使用yum命令安装gcc,cc/pcre-devel/openssl等:
yum install gcc-c++ libstdc++-devel
yum -y install pcre-devel
yum -y install openssl openssl-devel
5.配置nginx
cd nginx-1.7.3
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
6.make
7.make install
8.检测是否安装成功:
cd /usr/local/nginx/sbin
./nginx -t
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
9.启动nginx
cd /usr/local/nginx/sbin 目录下面 输入
./nginx 启动 nginx
10.检查是否启动成功
在浏览器中输入:http://192.168.26.128/,若出现如下图所示,表示启动成功。
否则的话,要检测是否是防火墙未关闭。
关闭防火墙:service iptables stop
11.关闭nginx
仍在/usr/local/nginx/sbin/nginx目录下,输入nginx -s stop