我启动了一个全新的 Ubuntu 16.04 VPC,这是我采取的第一步,按照 NGINX “如何操作” 帖子中的说明这里在他们的网站上。我通过 SSH 登录后,在此之前没有执行任何其他步骤,但它却给我错误消息。
ubuntu@ip-172-31-8-90:/$ sudo wget http://nginx.org/keys/nginx_signing.key
--2017-07-01 05:57:39-- http://nginx.org/keys/nginx_signing.key
Resolving nginx.org (nginx.org)... 206.251.255.63, 95.211.80.227,
2001:1af8:4060:a004:21::e3, ...
Connecting to nginx.org (nginx.org)|206.251.255.63|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1561 (1.5K) [text/plain]
Saving to: ‘nginx_signing.key’
nginx_signing.key 100%[================================================================================================================>] 1.52K --.-KB/s in 0s
2017-07-01 05:57:40 (323 MB/s) - ‘nginx_signing.key’ saved [1561/1561]
ubuntu@ip-172-31-8-90:/$ sudo apt-key add nginx_signing.key
OK
ubuntu@ip-172-31-8-90:/$ sudo nano /etc/apt/sources.list
附加源列表和
deb http://nginx.org/packages/ubuntu xenial nginx
deb-src http://nginx.org/packages/ubuntu xenial nginx
然后
ubuntu@ip-172-31-8-90:/$ sudo apt-get update
Hit:1 http://us-west-1.ec2.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://us-west-1.ec2.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://us-west-1.ec2.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 http://nginx.org/packages/ubuntu xenial InRelease
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Fetched 102 kB in 0s (136 kB/s)
Reading package lists... Done
ubuntu@ip-172-31-8-90:/$ sudo apt-get install nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libtiff5 libvpx3 libxpm4 libxslt1.1 nginx-common nginx-core
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
nginx
1 upgraded, 0 newly installed, 0 to remove and 30 not upgraded.
Need to get 0 B/786 kB of archives.
After this operation, 2,777 kB of additional disk space will be used.
(Reading database ... 51251 files and directories currently installed.)
Preparing to unpack .../nginx_1.12.0-1~xenial_amd64.deb ...
Unpacking nginx (1.12.0-1~xenial) over (1.10.3-0ubuntu0.16.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.12.0-1~xenial_amd64.deb (--unpack):
trying to overwrite '/usr/share/nginx/html/index.html', which is also in package nginx-common 1.10.3-0ubuntu0.16.04.1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
/var/cache/apt/archives/nginx_1.12.0-1~xenial_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
要解决您的问题,请运行
sudo dpkg -i --force-overwrite /var/cache/apt/archives/nginx_1.12.0-1~xenial_amd64.deb
运行以下命令检查所有问题是否解决:
sudo apt-get -f install