歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux安裝 >> Linux(CentOS 6.5) 下Nginx 安裝

Linux(CentOS 6.5) 下Nginx 安裝

日期:2017/4/19 14:04:55   编辑:Linux安裝

Nginx一個高性能的HTTP反向代理服務器,也是一個IMAP/POP3/SMTP服務器,一個Apache服務器不錯的替代品。

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

負載均衡服務器

郵件代理服務器

,一款輕量級的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:

[[email protected] 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
[[email protected] nginx-1.9.9]# /home/nginx/sbin/nginx
nginx: [emerg] getpwnam("nginx") failed

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

[[email protected] nginx-1.9.9]# groupadd nginx
[[email protected] nginx-1.9.9]# useradd -s /sbin/nologin -M -g nginx nginx
[[email protected] 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

注:之前沒添加用戶和用戶組。

Copyright © Linux教程網 All Rights Reserved