Loading

nginx 安装

在虚拟机测试了一遍,安装过程总结

Centos6.5,Nginx1.8.1

准备工作,安装依赖和必要配置

yum -y install pcre* 
yum -y install openssl*

groupadd www  #添加www用户组
useradd -g www www  #新添加www用户,且用户组隶属于www用户组

安装nginx

下载解压

cd /usr/src	
wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar zxvf nginx-1.8.1.tar.gz

编译安装

cd nginx-1.8.1

./configure --help # 查看可配置项

./configure --user=www --group=www --prefix=/usr/local/nginx-1.8.1  --with-http_ssl_module --with-http_spdy_module  --with-http_stub_status_module --with-pcre
make
make install

开启,关闭,重启nginx进程

/usr/local/nginx-1.8.1/sbin/nginx #开启
/usr/local/nginx-1.8.1/sbin/nginx -s reload #重启
/usr/local/nginx-1.8.1/sbin/nginx -s stop #关闭

添加防火墙规则

安装完后,本地浏览器输入localhost,可以看到nginx启动页:Welcome to nginx! ,但是其他机器访问却是超时,是由于centos防火墙拦截所导致

service iptables status #查看防火墙状态

可以看到结果中并没有开放80端口

vim /etc/sysconfig/iptables

//添加一条开发80端口的规则后保存(参照22端口写一条,其他端口一样)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

重启防火墙服务后,外网就可以看到 Welcome to Nginx 了

service iptables restart
posted @ 2016-04-06 10:34  sloong  阅读(369)  评论(0编辑  收藏  举报