在Ubuntu 16.04上安装laravel 5


21

有人在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,仍然收到相同的错误!有任何想法吗?谢谢

Answers:


30

如何在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上制作了一个教程,说明如何正确设置...。这是链接:https : //www.youtube.com/watch?v=A6TdaRIsG6g


例如,如果我不想以sudo身份运行composer,该怎么办?有警告说不要在作曲​​家中使用sudo。
m33bo 2016年

您需要以用户身份创建目录并安装laravel和composer而不使用sudo
lewis4u 2016年

甜。在我的机器上运行
Semo

对不起,chmod 77 5还不够吗?
Semo

1
存储和引导文件夹需要为777
lewis4u

3

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

并启用了mod

  • sudo phpenmod mcrypt
  • sudo phpenmod mbstring

    最后,毕竟这个作曲家仍然很痛苦地抱怨它没有zip扩展名,composer update因此我安装了以下代码:

  • sudo apt-get install php7.0-zip

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

这些是我要使laravel 5能够从Ubuntu Server的先前LTS版本运行的步骤。希望这对您有所帮助!最好的祝福 :)

-德里克



1

oerdnj的解决方案有效,安装后mbstringphp.ini在运行之前启用它composer install。在我的情况下,laravel需要ext-mbstring和ext-dom:
apt-get install php-dom


但他没有告诉如何将其添加到php.ini中:(
Juliatzin del Toro,2016年

1

谢谢大家的答复。我终于可以通过执行以下操作来解决此问题:

  • 首先完全删除php:

    sudo apt-get -y purge php.*

  • 重新安装php和这些重要的相关软件包:

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

  • 启用mod(感谢lewis4u视频):

    sudo phpenmod mcrypt

    sudo phpenmod mbstring


1

在那里,您需要在配置文件中手动进行操作。.我发现本文确实很有帮助。首先,需要使用'phpinfo()'函数检查系统中是否已经安装了天气mbstring.dll库。如果启用了它,而不是取消注释“ extension = php_mbstring.dll”,只需将其保留在php.ini配置文件中即可,否则,请通过以下方式安装该文件: sudo apt-get install php-mbstring php7.0-mbstring

然后只需配置以下内容。

; mbstring.language = All
;mbstring.internal_encoding = UTF-8
;mbstring.http_output = UTF-8
;mbstring.encoding_translation = On
;mbstring.func_overload = 0

就是这样..我想您知道其余的事情,例如如何安装laravel等等。


1

所以我和上面的那个家伙有同样的问题,我需要安装php-dom,所以我尝试运行,apt-get install php-dom但是它只是出现了消息

Package php-dom is a virtual package provided by:
php5.5-xml 5.5.35-1+donate.sury.org~xenial+2
php7.0-xml 7.0.6-1+donate.sury.org~xenial+1
php5.6-xml 5.6.21-1+donate.sury.org~xenial+2
You should explicitly select one to install.

作为终端的新手,我发现这有点令人困惑,但是我使用php7运行Ubuntu 16.04,所以我就运行了:apt-get install php7.0-xml这对我有用...希望对某人有帮助!


0

如要在Laravel文档中进行安装Laravel 5.4Ubuntu 16.04进行检查:

  1. 在终端检查您的PHP版本: php -v,您的php版本必须为PHP >= 5.6.4
  2. 检查终端用php -mOpenSSL PHP ExtensionPDO PHP Extension
  3. 终端:sudo apt install php-mbstring 通过再次检查php -mMbstring PHP ExtensionTokenizer PHP Extension

  4. 终端:sudo apt install php-xml通过再次检查php -mXML PHP Extension

  5. 在终端中按以下4个步骤下载Composer:

    • php -r“ copy(' https://getcomposer.org/installer','composer-setup.php ');”

    • php -r“ if(hash_file('SHA384','composer-setup.php')==='669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410'){回声'安装程序已验证'( php');}回显PHP_EOL;“

    • php composer-setup.php

    • php -r“ unlink('composer-setup.php');”

  6. 在终端中检查作曲家: php composer.phar

  7. 在终端中安装Laravel:

    php composer.phar global require "laravel/installer"
    终端中的输出将显示您的当前目录/home/yourname/.config/composer ,转到当前目录,然后按ctrl+h显示隐藏的文件。
    转到.config文件夹,然后转到composer包含以下内容的文件夹composer文件夹内容

  8. 创建Laravel project/var/www/html在终端:

    php composer.phar create-project --prefer-dist laravel/laravel /var/www/html/myLaravel

  9. 在终端中打开myLaravel,然后粘贴:php artisan servehttp://127.0.0.1:8000在浏览器中复制

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.