嘗試安裝 nginx:
第一的:
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
然後:
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).
跑步:
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
也可以使用。