首頁 php框架 Laravel 聊聊關於Mac Laravel docker sail 搭建問題

聊聊關於Mac Laravel docker sail 搭建問題

Nov 16, 2021 pm 02:47 PM
laravel

先寫段落獨白

兩年多沒用php寫過程式碼了,現在從新撿起來,以前用tp,但tp的版本更新很不友好,所以這次一步到位用Laravel。先docker環境開始吧,我會一邊嘗試一邊寫,也歡迎大家跟我互動,多教我一些東西。我也希望我的新手經驗可以幫助到一些人。

【推薦:laravel教學

#一.docker Desktop安裝

論壇裡詳細教學

##二. 運行容器(遇到「坑」了!)

我就是按照教程一步一步操作的,直到第六步我的運行並沒有很順利,出現了以下情況

ERROR: Service 'laravel.test' failed to build : Build failed
登入後複製
我在仔細看了一下日誌,錯誤出現在

#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
登入後複製

應該是更高的版本被安裝了,於是我嘗試替換apt-get使用
aptitude

apt-get
# 不同的是,aptitude 在處理依賴問題上更佳一些。舉例來說,aptitude 在刪除一個套件時,會同時刪除本身所依賴的套件。這樣,系統中不會殘留無用的包,整個系統更為乾淨。

於是我調整了一下Dockerfile<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">RUN apt-get update \ &amp;&amp; apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \</pre><div class="contentsignin">登入後複製</div></div>變成了

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 \
登入後複製

再次運行

./vendor/bin/sail up







# #情況變得不同了,但依然報了錯誤

#9 32.31 E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
登入後複製
並沒有安裝成功,只是執行了過去又嘗試了
apt-get install -f但依然沒什麼效果
好吧,換個思路觀察了一下,既然說的更高版本已經安裝,那我就基於更高的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.
登入後複製

搜尋了一下,似乎找到了一個解決方案
 Solve it with downgrade sail
 composer require laravel/sail:^1.7.0
 php artisan sail:install
 and in ubuntu terminal
 sail up --build
登入後複製

好,繼續嘗試,先執行

composer require laravel/sail:^1.7.0
登入後複製
登入後複製

發現報錯,具體錯誤忘記了。

我看了一下php版本是7.x於是使用

brew install php

發現報錯

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
登入後複製
看了一下是沒權限,使用

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.
登入後複製

發現sudo不支援。
於是
sudo chown -R $(whoami) /usr/local/CellarLaravel docker sail 搭建改變目錄權限

正常運作###使用###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
登入後複製
###繼續###
composer require laravel/sail:^1.7.0
登入後複製
登入後複製
###發現沒有找到,想到可能是國內composer來源有問題###
[InvalidArgumentException] Could not find package laravel/laravel with stability stable
登入後複製
###我是安裝了composer 的中國鏡像,其實就是composer 的中國鏡像出了問題,後來我直接把他改了,換成另外一個地址就行了###
composer config -g repo.packagist composer https://packagist.org
登入後複製
# ##成功。 ###第二步###
php artisan sail:install
登入後複製
###成功。 ###第三步###
sail up
登入後複製
###成功。解決問題。 ###最後localhost##########

以上是聊聊關於Mac Laravel docker sail 搭建問題的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

在Laravel中如何獲取郵件發送失敗時的退信代碼? 在Laravel中如何獲取郵件發送失敗時的退信代碼? Apr 01, 2025 pm 02:45 PM

Laravel郵件發送失敗時的退信代碼獲取方法在使用Laravel開發應用時,經常會遇到需要發送驗證碼的情況。而在實�...

在 Laravel 中,如何處理郵件發送驗證碼失敗的情況? 在 Laravel 中,如何處理郵件發送驗證碼失敗的情況? Mar 31, 2025 pm 11:48 PM

Laravel郵件發送驗證碼失敗時的處理方法在使用Laravel...

在dcat admin中如何實現點擊添加數據的自定義表格功能? 在dcat admin中如何實現點擊添加數據的自定義表格功能? Apr 01, 2025 am 07:09 AM

在dcatadmin(laravel-admin)中如何實現自定義點擊添加數據的表格功能在使用dcat...

Laravel Redis連接共享:為何select方法會影響其他連接? Laravel Redis連接共享:為何select方法會影響其他連接? Apr 01, 2025 am 07:45 AM

Laravel框架中Redis連接的共享與select方法的影響在使用Laravel框架和Redis時,開發者可能會遇到一個問題:通過配置...

Laravel多租戶擴展stancl/tenancy:如何自定義租戶數據庫連接的主機地址? Laravel多租戶擴展stancl/tenancy:如何自定義租戶數據庫連接的主機地址? Apr 01, 2025 am 09:09 AM

在Laravel多租戶擴展包stancl/tenancy中自定義租戶數據庫連接使用Laravel多租戶擴展包stancl/tenancy構建多租戶應用時,...

Bangla 部分模型檢索中的 Laravel Eloquent ORM) Bangla 部分模型檢索中的 Laravel Eloquent ORM) Apr 08, 2025 pm 02:06 PM

LaravelEloquent模型檢索:輕鬆獲取數據庫數據EloquentORM提供了簡潔易懂的方式來操作數據庫。本文將詳細介紹各種Eloquent模型檢索技巧,助您高效地從數據庫中獲取數據。 1.獲取所有記錄使用all()方法可以獲取數據庫表中的所有記錄:useApp\Models\Post;$posts=Post::all();這將返回一個集合(Collection)。您可以使用foreach循環或其他集合方法訪問數據:foreach($postsas$post){echo$post->

在Laravel6項目中如何有效檢查Redis連接的有效性? 在Laravel6項目中如何有效檢查Redis連接的有效性? Apr 01, 2025 pm 02:00 PM

在Laravel6項目中如何檢查Redis連接的有效性是一個常見的問題,特別是在項目依賴於Redis進行業務處理時。以下是...

Laravel數據庫遷移遇到類重複定義:如何解決遷移文件重複生成及類名衝突? Laravel數據庫遷移遇到類重複定義:如何解決遷移文件重複生成及類名衝突? Apr 01, 2025 pm 12:21 PM

Laravel數據庫遷移過程中出現類重複定義問題在使用Laravel框架進行數據庫遷移時,開發者可能會遇到“類已使用�...

See all articles