如何在ubuntu 16.04中安装laravel 5.6?

时间:2018-02-08 10:38:05

标签: linux laravel laravel-5 install ubuntu-16.04

我使用以下命令将PHP 7.0升级为7.1

1. sudo add-apt-repository ppa:ondrej/php
2. sudo apt-get update
3. sudo apt-get install php7.1

并从laravel.com运行此命令:

composer create-project --prefer-dist laravel/laravel blog

运行此代码后,出现以下错误:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- laravel/framework v5.6.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework 5.6.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- Installation request for laravel/framework 5.6.* -> satisfiable by laravel/framework[5.6.x-dev, v5.6.0].

To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.1/cli/php.ini
- /etc/php/7.1/cli/conf.d/10-opcache.ini
- /etc/php/7.1/cli/conf.d/10-pdo.ini
- /etc/php/7.1/cli/conf.d/20-calendar.ini
- /etc/php/7.1/cli/conf.d/20-ctype.ini
- /etc/php/7.1/cli/conf.d/20-exif.ini
- /etc/php/7.1/cli/conf.d/20-fileinfo.ini
- /etc/php/7.1/cli/conf.d/20-ftp.ini
- /etc/php/7.1/cli/conf.d/20-gettext.ini
- /etc/php/7.1/cli/conf.d/20-iconv.ini
- /etc/php/7.1/cli/conf.d/20-json.ini
- /etc/php/7.1/cli/conf.d/20-phar.ini
- /etc/php/7.1/cli/conf.d/20-posix.ini
- /etc/php/7.1/cli/conf.d/20-readline.ini
- /etc/php/7.1/cli/conf.d/20-shmop.ini
- /etc/php/7.1/cli/conf.d/20-sockets.ini
- /etc/php/7.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.1/cli/conf.d/20-sysvsem.ini
- /etc/php/7.1/cli/conf.d/20-sysvshm.ini
- /etc/php/7.1/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.

更新1:

我运行此命令:     sudo apt-get install php7.1-mbstring     sudo apt-get install libapache2-mod-php7.1

afetr run composer create-project --prefer-dist laravel/laravel blog命令,显示错误:

Failed to decode response: zlib_decode(): data error
Retrying with degraded mode, check    https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info


[Composer\Downloader\TransportException]                                                                                                     
Your configuration does not allow connection to http://packagist.org. See https://getcomposer.org/doc/06-config.md#secure-http for details. 

如何解决此错误?

3 个答案:

答案 0 :(得分:5)

你需要,

安装mbstring

sudo apt-get install php7.1-mbstring
sudo apt-get install libapache2-mod-php7.1

然后,

重新启动服务器:

sudo service apache2 restart
or
sudo service nginx restart

要使用composer解决错误,请运行:

sudo composer self-update

sudo composer clear-cache

sudo composer config -g secure-http false

答案 1 :(得分:0)

按照以下步骤安装laravel:

安装作曲家

curl -sS https://getcomposer.org/installer | php
  
sudo mv composer.phar /usr/local/bin/composer
  
sudo chmod +x /usr/local/bin/composer

安装后,在终端上键入composer时,您将获得 composer

Laravel基本要求:

如果您不使用Homestead,则需要确保您的服务器满足以下要求:

  • PHP> = 7.3
  • BCMath PHP扩展
  • Ctype PHP扩展
  • Fileinfo PHP扩展
  • JSON PHP扩展
  • Mbstring PHP扩展sudo apt-get install php-mbstring
  • OpenSSL PHP扩展
  • PDO PHP扩展
  • Tokenizer PHP扩展
  • XML PHP扩展sudo apt-get install php-xml

安装Laravel

composer create-project --prefer-dist laravel/laravel project-name

在安装laravel之后,像下面这样向您的storage, bootstrap文件夹分配权限:

sudo chmod  -R 777 storage  

sudo chmod  -R 777 bootstrap

现在,您可以使用serve命令运行项目了:

 php artisan serve

查看详细的文档检查laravel-installation

答案 2 :(得分:-1)

sudo apt-get install php libapache2-mod-php php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-mysql php-cli php-mcrypt

这将安装Laravel所需的所有php扩展。