Nginx在centos6.5下的安装和反向代理简单配置
2015-05-25 16:36
831 查看
From:http://blog.csdn.net/luckykapok918/article/details/44258901
查看linux的版本信息:
lsb_release -a
1.首先卸载原有的nginx:
yum remove nginx
2.安装nginx在内网的centos6.5服务器192.168.200.123上:
yum install nginx
3.运行nginx
cd /usr/sbin
./nginx
或者执行 service nginx start
4.,停止、重启nginx
/usr/sbin/nginx -s stop 或者执行 service nginx stop
/usr/sbin/nginx -s reload
5.检查nginx运行情况
5.1 ps -ef | grep nginx
5.2
浏览器中测试
6.查看80端口是否启用
7.配置反向代理,:
反向代理说明:nginx服务器地址192.168.200.123,端口80 ;tomcat服务器地址192.168.200.121端口8080;apache服务器地址192.168.200.121,端口80.
现在需要访问nginx的80端口来访问tomcat中的web服务。
7.1 配置前访问:
7.2配置nginx并重启服务:
cd 到 /etc/nginx/conf.d文件夹
修改default.conf文件
增加如下内容:
[html]
view plaincopyprint?
server{
listen 80;
server_name 192.168.200.123;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /wmsnew {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $http_destination;
proxy_pass http://192.168.200.121:8080/wmsnew/;
}
location /wmsnew/static {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $http_destination;
proxy_pass http://192.168.200.121/static;
}
}
如果123服务器启动了防火墙,则需要单独为80端口开发
[html]
view plaincopyprint?
<span style="font-size:18px;color:#3366ff;">#修改防火墙配置:
[root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
[root@admin nginx-1.2.6]# service iptables restart</span>
7.3 配置后访问:
配置成功!!
--------------------------------------------------------------补充源码编码安装nginx方式------------------------------------------------
操作系统:centos6.3
软件:nginx-1.2.6.tar.gz
安装方式:源码编码安装
安装位置:/usr/local/nginx
nginx下载地址:http://nginx.org/en/download.html
在安装nginx衫,需要确保系统已经安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
检查系统安装的ningx
find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
卸载系统原有的nginx
yum remove nginx
将安装包文件上传到目录中,本文是上传到/usr/local中,按以下命令进行操作。
[root@admin local]# cd /usr/local
[root@admin local]# tar -zxv -f nginx-1.2.6.tar.gz
[root@admin local]# rm -rf nginx-1.2.6.tar.gz
[root@admin local]# mv nginx-1.2.6 nginx
[root@admin local]# cd /usr/local/nginx
[root@admin nginx]# ./configure --prefix=/usr/local/nginx
[root@admin nginx]# make
[root@admin nginx]# make install
From:http://blog.csdn.net/luckykapok918/article/details/44258901
查看linux的版本信息:
lsb_release -a
1.首先卸载原有的nginx:
yum remove nginx
2.安装nginx在内网的centos6.5服务器192.168.200.123上:
yum install nginx
3.运行nginx
cd /usr/sbin
./nginx
或者执行 service nginx start
4.,停止、重启nginx
/usr/sbin/nginx -s stop 或者执行 service nginx stop
/usr/sbin/nginx -s reload
5.检查nginx运行情况
5.1 ps -ef | grep nginx
5.2
浏览器中测试
6.查看80端口是否启用
7.配置反向代理,:
反向代理说明:nginx服务器地址192.168.200.123,端口80 ;tomcat服务器地址192.168.200.121端口8080;apache服务器地址192.168.200.121,端口80.
现在需要访问nginx的80端口来访问tomcat中的web服务。
7.1 配置前访问:
7.2配置nginx并重启服务:
cd 到 /etc/nginx/conf.d文件夹
修改default.conf文件
增加如下内容:
[html]
view plaincopyprint?
server{
listen 80;
server_name 192.168.200.123;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /wmsnew {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $http_destination;
proxy_pass http://192.168.200.121:8080/wmsnew/;
}
location /wmsnew/static {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $http_destination;
proxy_pass http://192.168.200.121/static;
}
}
server{ listen 80; server_name 192.168.200.123; location / { root /usr/share/nginx/html; index index.html index.htm; } location /wmsnew { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $http_destination; proxy_pass http://192.168.200.121:8080/wmsnew/; } location /wmsnew/static { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Destination $http_destination; proxy_pass http://192.168.200.121/static; } }
如果123服务器启动了防火墙,则需要单独为80端口开发
[html]
view plaincopyprint?
<span style="font-size:18px;color:#3366ff;">#修改防火墙配置:
[root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables
#添加配置项
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙
[root@admin nginx-1.2.6]# service iptables restart</span>
<span style="font-size:18px;color:#3366ff;">#修改防火墙配置: [root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables #添加配置项 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #重启防火墙 [root@admin nginx-1.2.6]# service iptables restart</span>
7.3 配置后访问:
配置成功!!
--------------------------------------------------------------补充源码编码安装nginx方式------------------------------------------------
安装说明
操作系统:centos6.3软件:nginx-1.2.6.tar.gz
安装方式:源码编码安装
安装位置:/usr/local/nginx
nginx下载地址:http://nginx.org/en/download.html
准备工具
在安装nginx衫,需要确保系统已经安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
检查系统安装的ningx
find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
卸载系统原有的nginx
yum remove nginx
centos安装nginx
将安装包文件上传到目录中,本文是上传到/usr/local中,按以下命令进行操作。[root@admin local]# cd /usr/local
[root@admin local]# tar -zxv -f nginx-1.2.6.tar.gz
[root@admin local]# rm -rf nginx-1.2.6.tar.gz
[root@admin local]# mv nginx-1.2.6 nginx
[root@admin local]# cd /usr/local/nginx
[root@admin nginx]# ./configure --prefix=/usr/local/nginx
[root@admin nginx]# make
[root@admin nginx]# make install
相关文章推荐
- nginx在centos6.5下的安装和反向代理简单配置
- Centos6.5安装及简单配置nginx
- CentOS安装Nginx,并配置nodejs反向代理
- centOS6.5下安装Nginx配置
- centos6.5下安装配置ELK及收集nginx日志
- CentOS6.5下nginx的安装与配置
- centos 7.3 安装 nginx 及简单配置
- Centos6.5编译安装Nginx-1.11.5和简单配置
- centos6.5下安装nginx配置https
- linux系统上nginx安装及简单的反向代理配置
- centOS7 下Nginx的简单安装配置
- CentOS6.5系统简单安装与配置Nginx服务器的方法
- centos 6.5下编译安装、配置高性能服务器Nginx(安装笔记)
- [CentOS 7] 安装nginx及简单配置
- 物理机安装Nginx服务器与虚拟机简单配置反向代理
- centos6.5下Nginx简单安装教程
- centos6.5下postgresql9.4.3同步流复制的standby安装与配置
- centos下简单配置安装Squid 3.0反向代理
- CentOS6.5下 Asterisk 的安装、配置及 2个软电话实现互拨
- Centos6.5,安装nginx,包含ssl模块,如果已经安装nginx则配置即可