Nginx作为一个web服务器,目前使用最多的就利用其负载均衡,本篇着重讲解的是nginx在linux环境下的安装部署。
root环境下安装
1.准备资源,下载nginx及相关组件:
(1)、cd usr/local/src 进入下载目录,可自定义
(2)、准备下载4个程序(依次执行以下四个命令):
wget http://nginx.org/download/nginx-1.10.2.tar.gz
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
如果安装了c++的环境就可跳过,如未安装:yum install gcc-c++ (点击y即可)
安装结尾显示complete,即代表安装完成
2.安装nginx及其组件
(1)、安装openssl:
tar -zxvf openssl-fips-2.0.10.tar.gz
cd openssl-fips-2.0.10
./config && make && make install
(2)、安装pcre
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure && make && make install
(3)、安装zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install
(4)、安装nginx
tar zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure && make && make install
3.启动Nginx
命令 cd /usr/local/nginx/sbin
./nginx -t
./nginx -c /usr/local/nginx/conf/nginx.conf
启动成功,默认80端口,直接访问即可