CentOS 4.0安裝配置Nginx的方法_nginx

來源:互聯網
上載者:User

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  //即可

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.