Centos6.8安装nginx(一)
在这里对nginx的安装简单的做个记录,后续有时间的话在详细补充。1.yum安装g++:
yum install -y gcc gcc-c++
2.下载必需的依赖库:zlib(为了gzip压缩) 、openssl 、pcre(为了重写rewrite)
wget http://nginx.org/download/nginx-1.11.13.tar.gz
wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz
3.安装依赖库:zlib 、openssl 、pcre
tar xvf nginx-1.11.13.tar.gz
tar xvf openssl-1.1.0e.tar.gz
tar xvf pcre2-10.21.tar.gz
tar xvf zlib-1.2.11.tar.gz
cd .
/nginx-1.11.13
.
/configure --prefix=/usr/local/nginx --with-pcre=../pcre2-10.21 --with-openssl=../openssl-1.1.0e --with-zlib=../zlib-1.2.11
make
make install
注意:
--with选项均指向源码路径。
4.修改配置:
vi /usr/local/nginx/conf/nginx.conf
添加以下内容,注意位置:
upstreamtest { server
127.0.0.1:18087; server
127.0.0.1:28087;
}
server {
listen
80; server_namelocalhost;
charset utf
-8; location
/test { root html;
indexindex.html index.htm;
proxy_pass http:
//test;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
5.测试配置问是否正确:
/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
6.启动 :
启动:
/usr/local/nginx/sbin/nginx
重启:
/usr/local/nginx/sbin/nginx -s>
7.访问:
安装成功!
先记录到这里,后续再进行详细补充^_^~
页:
[1]