Nginx的下载网址为:http://nginx.org/en/download.html
Nginx源码下载
# mkdir /root/nginx
# cd /root/nginx
# wget http://nginx.org/download/nginx-1.12.2.tar.gz
# tar zxvf nginx-1.12.2.tar.gz
安装依赖软件
# yum -y install gcc gcc-c++ autoconf automake make zlib zlib-devel openssl openssl-devel pcre pcre-devel
gcc、gcc-c++:标准GCC编译器;
pcre、pcre-devel:支持rewrite模块;
zlib 、zlib -devel:支持gzip模块;
openssl、openssl-devel:支持ssl模块。
安装Nginx
指定安装路径./configure --prefix=/usr/local/nginx指定安装路径为/usr/local/nginx。
# cd nginx-1.12.2
# ./configure --prefix=/usr/local/nginx
编译
# make
安装
# make install
启动Nginx
# cd /usr/local/nginx/sbin
# ./nginx
默认的端口为80端口,我安装Nginx的主机IP为172.21.13.165,浏览器输入该IP地址,访问
有一个需求,访问m.XXX.com的时候,需要实际访问www.YYY.com/m
server {
listen 80;
server_name 172.21.13.165;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
proxy_pass http://172.21.16.151:8088/logins/;
}
}