Errores de dpkg al intentar instalar nginx

Errores de dpkg al intentar instalar nginx

Intentando instalar nginx:

  1. Primero:

    sudo curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
    

    Resultado:

    Parece que todo está bien:

    > ## Run `sudo apt-get install -y nodejs` to install Node.js 16.x and npm
    > ## You may also need development tools to build native addons:
    >      sudo apt-get install gcc g++ make
    > ## To install the Yarn package manager, run:
    >      curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
    >      echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee
    > /etc/apt/sources.list.d/yarn.list
    >      sudo apt-get update && sudo apt-get install yarn
    
  2. Entonces:

    sudo apt install -y nodejs nano nginx
    

    Se ve bien pero se le pidió que corriera.apt --fix-broken install

    You might want to run 'apt --fix-broken install' to correct these.
    The following packages have unmet dependencies:
     nginx : Depends: nginx-core (< 1.18.0-6ubuntu11.1~) but it is not going to be installed or
                      nginx-full (< 1.18.0-6ubuntu11.1~) but it is not going to be installed or
                      nginx-light (< 1.18.0-6ubuntu11.1~) but it is not going to be installed or
                      nginx-extras (< 1.18.0-6ubuntu11.1~) but it is not going to be installed
             Depends: nginx-core (>= 1.18.0-6ubuntu11) but it is not going to be installed or
                      nginx-full (>= 1.18.0-6ubuntu11) but it is not going to be installed or
                      nginx-light (>= 1.18.0-6ubuntu11) but it is not going to be installed or
                      nginx-extras (>= 1.18.0-6ubuntu11) but it is not going to be installed
    E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
    
  3. Correr:

    apt --fix-broken install`
    

    Hay errores:

    dpkg: error processing archive /var/cache/apt/archives/nodejs_16.13.0-deb-1nodesource1_amd64.deb (--unpack):
     trying to overwrite '/usr/share/doc/nodejs/api/fs.html', which is also in package nodejs-doc 12.22.5~dfsg-5ubuntu1
    dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
    Errors were encountered while processing:
     /var/cache/apt/archives/nodejs_16.13.0-deb-1nodesource1_amd64.deb
    needrestart is being skipped since dpkg has failed
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

No sé qué hacer a continuación, pero parece que nginx no está instalado

Respuesta1

Dijiste que ni siquiera podías hacerlo apt-get install nginx. Yo también tuve ese problema y, en mi caso, ni siquiera pude desinstalar hasta que eliminé manualmente todas las instancias existentes de nginx. Parece que previamente había (intentado) instalar nginx algún día y no lo recordaba y mi instalación fue un desastre. Intentar

$ whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

Lo que hice fue forzar la eliminación de todos los que contenían rm -rfy luego eliminar los enlaces simbólicos existentes que encontré. Después de eso, finalmente pude desinstalar todos los paquetes relacionados con nginx que mencionaste y reinstalar nginx.

wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/nginx/1.18.0-6ubuntu11/nginx_1.18.0.orig.tar.gz
# extract
cd nginx_1.18.0.orig/nginx-1.18.0/
./configure
make

Lo instalé desde la fuente (lo cual no pude hacer antes de eliminar todo el material anterior), pero también debería ser posible usarlo apt-get install nginx.

información relacionada