Nginx 安装不起作用

Nginx 安装不起作用

我遇到了 nginx 问题,我删除了 nginx,因为我在 nginx.conf 中做了一些修改,现在我无法安装它......

apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libmemcached11 libmemcachedutil2
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  nginx-common nginx-full
Suggested packages:
  fcgiwrap nginx-doc
The following NEW packages will be installed:
  nginx-common nginx-full
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/518 kB of archives.
After this operation, 1311 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 122283 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.6.2-5+deb8u4_all.deb ...
Unpacking nginx-common (1.6.2-5+deb8u4) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-common_1.6.2-5+deb8                                                                                                                                                             u4_all.deb (--unpack):
 trying to overwrite '/etc/nginx/scgi_params', which is also in package sw-nginx                                                                                                                                                              1.11.10-debian8.0.17040416
Preparing to unpack .../nginx-full_1.6.2-5+deb8u4_amd64.deb ...
Unpacking nginx-full (1.6.2-5+deb8u4) ...
dpkg: error processing archive /var/cache/apt/archives/nginx-full_1.6.2-5+deb8u4                                                                                                                                                             _amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/nginx', which is also in package sw-nginx 1.11.1                                                                                                                                                             0-debian8.0.17040416
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nginx-common_1.6.2-5+deb8u4_all.deb
 /var/cache/apt/archives/nginx-full_1.6.2-5+deb8u4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@vps:~# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 nginx : Depends: nginx-full (>= 1.6.2-5+deb8u4) but it is not installed or
                  nginx-light (>= 1.6.2-5+deb8u4) but it is not installed or
                  nginx-extras (>= 1.6.2-5+deb8u4) but it is not installed
         Depends: nginx-full (< 1.6.2-5+deb8u4.1~) but it is not installed or
                  nginx-light (< 1.6.2-5+deb8u4.1~) but it is not installed or
                  nginx-extras (< 1.6.2-5+deb8u4.1~) but it is not installed
E: Unmet dependencies. Try using -f.

答案1

尝试运行以下命令

sudo apt-get remove nginx && sudo apt-get purge nginx
sudo apt-get install nginx

清除删除应用程序的配置文件,但如果不先删除它,就会出现问题。

&&仅当执行了前一个命令时才执行,以退出代码 0(成功)退出echo $?将显示应用程序的退出代码。

如果所有这些都失败,请尝试运行dpkg -l|grep nginx并查找输出中的前两个字母以查看 nginx 包安装的状态。

例子

openssh-服务器

描述 dpkg 标志的链接 https://askubuntu.com/questions/18804/what-do-the-various-dpkg-flags-like-ii-rc-mean

答案2

尝试这个:

sudo apt-get purge nginx
sudo apt-get install nginx

我在 ubuntu 14.04 上,这对我有用。

相关内容