Tulis monolog dahulu
Saya tidak menulis kod dalam PHP selama lebih daripada dua tahun, dan kini saya telah mengambilnya semula TP, tetapi kemas kini versi TP sangat tidak mesra, jadi kali ini saya menggunakan Laravel dalam satu langkah. Mari kita mulakan dengan persekitaran docker terlebih dahulu. Saya akan mencuba dan menulis semasa saya pergi. Saya juga berharap pengalaman newbie saya dapat membantu sesetengah orang.
[Disyorkan: Tutorial laravel]
Tutorial terperinci dalam forum
Saya mengikuti tutorial langkah demi langkah, tetapi operasi saya tidak berjalan lancar sehingga langkah keenam Situasi
ERROR: Service 'laravel.test' failed to build : Build failed
Saya melihat log dengan teliti dan ralat muncul dalam
#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.
Nampaknya terdapat masalah dengan banyak kebergantungan
#9 7.262 gnupg : Depends: gpgv (< 2.2.19-3ubuntu2.1.1~) but 2.2.20-1ubuntu3 is to be installed
Ia sepatutnya menjadi lebih tinggi Versi telah dipasang, jadi saya cuba menggantikan apt-get
dengan aptitude
Perbezaan dengan apt-get
ialah aptitude
lebih baik dalam mengendalikan isu pergantungan. Sebagai contoh, apabila kebolehan memadamkan pakej, ia juga akan memadamkan pakej yang bergantung padanya. Dengan cara ini, pakej yang tidak berguna tidak akan kekal dalam sistem, dan keseluruhan sistem akan menjadi lebih bersih.
Jadi saya melaraskan Dockerfile
RUN apt-get update \ && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
kepada
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 \
dan menjalankannya semula./vendor/bin/sail up
Keadaan menjadi berbeza masih melaporkan ralat
#9 32.31 E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation
Pemasangan tidak berjaya, saya baru sahaja melaksanakannya
Saya cuba lagiapt-get install -f
tetapi masih tiada kesan
Baiklah, mari kita lihat berbeza. , kerana versi yang lebih tinggi yang disebutkan telah dipasang, maka saya akan melakukannya berdasarkan ubuntu yang lebih tinggi, jadi saya mengubah suai FROM
daripada
FROM ubuntu:21.04
kepada
FROM ubuntu:latest
Baik , masalah pergantungan baru ada di sini
#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.
Selepas mencari, saya nampaknya telah menemui penyelesaian
Solve it with downgrade sail composer require laravel/sail:^1.7.0 php artisan sail:install and in ubuntu terminal sail up --build
Baiklah, teruskan mencuba, jalankan dahulu
composer require laravel/sail:^1.7.0
Saya mendapati ralat, tetapi saya terlupa ralat khusus.
Saya menyemak bahawa versi php ialah 7.x, jadi saya menggunakan brew install php
dan mendapati ralat
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
selepas menyemak bahawa saya tidak mempunyai kebenaran, jadi saya menggunakan 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.
Didapati bahawa sudo tidak disokong.
Jadisudo chown -R $(whoami) /usr/local/Cellar
tukar kebenaran direktori
jalankan seperti biasa
gunakan php -v
dan semak versi, ia masih 7.0
gunakan brew unlink php70
brew link php
sudo vim ~/.bash_profile
Lampirkan di hujung fail
PATH="$(brew --prefix php)/bin:$PATH"export PYTHON_ENV=development
php -v
php8.0 berjaya dipasang
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
Teruskan
composer require laravel/sail:^1.7.0
Tiada apa -apa yang saya dapati dan berfikir bahawa mungkin ada masalah dengan sumber komposer domestik
[InvalidArgumentException] Could not find package laravel/laravel with stability stable
Saya memasang imej komposer Cina. . Nanti saya tukar terus dan ganti dengan yang lain cukuplah
composer config -g repo.packagist composer https://packagist.org
Berjaya.
Langkah kedua
php artisan sail:install
telah berjaya.
Langkah 3
sail up
Berjaya. Selesaikan masalah.
Hos tempatan terakhir
Atas ialah kandungan terperinci Mari kita bincangkan tentang isu pembinaan belayar Mac Laravel docker. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!