ubantu安装Nginx
最近工作上有涉及Nginx的内容,所以学着安装一下。Nginx的主要作用是:
1.反向代理:将请求发送到反向代理的服务器,由反向代理分区器去选择目标服务器获取数据后,再返回给客户端
2.负载均衡:增加服务器的数量,然后将请求分发到各个服务器上,将原先请求集中到单个服务器上的情况改为将请求分发到多个服务器上,将负载分发到不同的服务器。
3.动静结合:为了加快网站的解析速度,可以把动态页面和静态页面由不同的服务器来解析,加快解析速度。降低原来单个服务器的压力。
Nginx主要的网上安装Nginx教程的很多,我也是按照大佬们的学习之后,再来安装。之后做一个笔记。
安装Nginx
安装Nginx主要有两种方法:1.apt方式下载 2.下载对应的安装包之后,下依赖包,编译安装等。
1.apt下载
apt-get install nginx
(如下图)
但出现报错信息(一波未平一波又起):
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5147 (apt-get)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
找了一下大佬的笔记,然后就解决了(大佬是真的强)。代码如下:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
sudo dpkg --configure -a
sudo apt update
然后再升级一下
root@ubuntu:/home**/Documents/myfile/12month# apt list --upgradable
Listing... Done
alsa-ucm-conf/focal-updates,focal-updates 1.2.2-1ubuntu0.11 all [upgradable from: 1.2.2-1ubuntu0.9]
ghostscript-x/focal-updates 9.50~dfsg-5ubuntu4.4 amd64 [upgradable from: 9.50~dfsg-5ubuntu4.3]
ghostscript/focal-updates 9.50~dfsg-5ubuntu4.4 amd64 [upgradable from: 9.50~dfsg-5ubuntu4.3]
gir1.2-mutter-6/focal-updates 3.36.9-0ubuntu0.20.04.2 amd64 [upgradable from: 3.36.9-0ubuntu0.20.04.1]
gir1.2-udisks-2.0/focal-updates 2.8.4-1ubuntu2 amd64 [upgradable from: 2.8.4-1ubuntu1]
gnome-control-center-data/focal-updates,focal-updates 1:3.36.5-0ubuntu3 all [upgradable from: 1:3.36.5-0ubuntu2]
gnome-control-center-faces/focal-updates,focal-updates 1:3.36.5-0ubuntu3 all [upgradable from: 1:3.36.5-0ubuntu2]
gnome-control-