[root@localhost ~]# yum -y install gcc gcc-c++ automake autoconf libtool makeb) 安装prec
[root@localhost ~]# yum install pcre.x86_64 pcre-devel.x86_64c) 安装zlib
[root@localhost ~]# yum install zlib.x86_64 zlib-devel.x86_64d) 安装openssl
[root@localhost ~]# yum install openssl.x86_64 openssl-devel.x86_64
[root@localhost ~]# wget http://nginx.org/download/nginx-1.4.7.tar.gzb) 解压
[root@localhost ~]# tar -xvf nginx-1.4.7.tar.gz [root@localhost ~]# cd nginx-1.4.7c) 安装i. 指定安装文件夹
[root@localhost ~]# ./configure --prefix=/usr/local/nginx/cache/ii. make & make install
[root@localhost ~]# make [root@localhost ~]# make install
[root@localhost ~]# netstat –nltp | grep 80b) root启动nginx,
[root@localhost ~]# /usr/local/nginx/cache/sbin/nginx -c /usr/local/nginx/cache/conf/nginx.conf
[root@localhost ~]# telnet 10.237.92.30 80 Trying 10.237.92.30... telnet: Unable to connect to remote host: No route to hostb) Centos的防火墙默认是打开的,查看本机防火墙配置
[root@localhost ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) num target prot opt source destinationc) 打开80port
[root@localhost ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT查看port会发现port通了
guojun1@guojun1-OptiPlex-9020:~$ telnet 10.237.92.30 80 Trying 10.237.92.30... Connected to 10.237.92.30. Escape character is ‘^]‘. ^]d) 改动iptables配置文件使用iptables命令添加的规则在重新启动之后就失效了,要想规则在重新启动之后任然有效, 须要改动iptables配置文件/etc/sysconfig/iptables,添加以下的行。
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
原文:http://www.cnblogs.com/jzdwajue/p/7044162.html