发布于 2016-01-29 01:25:59 | 224 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Nginx中文文档,程序狗速度看过来!

Nginx WEB服务器

Nginx 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。


这篇文章主要介绍了CentOS 4.0安装配置Nginx的方法,需要的朋友可以参考下

1.安装说明:

系统环境:CentOS-4.0

2.依赖的程序

    (1). gzip module requires zlib library
    (2). rewrite module requires pcre library
    (3). ssl support requires openssl library

3.依赖程序的安装有两种方法:一种是下载包安装二是YUM一次性安装

(1)zlib安装
    下载地址:http://zlib.net/fossils/
      $tar -xvzf zlib-1.2.5.tar.gz
      $cd zlib-1.2.5.tar.gz
      $./configure
      $make
      $make install
(2)pcre安装
    下载地址:http://ftp.exim.llorien.org/pcre/
      $tar -xvzf pcre-8.02.tar.gz
      $cd pcre-8.02
      $./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties
      $ make && make install
(3)openssl安装
    下载地址:http://mirrors.ibiblio.org/openssl/source/
      $tar zvxf openssl-1.0.0.tar.gz
      $cd openssl-1.0.0
      $./config --prefix=/usr/local/ssl-1.0.0 shared zlib-dynamic enable-camellia
      $make && make install

(4)nginx安装

    下载地址:http://nginx.org/download/
      $tar zvxf Nginx 0.8.40.tar.gz
      $cd Nginx 0.8.40
      $./configure
      $ make
      $ make install
     更多配置:
      ./configure --prefix=/usr/local/nginx
     --with-openssl=/usr/include (启用ssl)
     --with-pcre=/usr/include/pcre/ (启用正规表达式)
     --with-http_stub_status_module (安装可以查看nginx状态的程序)
     --with-http_memcached_module (启用memcache缓存)
     --with-http_rewrite_module (启用支持url重写)
    方法二如下:这种方法就好,不容易出错,如果网速快10分内可以完成,网速不好也可以在20分内完成。
        yum –y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
    现在三个依赖的程序的安装成功,下面是安装Nginx 0.8.40了。

      官网下载地址:http://www.nginx.org/
      $tar zvxf Nginx 0.8.40.tar.gz
      $cd Nginx 0.8.40
      $./configure  //默认安装在/usr/local/nginx下
      $ make
      $ make install

4.配置(很重要)



    #修改防火墙配置: 

    [root@bogon nginx-0.8.4]# vi + /etc/sysconfig/iptables

    #添加配置项 

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

    #重启防火墙 

    [root@bogon nginx-0.8.4]# service iptables restart

5.启动:



    #方法1

    [root@bogon nginx-0.8.4]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    #方法2

    [root@bogon nginx-0.8.4]# cd /usr/local/nginx/sbin

    [root@bogon sbin]# ./nginx

6.停止:



    #查询nginx主进程号 

    ps -ef | grep nginx

    #停止进程 

    kill -QUIT 主进程号 

    #快速停止 

    kill -TERM 主进程号 

    #强制停止 

    pkill -9 nginx

7.测试:



    #测试端口 

    netstat –na|grep 80

    #浏览器中测试 

    http://127.0.0.1:80

8.注意问题:
    安装nginx时出现情况的解决办法:



    [root@bogon sbin]# ./nginx

    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)

    [emerg]: still could not bind()

    #netstat -nptl  //查看80端口已被使用
    #killall nginx  //即可



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务