首页 > 技术文章 > uwsgi+nginx 基于linux的各种离谱错误

shanjiaaa 2020-12-11 17:41 原文

1.常见的排查方法  

1.nginx错误 

  • 启动报错
systemctl restart nginx 
tail -f /var/log/nginx/error.log
  • 在浏览器中访问抱错
tail -f /var/log/nginx/access.log 

cd /home/worker/opwf_project/uwsgi_conf tail -f *

  

2.端口占用冲突问题
  • 端口占用
(syl) root@dev:uwsgi_conf# netstat -anptu | grep 8000 # 查看端口是否占用 

 kill -9 68279 
  • uwsgi每次修改代码后最好都重启一下
uwsgi --ini uwsgi.ini # 启动 
(syl) root@dev:uwsgi_conf# ps -ef|grep uwsgi

 

 

 

 

3.nginx权限问题,无法打开vue部署文件
  • 修改nginx启动用户为root
  • vim /etc/nginx/nginx.conf 

 

 

4. 如果下载 nginx 显示无法 “E 无法定位软件“?

  •  解决:换源,linux ubuntu默认欧洲源 ,我们换为中国的
前言:看见Ubuntu新出了18.04版本感觉不错,装一个玩玩,虽然有很多教程可以参考,但我也给出一个不是很一样的方案吧,尽量解释的详细一点。

为了下载更方便,速度更快,我们往往在使用Linux系列系统时修改apt源为国内的源,一般选择有阿里云,豆瓣之类的,下面简单说下如何更改为阿里云源。

 

1.复制源文件备份,以防万一

我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。

命令如下:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

 

2.编辑源列表文件

命令如下:

sudo vim /etc/apt/sources.list

如果报错:sudo:vim:command not found    说明没装vim编辑器

使用命令:

sudo apt-get install vim 安装即可

 

3.查看新版本信息

其实Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:

使用如下命令:

lsb_release -c

得到本系统的系统代号,如下图所示:



我们可以看到新版本的Ubuntu系统代号为bionic

同样的我们也可以得到之前任意版本的系统代号:

Ubuntu 12.04 (LTS)代号为precise。

Ubuntu 14.04 (LTS)代号为trusty。

Ubuntu 15.04 代号为vivid。

Ubuntu 15.10 代号为wily。

Ubuntu 16.04 (LTS)代号为xenial。

所以这也就解释了为什么我们百度出来的那么多方案里面内容不尽相同的原因,因为他们更改apt安装源时用的系统不一样。

 

4.将原有的内容注释掉,添加以下内容(或者你把里面内容修改成下面的就可以,但是不能有除了以下内容的有效内容)

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

 

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

 

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

 

值得注意的是sources.list文件的条目都是有格式的(通过上面的内容大家也看的出来),一般有如下形式

 

deb http://site.example.com/debian distribution component1 component2 component3
deb-src http://site.example.com/debian distribution component1 component2 component3
所以后面几个参数是对软件包的分类(Ubuntu下是main, restricted,universe ,multiverse这四个)

所以你把内容写成

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed universe multiverse

之类的也是可以的,之前我有这个疑惑,所以在这里一并告知和我有一样疑惑的朋友。

 

5.更新软件列表

运行如下命令:

sudo apt-get update

 

6.更新软件包

运行如下命令:

sudo apt-get upgrade

 

 

 永远记住:这个错,绝对是配置文件出错,少一个分号,多一个逗号,或者少写什么配置都会出现

推荐阅读