我将这些行添加到“/etc/apt/sources.list”中:
deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx
之后我尝试使用以下命令更新 nginx:
sudo apt-get clean && sudo apt-get install nginx
但我收到以下错误:
Unpacking nginx (1.9.15-1~jessie) over (1.6.2-5+deb8u1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.9.15-1~jessie_amd64.deb (--unpack):
trying to overwrite '/usr/share/nginx/html/index.html', which is also in package nginx-common 1.6.2-5+deb8u1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nginx_1.9.15-1~jessie_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
我做错了什么?谢谢。
答案1
在终端上运行以下命令:
sudo dpkg -P nginx-common
sudo apt-get install -f
如果在卸载上述 nginx-common 包时出现任何依赖问题,则清除 nginx-common 包及其依赖项:
sudo apt-get purge nginx*
在运行上述命令之前,不要忘记检查将与 nginx 一起清除的依赖包。
sudo apt-get purge -s nginx*
然后您将能够安装NGinX。
答案2
按照你说的做完之后,在运行apt-get update命令之前,需要获取nginx的公钥:
wget http://nginx.org/packages/keys/nginx_signing.key
cat nginx_signing.key | apt-key add -
然后更新并安装。