linux nginx安装

Linux中必备常用支持库的安装(CentOS-6.5)

yum install -y gcc gdb strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers libevent-devel libevent uuid-devel uuid mysql-devel

3.3 Nginx安装

0)创建用户nginx使用的www用户。
# groupadd  www  #添加www组    
# useradd -g  www www -s /bin/false  #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统

创建安装目录与日志目录
a) 安装目录
# mkdir /usr/local/nginx
b) 日志目录
# mkdir /data0/logs/nginx
# chown www:www /data0/logs/nginx -R
1) 判断系统是否安装了zlib-devel。如果没有安装。使用
# yum install -y zlib-devel

Linux中Nginx安装与配置详解

2) 解压
# cd /usr/local/src/nginx
# tar zxvf nginx-1.5.0.tar.gz
3) 进入目录
# cd nginx-1.5.0
4) 配置。通常将软件安装在/usr/local/目录下。
# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
5)编译
# make
6) 安装
#  make install
7) 检查是否安装成功
# cd  /usr/local/nginx/sbin
# ./nginx -t 
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
3.4 配置防火墙80端口
#修改防火墙配置: 
# vi + /etc/sysconfig/iptables
#添加配置项 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#重启防火墙 
# service iptables restart
3.5 上传配置文件
1)上传nginx.conf (文件下载地址见上面的Linux公社资源站)
# cd /usr/local/nginx/conf
# rz nginxrz fastcgi_params.phis
3.6 启动停止重启与测试
1)启动
    #方法1
    # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    #方法2
    # cd /usr/local/nginx/sbin
    # ./nginx
# cd /usr/local/nginx/sbin
    # ./nginx
 2) 停止
    #查询nginx主进程号 
    ps -ef | grep nginx
    #停止进程 
    kill -QUIT 主进程号 
    #快速停止 
    kill -TERM 主进程号 
    #强制停止 
    pkill -9 nginx
3) 重启
(首次启动需:/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf)
/usr/local/nginx/sbin/nginx -s reload
4)测试
    #测试端口 
    netstat -na | grep 80
    #浏览器中测试 
    http://ip:80
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GY程序源

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值