0

Trying to install nginx:

  1. First:

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

    Result:

    Looks everything okay:

    > ## 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. Then:

    sudo apt install -y nodejs nano nginx
    

    Looks okay but asked to run 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. Run:

    apt --fix-broken install`
    

    There are errors:

    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)
    

I don't know what to next, but looks nginx is not installed

3
  • 2
    Why didn't you just apt install nginx? Oct 30, 2021 at 17:53
  • The same result on step 2
    – Mediator
    Oct 31, 2021 at 10:11
  • I mean before you did all of that. There was no reason to add those repos nor is there any need for nodejs. nginx is in Ubuntu's repos so all you had to do from the start was to apt install nginx. You can start by removing the needless Yarn repository. Oct 31, 2021 at 12:06

1 Answer 1

0

You said you were not able to even do apt-get install nginx. I had that problem too and, in my case, I wasn't able to even uninstall until I manually removed all the existing instances of nginx. It seems like I had previously (tried to) install nginx some day and I didn't remember and my installation was a mess. Try

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

What I did was force remove all those with rm -rf and then remove the existing symbolic links I found. After that, I was finally able to uninstall all the nginx-related packages you mentioned and actually re-install 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

I installed from source (which I couldn't do before removing all the previous stuff) but it should be possible to use apt-get install nginx too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .