当前位置:   article > 正文

Ubuntu安装Nginx 过程与错误原因总结_ubuntu npx无法安装

ubuntu npx无法安装

1.更新安装源

执行:sudo apt-get update

执行这步的原因:避免安装nginx相关依赖包时出现:unable to locate package xxx。这个错误提示

2.安装nginx相关依赖包

  1. ~~~1.# 查看zlib是否安装
  2. dpkg -l | grep zlib
  3. ~~~2.# 解决依赖包openssl
  4. 安装:sudo apt-get install openssl libssl-dev
  5. ~~~3.# 解决依赖包pcre安装
  6. sudo apt-get install libpcre3 libpcre3-dev
  7. ~~~4.# 解决依赖包zlib安装
  8. sudo apt-get install zlib1g-dev

3.下载nginx

  1. 访问Nginx官网下载
  2. 1.下载nginx
  3. wget http://nginx.org/download/nginx-1.13.1.tar.gz
  4. 2. 解压nginx
  5. tar -xzvf nginx-1.13.1.tar.gz
  6. 3. 重命名文件夹
  7. mv nginx-1.13.1 nginx
  8. 4. 移动文件夹到ubuntu常见软件目录下
  9. mv nginx/ /usr/local/

4.安装nginx

注意

1)在/usr/local/nginx目录下执行: mkdir logs。 

如果没有执行此步,将会在install的时候出现:could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory) 错误提示

2)执行:/usr/local/nginx/sbin/nginx  -c  /usr/local/nginx/conf/nginx.conf

如果没有执行此步,将会在install的时候出现:configuration file /usr/local/nginx/conf/nginx.conf test failed 错误提示

 

  1. 1)配置nginx
  2. ① cd /usr/local/nginx
  3. ② sudo ./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module --with-http_ssl_module--with-http_realip_module
  4. 2)编译nginx
  5. sudo make
  6. 3)安装nginx
  7. sudo make install

5. 检查nginx是否安装成功

  1. 1. cd /usr/local/nginx/sbin
  2. 2. ./nginx –t
  1. 如果结果显示为:
  2. nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  4. 则表示安装成功

参考博客:https://www.linuxidc.com/Linux/2016-08/134110.htm

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/947716
推荐阅读
相关标签
  

闽ICP备14008679号