Linux/Centos Nginx安装与配置代理

nginx版本:version 1.9.3

注:文中涉及到的软件包可以加最下方微信免费获取

使用yum安装依赖包

#yum install gcc zlib zlib-devel openssl openssl-devel pcre pcre-devel*ncurse* -y

#cd /usr/local/src

#tar -zxvf /usr/local/src/nginx-1.9.3.tar.gz

#cd nginx-1.9.3

#./configure --prefix=/usr/local/nginx --with-http_realip_module--with-http_sub_module --with-http_gzip_static_module--with-http_stub_status_module --with-pcre --with-http_ssl_module

#make  && make install

配置nginx

#cd /usr/local/nginx/conf/

#mv nginx.conf nginx.conf.bak

下面的截图是一个简单的反向代理:


如上图所示访问http://192.168.8.156:80的请求会被转发到http://192.168.0.186:9890

启动方法

#/usr/local/nginx/sbin/nginx

也可以通过/etc/init.d/nginxstart|stop|restart方式

将附件里的nginx启动脚本上传到/etc/init.d/下

#chmod 755 /etc/init.d/nginx  //赋权

#chkconfig  --add nginx     //添加nginx为系统服务

#chkconfig  nginx on        //配置开机自启动

如果对此有兴趣,请扫下面二维码免费获取更多详情


猜你喜欢

转载自blog.csdn.net/weixin_41078837/article/details/80576276