本篇內(nèi)容介紹了“怎么搭建Mac Laravel docker sail”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
成都創(chuàng)新互聯(lián)堅(jiān)實(shí)的技術(shù)研發(fā)基礎(chǔ)贏得了行業(yè)內(nèi)的良好口碑,公司成立10余年來,為上千家企業(yè)提供過網(wǎng)站建設(shè)、軟件開發(fā)、搜索引擎優(yōu)化技術(shù)、互聯(lián)網(wǎng)大數(shù)據(jù)整合營(yíng)銷服務(wù),多年的技術(shù)服務(wù)成功經(jīng)驗(yàn)、眾多的客戶使我們能懂得更多,做得更好。"讓您的網(wǎng)站跑起來"是我們一直追求的目標(biāo)!
論壇里詳細(xì)教程
我就是按照教程一步一步操作的,直到第六步我的運(yùn)行并沒有很順利,出現(xiàn)了以下情況
ERROR: Service 'laravel.test' failed to build : Build failed
我在仔細(xì)看了一下日志,錯(cuò)誤出現(xiàn)在
#9 7.166 Some packages could not be installed. This may mean that you have #9 7.166 requested an impossible situation or if you are using the unstable #9 7.166 distribution that some required packages have not yet been created #9 7.166 or been moved out of Incoming.#9 7.166 The following information may help to resolve the situation:#9 7.166#9 7.166 The following packages have unmet dependencies:#9 7.262 gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed #9 7.264 perl : Depends: perl-base (= 5.30.0-9ubuntu0.2) but 5.32.1-3ubuntu2.1 is to be installed #9 7.264 Recommends: netbase but it is not going to be installed #9 7.264 perl-base : Breaks: perl (< 5.32.1~) but 5.30.0-9ubuntu0.2 is to be installed #9 7.265 zlib1g-dev : Depends: zlib1g (= 1:1.2.11.dfsg-2ubuntu1.2) but 1:1.2.11.dfsg-2ubuntu6 is to be installed #9 7.265 Depends: libc6-dev but it is not going to be installed or #9 7.265 libc-dev #9 7.283 E: Unable to correct problems, you have held broken packages.
有很多依賴貌似有問題
#9 7.262 gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed
應(yīng)該是更高的版本被安裝了,于是我嘗試替換apt-get
使用aptitude
與 apt-get
不同的是,aptitude
在處理依賴問題上更佳一些。舉例來說,aptitude 在刪除一個(gè)包時(shí),會(huì)同時(shí)刪除本身所依賴的包。這樣,系統(tǒng)中不會(huì)殘留無用的包,整個(gè)系統(tǒng)更為干凈。
于是我調(diào)整了一下Dockerfile
RUN apt-get update \ && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
變成了
RUN apt-get update \ && apt-get install -y aptitude \ && aptitude install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
再次運(yùn)行./vendor/bin/sail up
情況變得不同了,但依然報(bào)了錯(cuò)誤
#9 32.31 E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
并沒有安裝成功,只是執(zhí)行了過去
又嘗試了apt-get install -f
但依然沒什么效果
好吧,換個(gè)思路觀察了一下,既然說的更高版本已經(jīng)安裝,那我就基于更高的ubuntu去做,于是我修改了FROM
,從
FROM ubuntu:21.04
改到了
FROM ubuntu:latest
好吧,新的依賴問題來了
#9 44.96 Some packages could not be installed. This may mean that you have #9 44.96 requested an impossible situation or if you are using the unstable #9 44.96 distribution that some required packages have not yet been created #9 44.96 or been moved out of Incoming.#9 44.96 The following information may help to resolve the situation:#9 44.96#9 44.96 The following packages have unmet dependencies:#9 45.08 php8.0-bcmath : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-cli : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Depends: php8.0-opcache but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 Depends: libxml2 (>= 2.8.0) but it is not going to be installed #9 45.08 php8.0-curl : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-dev : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Recommends: pkg-php-tools but it is not going to be installed #9 45.08 php8.0-gd : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-igbinary : Depends: php8.0-common but it is not going to be installed #9 45.08 php8.0-imap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-intl : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Depends: libicu67 (>= 67.1-1~) but it is not installable #9 45.08 php8.0-ldap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-mbstring : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-memcached : Depends: php8.0-common but it is not going to be installed #9 45.08 php8.0-msgpack : Depends: php8.0-common but it is not going to be installed #9 45.08 php8.0-MySQL : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-pcov : Depends: php8.0-common but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 php8.0-pgsql : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-readline : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-redis : Depends: php8.0-common but it is not going to be installed #9 45.08 php8.0-soap : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 Depends: libxml2 (>= 2.7.4) but it is not going to be installed #9 45.08 php8.0-sqlite3 : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 php8.0-swoole : Depends: php8.0-common but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 php8.0-xdebug : Depends: php8.0-common but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 php8.0-xml : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 Depends: libxml2 (>= 2.9.0) but it is not going to be installed #9 45.08 Depends: libxslt1.1 (>= 1.1.25) but it is not going to be installed #9 45.08 php8.0-zip : Depends: php8.0-common (= 8.0.12-1+ubuntu21.04.1+deb.sury.org+1) but it is not going to be installed #9 45.08 Depends: libc6 (>= 2.33) but 2.31-0ubuntu9.2 is to be installed #9 45.08 Depends: libzip4 (>= 1.7.0) but it is not installable #9 45.10 E: Unable to correct problems, you have held broken packages.
搜索了一下,貌似找到了一個(gè)解決方案
Solve it with downgrade sail composer require laravel/sail:^1.7.0 php artisan sail:install and in ubuntu terminal sail up --build
好,繼續(xù)嘗試,首先運(yùn)行
composer require laravel/sail:^1.7.0
發(fā)現(xiàn)報(bào)錯(cuò),具體錯(cuò)誤忘記了。
我看了一下php版本是7.x于是使用brew install php
發(fā)現(xiàn)報(bào)錯(cuò)
Error: Failure while executing; `cp -pR /var/folders/vq/934y4t116875gz570v8drdcm0000gn/T/d20211115-17671-1n3qf1o/openssl@1.1/. /usr/local/Cellar/openssl@1.1` exited with 1. Here's the output:cp: utimes: /usr/local/Cellar/openssl@1.1/.: Operation not permitted cp: chmod: /usr/local/Cellar/openssl@1.1/.: Operation not permitted
看了一下是沒權(quán)限,使用sudo brew install php
Error: Running Homebrew as root is extremely dangerous and no longer supported.As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.
發(fā)現(xiàn)sudo不支持。
于是sudo chown -R $(whoami) /usr/local/Cellar
改變目錄權(quán)限
正常運(yùn)行
使用php -v
看了一下版本,還是7.0
使用brew unlink php70
brew link php
sudo vim ~/.bash_profile
在文件末尾追加
PATH="$(brew --prefix php)/bin:$PATH"export PYTHON_ENV=development
php -v
php8.0安裝成功
PHP 8.0.12 (cli) (built: Oct 21 2021 14:49:05) ( NTS )Copyright (c) The PHP Group Zend Engine v4.0.12, Copyright (c) Zend Technologies
繼續(xù)
composer require laravel/sail:^1.7.0
發(fā)現(xiàn)沒有沒有找到,想到可能是國(guó)內(nèi)composer源有問題
[InvalidArgumentException] Could not find package laravel/laravel with stability stable
我是安裝了composer 的中國(guó)鏡像,其實(shí)就是composer 的中國(guó)鏡像出了問題,后來我直接把他改了,換成另外一個(gè)地址就行了
composer config -g repo.packagist composer https://packagist.org
成功。
第二步
php artisan sail:install
成功。
第三步
sail up
“怎么搭建Mac Laravel docker sail”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!