阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Linux(CentOS 6.5) 下Nginx 安装

123次阅读
没有评论

共计 2018 个字符,预计需要花费 6 分钟才能阅读完成。

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:

[root@linuxidc 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@linuxidc nginx-1.9.9]# /home/nginx/sbin/nginx
nginx: [emerg] getpwnam(“nginx”) failed

解决方法 1:
      在 nginx.conf 中 把 user nobody 的注释去掉既可
解决方法 2:
      错误的原因是没有创建 www 这个用户,应该在服务器系统中添加 www 用户组和用户 www,如下命令:

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

注:之前没添加用户和用户组。

更多 CentOS 相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-07/133462.htm

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-21发表,共计2018字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中