当前位置: 首页>>技术教程>>正文


在 Ubuntu 16.04 上安装 laravel 5

, , ,

问题描述

有人在 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.

我读过文章 Here one of them 说 Ubuntu 16.04 默认带有 PHP7,但我们仍然可以使用 PHP5。但是我尝试了 PHP7 和PHP5,仍然得到同样的错误!有任何想法吗?谢谢

最佳方案

如何在 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

LAMP

sudo apt-get install tasksel
sudo tasksel install lamp-server

CURL

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

Composer

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

次佳方案

我已将 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 corrupted

第三种方案

这些是我在全新升级后在 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 7.0 版后,我安装了 Mohhammad 推荐的其他相关软件包:

  • sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext php-gd

并启用了模组

  • sudo phpenmod mcrypt

  • sudo phpenmod mbstring 最后,毕竟这个作曲家仍然在抱怨它没有 composer update 的 zip 扩展名,所以我安装了以下内容:

  • sudo apt-get install php7.0-zip

之后它运行得很好,没有错误!

这些是我从以前的 LTS 版本的 Ubuntu Server 获得 laravel 5 运行所需的步骤。希望这有帮助!此致 :)

-德里克

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/12814.html,未经允许,请勿转载。