centos6.5_64bit-nginx安装部署

1、配置防火墙,开启80端口、3306端口
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(允许80端口通过防火墙)
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT(允许3306端口通过防火墙)
特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
添加好之后防火墙规则如下所示:
#########################################################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -mstate --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -mstate --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
#########################################################
/etc/init.d/iptables restart  #最后重启防火墙使配置生效
2、关闭SELINUX
vim /etc/selinux/config
#SELINUX=enforcing       #注释掉
#SELINUXTYPE=targeted    #注释掉
SELINUX=disabled         #增加
:wq  保存,关闭
shutdown -r now   #重启系统
#########################################################
 
要安装的依赖包都在文件夹里
安装lrzsz-0.12.20-27.1.el6.x86_64.rpm
rpm -ivh lrzsz-0.12.20-27.1.el6.x86_64.rpm
最好确认一下gcc是否安装。
yum install -y gcc gcc-c++
安装pcre 后make提示:checking for gcc... no
checking for cc... no
checking for cl.exe... no,make 
说明gcc没装yum install -y gcc gcc-c++
nginx安装:
新建文件夹
mkdir /opt/nginx
 
1、安装pcre库
cd 
tar zxvf softs/nginx/pcre-8.39.tar.gz -C /opt/nginx/
cd pcre-8.37
./configure
make       
make install
2、安装zlib库
cd 
tar zxvf softs/nginx/zlib-1.2.8.tar.gz -C /opt/nginx/
cd zlib-1.2.8
./configure
make
make install
3、安装openssl
cd 
tar zxvf softs/nginx/openssl-1.0.2h.tar.gz -C /opt/nginx/
cd openssl-1.0.2h/
./config
make
make install
提示 perl 5 需要安装
tar zxvf softs/nginx/perl-5.16.3.tar -C /opt/nginx/
./configure -de
make
make install
 
4、安装nginx
cd 
tar zxvf softs/nginx/nginx-1.9.3.tar.gz -C /opt/nginx/
cd nginx-1.9.3
 
./configure --prefix=/opt/openresty --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module--with-pcre=/home/soft/pcre-8.39/--with-zlib=/home/soft/zlib-1.2.8/ --with-openssl=/home/soft/openssl-1.0.2h
 
//编译
 
make
//
安装
 
make install
或者
tar zxvf /home/soft/openresty-1.9.7.5.tar.gz -C /opt/nginx/
cd openresty-1.9.7.5
 
./configure--prefix=/opt/openresty--with-http_ssl_module --with-http_gzip_static_module--with-http_stub_status_module--with-pcre=/home/soft/pcre-8.39/--with-zlib=/home/soft/zlib-1.2.8/--with-openssl=/home/soft/openssl-1.0.2h/
 
openresty-1.9.7.5.tar.gz包含nginx
//编译
 
make
//
安装
 
make install
 
如果提示报错/home/wxgame/pcre/pcre-8.37什么的出错,那就把/home/wxgame/pcre/去掉改成 . . /pcre-8.37 ,三个都要改掉
 
  
启动nginx   查看nginx在那里
/opt/openresty/nginx/sbin/nginx   回车
 
 
报错:
如果启动报错:nginx: [emerg] still could not bind()
解决:先使用lsof查看一下端口占用情况
 # /usr/sbin/lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
nginx 9285 root 6u IPv4 386456 TCP *:http (LISTEN)
nginx 9286 www 6u IPv4 386456 TCP *:http (LISTEN)
杀掉重启
#kill -9 9285
#kill -9 9286
#/opt/openresty/nginx/sbin/nginx

 

posted @ 2017-04-28 16:09  pzczyy  阅读(155)  评论(0编辑  收藏  举报