帮助解决混乱的 Nginx 安装(Trusty 14.04 服务器)

帮助解决混乱的 Nginx 安装(Trusty 14.04 服务器)

我有点菜鸟。我想尝试一下 nginx,但在安装时遇到了一些错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  nginx-common nginx-core
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  nginx nginx-common nginx-core
0 upgraded, 3 newly installed, 0 to remove and 84 not upgraded.
Need to get 348 kB of archives.
After this operation, 1,296 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu/ trusty-updates/main nginx-common all 1.4.6-1ubuntu3.2 [18.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main nginx-core amd64 1.4.6-1ubuntu3.2 [325 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main nginx all 1.4.6-1ubuntu3.2 [5,420 B]
Fetched 348 kB in 1s (313 kB/s)    
Selecting previously unselected package nginx-common.
(Reading database ... 124222 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.4.6-1ubuntu3.2_all.deb ...
Unpacking nginx-common (1.4.6-1ubuntu3.2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.2_all.deb (--unpack):**
 trying to overwrite '/usr/share/man/man1/nginx.1.gz', which is also in package sw-nginx 1.6.0-1.14060313.ubuntu1404
Selecting previously unselected package nginx-core.
Preparing to unpack .../nginx-core_1.4.6-1ubuntu3.2_amd64.deb ...
Unpacking nginx-core (1.4.6-1ubuntu3.2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-core_1.4.6-1ubuntu3.2_amd64.deb (--unpack):**
 trying to overwrite '/usr/sbin/nginx', which is also in package sw-nginx 1.6.0-1.14060313.ubuntu1404
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)**
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.4.6-1ubuntu3.2_all.deb ...
Unpacking nginx (1.4.6-1ubuntu3.2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.2_all.deb
 /var/cache/apt/archives/nginx-core_1.4.6-1ubuntu3.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我试过apt-get 安装 nginx还有一个项目:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
nginx is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 nginx : Depends:

 nginx-core (>= 1.4.6-1ubuntu3.2) but it is not going to be installed or
                  nginx-full (>= 1.4.6-1ubuntu3.2) but it is not going to be installed or
                  nginx-light (>= 1.4.6-1ubuntu3.2) but it is not going to be installed or
                  nginx-extras (>= 1.4.6-1ubuntu3.2) but it is not going to be installed or
                  nginx-naxsi (>= 1.4.6-1ubuntu3.2) but it is not going to be installed
         Depends: nginx-core (< 1.4.6-1ubuntu3.2.1~) but it is not going to be installed or
                  nginx-full (< 1.4.6-1ubuntu3.2.1~) but it is not going to be installed or
                  nginx-light (< 1.4.6-1ubuntu3.2.1~) but it is not going to be installed or
                  nginx-extras (< 1.4.6-1ubuntu3.2.1~) but it is not going to be installed or
                  nginx-naxsi (< 1.4.6-1ubuntu3.2.1~) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

我应该这么做apt-get -f 安装? 那会有什么作用?

尝试过apt-get -f 安装并得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  nginx-common nginx-core
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  nginx-common nginx-core
0 upgraded, 2 newly installed, 0 to remove and 84 not upgraded.
1 not fully installed or removed.
Need to get 0 B/343 kB of archives.
After this operation, 1,201 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 124227 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.4.6-1ubuntu3.2_all.deb ...
Unpacking nginx-common (1.4.6-1ubuntu3.2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.2_all.deb (--unpack):
 trying to overwrite '/usr/share/man/man1/nginx.1.gz', which is also in package sw-nginx 1.6.0-1.14060313.ubuntu1404
Preparing to unpack .../nginx-core_1.4.6-1ubuntu3.2_amd64.deb ...
Unpacking nginx-core (1.4.6-1ubuntu3.2) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-core_1.4.6-1ubuntu3.2_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package sw-nginx 1.6.0-1.14060313.ubuntu1404
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db (2.6.7.1-1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/nginx-common_1.4.6-1ubuntu3.2_all.deb
 /var/cache/apt/archives/nginx-core_1.4.6-1ubuntu3.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

它与sw-nginx包冲突:

dpkg: error processing archive /var/cache/apt/archives/nginx-core_1.4.6-1ubuntu3.2_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package sw-nginx 1.6.0-1.14060313.ubuntu1404

去掉它:

sudo apt-get purge sw-nginx

相关内容