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

[经验分享] ubuntu安装nginx-1.8.0.tar.gz

[复制链接]

尚未签到

发表于 2018-11-14 11:38:02 | 显示全部楼层 |阅读模式
  安装包:nginx-1.8.0.tar.gz
  挂载Windows盘
  mount -t cifs -o username=xx,passwd=yyyy //IP地址/share /mnt
  解压nginx包到/usr/src/
  sudo tar -zxf nginx-1.8.0.tar.gz -C /usr/src/
  创建nginx用户和组
  cat /etc/group
  sudo groupadd –g 112 –r nginx
  sudo useradd –u 112 –r –g  112 nginx
  id nginx
  uid=112(nginx) gid=112(nginx) groups=112(nginx)
  编译nginx
  cd /usr/src/nginx-1.8.0
  sudo ./configure --prefix=/usr/local/nginx \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --http-log-path=/var/log/nginx/access.log \
  --pid-path=/var/run/nginx.pid \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_stub_status_module \
  --http-client-body-temp-path=/var/tmp/nginx/client \
  --http-proxy-temp-path=/var/tmp/nginx/proxy \
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
  --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
  --with-pcre
  错误:
  ./configure:error: the HTTP 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= option.
  缺少pcre-devel包
  解决:
  Centos :yum installpcre-devel  就可以解决
  Ubuntu : sduo apt-get pcre-devel  找不到pcre-devel包,debian/ubuntu系统下名称改了,名称为libpcre3 libpcre3-dev 正确命令如下:
  sudoapt-get install libpcre3 libpcre3-dev
  继续编译nginx
  错误:
  ./configure: error: SSL modules require the OpenSSL library.
  You can either do not enable the modules,or install the OpenSSL library
  into the system, or build the OpenSSLlibrary statically from the source
  with nginx by using --with-openssl=option.
  缺少openssl libssl-dev包
  解决:
  Centos:yum install openssl-devel
  Ubuntu: sudo apt-get install openssl libssl-dev
  重新编译成功
DSC0000.jpg

  sudo make
  错误:
  mkdir: cannot create directory ‘/usr/local/nginx’: Permission denied,创建/usr/src/nginx权限不够,我用sudo不知道为什么还是权限不够,后来直接mkdir /usr/src/nginx  问题OK
  解决:sudo mkdir /usr/src/nginx
  sudo make && make install
  安装完成
  启动nginx
  nginx 启动文件在--sbin-path=/usr/sbin/nginx
  sudo cp /usr/sbin/nginx /etc/init.d/
  sudo service nginx            启动nginx
  错误:
  nginx: [emerg] mkdir() "/var/tmp/nginx/client"failed (2: No such file or directory)没有
  /var/tmp/nginx/client 目录
  解决:
  sudo mkdir -p /var/tmp/nginx/client
  sudo service nginx
  查看端口
  sudo netstat –ntulp
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
  tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      23451/nginx
  tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1106/sshd
  tcp6       0      0 :::22                   :::*                    LISTEN      1106/sshd
  udp        0      0 0.0.0.0:68              0.0.0.0:*                           826/dhclient
  udp        0      0 0.0.0.0:23296           0.0.0.0:*                           826/dhclient
  udp6       0      0 :::43770                :::*                                826/dhclient
  开机自动启动chkconfig
  Ubuntu 不支持chkconfig,需安装
  Chkconfig.deb下载地址:http://download.csdn.net/download/hylongsuny/5276536
  dpkg –I chkconfig.deb
  sudo chkconfig --add nginx
  sudo chkconfig nginx on
  错误:
  /sbin/insserv: Nosuch file or directory
  解决:
  sudo find / -name insserv
  sudo ln -s /usr/lib/insserv/insserv /sbin/    软链接到/sbin/
  sudo chkconfig nginx on   chkconfig –list 查看nginx 服务是OK的,但报以下错误:
  niliyan@ubuntu2:/var/log$ sudo chkconfignginx on
  insserv: warning: script 'K20nginx' missingLSB tags and overrides
  insserv: warning: script 'nginx' missingLSB tags and overrides
  The script you are attempting to invoke hasbeen converted to an Upstart
  job, but lsb-header is not supported forUpstart jobs.
  insserv: warning: script'friendly-recovery' missing LSB tags and overrides
  insserv: Default-Start undefined, assumingempty start runlevel(s) for script `friendly-recovery'
  insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `friendly-recovery'
  The script you are attempting to invoke hasbeen converted to an Upstart
  job, but lsb-header is not supported forUpstart jobs.
  insserv: warning: script 'cron' missing LSBtags and overrides
  insserv: Default-Start undefined, assumingempty start runlevel(s) for script `cron'
  insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cron'
  在网上查了很久,chkconfig适用于redhat,ubuntu/debian应该使用update-rc.d 命令,可以用sudo update-rc.dnginx defaults 来替代sudochkconfig nginx on 启动nginx
  sudorm -rf /sbin/insserv      update-rc.d 可以不需要软件接,删除
  sudoupdate-rc.d nginx defaults
  update-rc.d:warning: /etc/init.d/nginx missing LSB information
  update-rc.d:see
  Adding system startup for /etc/init.d/nginx...
  /etc/rc0.d/K20nginx -> ../init.d/nginx
  /etc/rc1.d/K20nginx -> ../init.d/nginx
  /etc/rc6.d/K20nginx -> ../init.d/nginx
  /etc/rc2.d/S20nginx -> ../init.d/nginx
  /etc/rc3.d/S20nginx-> ../init.d/nginx
  /etc/rc4.d/S20nginx -> ../init.d/nginx
  /etc/rc5.d/S20nginx -> ../init.d/nginx
  sudo chkconfig --list |grep nginx
  nginx                     0:off  1:off 2:on   3:on   4:on  5:on   6:off
  访问测试
DSC0001.jpg



运维网声明 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-634959-1-1.html 上篇帖子: keepalived 双实例_nginx互为主备 下篇帖子: nginx 模块开发实例
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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