设为首页 收藏本站
查看: 824|回复: 0

[经验分享] 服务器上编译安装nginx

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-6-29 10:08:33 | 显示全部楼层 |阅读模式
操作系统:CentOS release 6.8 (Final)
Web应用服务器软件:nginx-1.10.1.tar.gz
实战任务:编译安装nignx
下载:#wget http://nginx.org/download/nginx-1.10.1.tar.gz
#wgetftp://ftp.csx.cam.ac.uk/pub/soft ... /pcre2-10.20.tar.gz
# tar zxvf pcre2-10.20.tar.gz
#cd pcre2-10.20
#./configure
# make && make install
#useradd  nginx -s /sbin/nologin  -M
# wget  http://nginx.org/download/nginx-1.10.1.tar.gz
#tar  zxf nginx-1.10.1.tar.gz
#cd nginx-1.10.1
[iyunv@sky9896 nginx-1.10.1]#./configure--user=nginx \
--group=nginx \
--prefix=/application/nginx-1.10.1\
--with-http_stub_status_module \
--with-http_ssl_module
./configure: error: theHTTP rewrite module requires the PCRE library.
You can either disable the module by using--without-http_rewrite_module
option, or install the PCRE library intothe system, or build the PCRE library
statically from the source with nginx byusing --with-pcre=<path> option.
[root@sky9896nginx-1.10.1]# yum -y install pcre-devel #解决上述问题:
[iyunv@sky9896 nginx-1.10.1]#make && make install
[iyunv@sky9896 nginx-1.10.1]#ln -s /application/nginx-1.10.1 /application/nginx
[iyunv@sky9896 nginx-1.10.1]#/application/nginx/sbin/nginx  -t
nginx: the configuration file/application/nginx-1.10.1/conf/nginx.confsyntax is ok
nginx: configuration file/application/nginx-1.10.1/conf/nginx.conftest is successful
[iyunv@sky9896 nginx-1.10.1]#lsof -i :80
COMMAND  PID   USER   FD  TYPE  DEVICE SIZE/OFF NODE NAME
httpd   1732   root    4u IPv6   10810      0t0 TCP *:http (LISTEN)
sdsvrd  1899   root   15u IPv4 8828354      0t0  TCP bbs.jxatei.net:9965->110.86.5.94:http(ESTABLISHED)
httpd   5506 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5526 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5529 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5543 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5544 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5545 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5546 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5547 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5548 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5549 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd   5550 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  17445 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30642 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30643 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30644 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30647 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30648 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30649 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30650 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
httpd  30651 apache    4u  IPv6  10810      0t0  TCP *:http (LISTEN)
[iyunv@sky9896 nginx-1.10.1]#netstat -lnt|grep 80
tcp       0      0::ffff:127.0.0.1:8005       :::*                        LISTEN     
tcp       0      0 :::8009                     :::*                        LISTEN     
tcp       0      0 :::8080                     :::*                        LISTEN     
tcp       0      0 :::80                       :::*                        LISTEN   

[iyunv@sky9896 nginx-1.10.1]#ps -ef|grep nginx
root     6862 16136  0 09:17 pts/0    00:00:00 grep nginx
#通过以上操作检查,说明nginx并没有正常工作,分析原因是与apache引起端口冲突。
[iyunv@sky9896conf]# vi nginx.conf
  listen     80;  #改成 listen 9090
[iyunv@sky9896sbin]# ./nginx -s reload  #重启nginx后丢失nginx.pid,如何重新启动nginx
nginx: [error]invalid PID number "" in "/application/nginx-1.10.1/logs/nginx.pid"
[iyunv@sky9896conf]# ../sbin/nginx –c  /application/nginx/conf/nginx.conf
[iyunv@sky9896conf]# ../sbin/nginx -s reload
[iyunv@sky9896conf]# netstat -lnt|grep 9090
tcp        0     0 0.0.0.0:9090           0.0.0.0:*          LISTEN
[iyunv@sky9896conf]# ps -ef|grep nginx
root     10400 16136  0 09:24 pts/0    00:00:00 ./nginx
root     14560    1  0 09:32 ?        00:00:00 nginx: master process../sbin/nginx -c /application/nginx/conf/nginx.conf
nginx    14646 14560 0 09:33 ?        00:00:00 nginx:worker process                             
nginx    14647 14560 0 09:33 ?        00:00:00 nginx:worker process                             
nginx    14648 14560 0 09:33 ?        00:00:00 nginx: worker process                             
nginx    14649 14560 0 09:33 ?        00:00:00 nginx:worker process                             
nginx    14650 14560 0 09:33 ?        00:00:00 nginx:worker process                             
nginx    14651 14560 0 09:33 ?        00:00:00 nginx:worker process                             
nginx    14653 14560 0 09:33 ?        00:00:00 nginx: workerprocess                             
nginx    14654 14560 0 09:33 ?        00:00:00 nginx:worker process                             
root     15061 16136  0 09:34 pts/0    00:00:00 grep nginx
[iyunv@sky9896conf]# vi  /etc/sysconfig/iptables
-A INPUT -p tcp-m state --state NEW -m tcp --dport 9090 -j  ACCEPT  #9090端口通过防火强
[iyunv@sky9896conf]#  vi /etc/rc.local
/applicaction/nginx/sbin/nginx #在末尾加该语句,可以随系统启动服务
小结,配置端口不冲突之后,每次重启服务还会导致nginx.pid丢掉,无法正常开启,估计主要原因是在一台服务器上配置了多个web服务,包括Apache、Tomcat和nginx,运行冲突导致。最终把下面两条语句放在/rc.local 文件中才解决nginx.pid的问题。
/applicaction/nginx/sbin/nginx
/application/nginx/sbin/nginx–c  /application/nginx/conf/nginx.conf



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-236840-1-1.html 上篇帖子: fail2ban 的安装配置 下篇帖子: nginx 之 Module ngx_http_proxy_module 深入研究 服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表