nginxをインストールしようとしたときにdpkgエラーが発生しました。

nginxをインストールしようとしたときにdpkgエラーが発生しました。

nginxをインストールしてみてください:

  1. 最初:

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

    結果:

    すべてが大丈夫に見えます。

    > ## 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. それから:

    sudo apt install -y nodejs nano nginx
    

    よさそうだが実行を要求した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. ランニング:

    apt --fix-broken install`
    

    無効:

    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)
    

次は何をすべきかわかりませんが、nginxがインストールされていないようです

ベストアンサー1

あなたはそれすらできないと言ったapt-get install nginx。私にもこの問題がありました。私の場合、既存のnginxインスタンスをすべて手動で削除するまで削除することはできませんでした。一日前にnginxをインストール(試行)したようですが、覚えておらず、インストールがかなり混乱しました。努力する

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

私がしたことは、すべてのrm -rfシンボリックリンクを強制的に削除し、見つけた既存のシンボリックリンクを削除することでした。その後、ついに述べたすべてのnginx関連パッケージを削除し、実際に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

ソースからインストールしましたが(以前の項目をすべて削除しないとそれはできませんでした)、うまくいきますapt-get install nginx

おすすめ記事