有人在 Ubuntu 16.04 上安裝了 laravel 5 嗎?我剛剛切換到 Ubuntu 16.04,我正在嘗試使用 Composer 在其上安裝 laravel 5 框架。但每次我嘗試建立一個專案時都會出現這個錯誤
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/laravel v5.2.0 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.15 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.23 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.24 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.27 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.29 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/laravel v5.2.31 requires laravel/framework 5.2.* -> satisfiable by laravel/framework[v5.2.0, v5.2.1, v5.2.10, v5.2.11, v5.2.12, v5.2.13, v5.2.14, v5.2.15, v5.2.16, v5.2.17, v5.2.18, v5.2.19, v5.2.2, v5.2.20, v5.2.21, v5.2.22, v5.2.23, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.29, v5.2.3, v5.2.30, v5.2.31, v5.2.4, v5.2.5, v5.2.6, v5.2.7, v5.2.8, v5.2.9].
- laravel/framework v5.2.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.31 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.30 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.29 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.27 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.26 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.25 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.24 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.23 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.22 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.21 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.20 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.19 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.18 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.17 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.16 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.15 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.14 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.13 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.12 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.11 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.10 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.2.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- Installation request for laravel/laravel ^5.2 -> satisfiable by laravel/laravel[v5.2.0, v5.2.15, v5.2.23, v5.2.24, v5.2.27, v5.2.29, v5.2.31].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/5.6/cli/php.ini
- /etc/php/5.6/cli/conf.d/10-opcache.ini
- /etc/php/5.6/cli/conf.d/10-pdo.ini
- /etc/php/5.6/cli/conf.d/20-calendar.ini
- /etc/php/5.6/cli/conf.d/20-ctype.ini
- /etc/php/5.6/cli/conf.d/20-exif.ini
- /etc/php/5.6/cli/conf.d/20-fileinfo.ini
- /etc/php/5.6/cli/conf.d/20-ftp.ini
- /etc/php/5.6/cli/conf.d/20-gettext.ini
- /etc/php/5.6/cli/conf.d/20-iconv.ini
- /etc/php/5.6/cli/conf.d/20-json.ini
- /etc/php/5.6/cli/conf.d/20-phar.ini
- /etc/php/5.6/cli/conf.d/20-posix.ini
- /etc/php/5.6/cli/conf.d/20-readline.ini
- /etc/php/5.6/cli/conf.d/20-shmop.ini
- /etc/php/5.6/cli/conf.d/20-sockets.ini
- /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
- /etc/php/5.6/cli/conf.d/20-sysvsem.ini
- /etc/php/5.6/cli/conf.d/20-sysvshm.ini
- /etc/php/5.6/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, deleting ./composer.json.
我讀過文章這是其中之一假設 Ubuntu 16.04 預設使用 PHP7,但我們仍然可以使用 PHP5。但我嘗試了 PHP7 和 PHP5,仍然遇到相同的錯誤!有任何想法嗎?謝謝
答案1
如何在 Ubuntu 16.04 中安裝 Laravel
更新:Laravel 5.4
由於對這個問題非常感興趣,我決定更新它並創建一個小的 bash 腳本來安裝使用 Laravel 所需的一切(這是與 NGINX 一起使用的)
https://github.com/emilas44/laravel-5.4-on-Ubuntu/blob/master/script.sh
您可以簡單地複製它並根據需要進行編輯...也許您已經安裝了腳本內的一些組件,如果是這樣,您可以隨意刪除不需要的部分。
Laravel 5.2 如下:
基本的東西安裝(可選)
sudo apt-get install git
sudo apt-get install zip
燈
sudo apt-get install tasksel
sudo tasksel install lamp-server
捲曲
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext
啟用模組
sudo phpenmod mcrypt
sudo phpenmod mbstring
sudo a2enmod rewrite
sudo systemctl restart apache2
作曲家
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
安裝 phpmyadmin
sudo apt-get install phpmyadmin
稍後可以透過 localhost/phpmyadmin 訪問
創建 Laravel 項目
cd /var/www/html/
sudo composer create-project laravel/laravel work --prefer-dist
sudo chmod -R 777 work (do not set 777 on "live" server!)
建立虛擬主機 work.com
sudo gedit /etc/apache2/sites-available/work.com.conf
並將其貼到該文件中
#/etc/apache2/sites-available/work.com.conf contains following lines
<VirtualHost *:80>
ServerName work.com
DocumentRoot /var/www/html/work/public
<Directory /var/www/html/work/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
啟用該網站
sudo a2ensite work.com
service apache2 reload
修復主機文件,以便您可以透過網頁瀏覽器存取它
sudo gedit /etc/hosts //space between gedit and destination!
#/etc/hosts contents following lines
127.0.0.1 work.com
或使用此命令
sudo -- sh -c "echo '\n127.0.0.1 \twork.com'>> /etc/hosts"
這樣 Laravel 就安裝好了!
我在 youtube 上製作了一個如何正確使用的教學...包含使用 laravel 所需的所有內容。連結在這裡: https://www.youtube.com/watch?v=A6TdaRIsG6g
答案2
我已將 php 5.6.11 升級到 5.6.21。
所以,就我而言,我必須運行:
sudo apt-get install php5.6-mbstring
PS:我如何從 5.6.11 升級到 5.6.21 如下:
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
升級原因:zend_mm_heap 損壞在作曲家更新期間。
答案3
這些是我在全新升級後在 Ubuntu Server 16.04 上安裝 Laravel 5 所必須採取的步驟
首先,我必須完全刪除所有 PHP,正如 Mohammad Barhoush 所說:
sudo apt-get -y purge php.*
然後我重新安裝了 PHP:
sudo apt install php libapache2-mod-php
sudo apt install php-cli
sudo apt install php-mysql
重新安裝 PHP ver.7.0 後,我安裝了 Mohhammad 推薦的其他相關軟體包:
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext php-gd
並啟用模組
sudo phpenmod mcrypt
sudo phpenmod mbstring
最後,畢竟這位作曲家仍然很痛苦地抱怨它沒有 a 的 zip 副檔名,所以
composer update
我安裝了以下內容:sudo apt-get install php7.0-zip
之後就正常運作了,沒有任何錯誤!
這些是我從先前的 LTS 版本的 Ubuntu Server 中取得 laravel 5 功能所需的步驟。希望有幫助!此致 :)
-德瑞克
答案4
oerdnj 的解決方案有效,安裝後您應該在before runmbstring
中啟用它。就我而言,laravel 需要 ext-mbstring 和 ext-dom:php.ini
composer install
apt-get install php-dom