菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
197
0

nginx 安装

原创
05/13 14:22
阅读数 65714

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

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

发表评论

0/200
197 点赞
0 评论
收藏