Linux(Centos6.5) Nginx 安裝,centos6.5nginx

來源:互聯網
上載者:User

Linux(Centos6.5) Nginx 安裝,centos6.5nginx

  Nginx一個高效能的HTTP和反向 Proxy伺服器,也是一個IMAP/POP3/SMTP伺服器,一個Apache伺服器不錯的替代品。

            能夠支援高達 50,000 個並發串連數的響應

            負載平衡伺服器

            郵件Proxy 伺服器

   它,一款輕量級的web伺服器越來越被人們所熟知。作為即將要步上營運的我,也不得不去學習、瞭解、專研它,說實話這是我第一篇部落格,也是我一個新的起點,我希望我能夠在這條路上越走越遠。

    

以下是我全部正確的安裝過程:

1.安裝Nginx依賴包

yum install -y pcre pcre-devel
yum install -y openssl openssl-devel

2.將下載的Nginx源碼包上傳到/home下  然後解壓
tar zxvf nginx-1.9.9.tar.gz

3.進入到解壓檔案下
cd nginx-1.9.9

4.建立Nginx的使用者組及使用者
groupadd nginx
useradd -s /sbin/nologin -M -g nginx nginx

5.編譯及安裝
./configure --user=nginx --group=nginx --prefix=/home/nginx-1.9.9 --conf-path=/home/nginx-1.9.9/nginx.conf --with-http_stub_status_module --with-http_ssl_module
make && make install

6.配置
ln -s /home/nginx1.9.9/ /home/nginx
echo 'PATH=/home/nginx-1.9.9/sbin:$PATH' >>/etc/profile
source /etc/profile

7.啟動
nginx -v
/home/nginx/sbin/nginx -t
/home/nginx/sbin/nginx

8.檢查
ps -ef |grep nginx
netstat -antup |grep 80

 安裝過程中的問題:

問題1:

make && make install

……

cp conf/koi-win '/home/nginx-1.9.9/conf'
cp: `conf/koi-win' and `/home/nginx-1.9.9/conf/koi-win' are the same file
make[1]: *** [install] Error 1
make[1]: Leaving directory `/home/nginx-1.9.9'
make: *** [install] Error 2

解決方案:

將這一步改一下

./configure --prefix=/usr/local/nginx  

TO

./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf  

註:之前我沒有加這句,安裝過程中各個組件需要對應的安裝路徑。

 

問題2:

[root@CC nginx-1.9.9]# /home/nginx/sbin/nginx -t
nginx: the configuration file /home/nginx-1.9.9/nginx.conf syntax is ok
nginx: [emerg] getpwnam("nginx") failed
nginx: configuration file /home/nginx-1.9.9/nginx.conf test failed
[root@CC nginx-1.9.9]# /home/nginx/sbin/nginx
nginx: [emerg] getpwnam("nginx") failed

解決方案1:
      在nginx.conf中 把user nobody的注釋去掉既可
解決方案2:
      錯誤的原因是沒有建立www這個使用者,應該在伺服器系統中添加www使用者組和使用者www,如下命令:

[root@CC nginx-1.9.9]# groupadd nginx
[root@CC nginx-1.9.9]# useradd -s /sbin/nologin -M -g nginx nginx
[root@CC nginx-1.9.9]# /home/nginx/sbin/nginx -t
nginx: the configuration file /home/nginx-1.9.9/nginx.conf syntax is ok
nginx: configuration file /home/nginx-1.9.9/nginx.conf test is successful

註:之前沒添加使用者和使用者組。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.