在Ubuntu中创建Laravel应用程序时出错

时间:2017-08-09 03:46:57

标签: php laravel ubuntu

我正在使用Ubuntu 17.04。我试图访问和/etc/php/7.0/cli和编辑php.ini文件。但无论如何都没有帮助。如何启用以下扩展程序。

<form method="POST" action="{% url 'content' %}">


执行服务命令时也出现错误

ninja@ninja:~/Documents/lartest$ laravel new demo

    Crafting application...
    Cannot create cache directory /home/ninja/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
    Cannot create cache directory /home/ninja/.composer/cache/files/, or directory is not writable. Proceeding without cache
    Cannot create cache directory /home/ninja/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Your requirements could not be resolved to an installable set of packages.

      Problem 1
        - Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8].
        - phpunit/php-code-coverage 4.0.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
      Problem 2
        - Installation request for phpunit/phpunit 5.7.21 -> satisfiable by phpunit/phpunit[5.7.21].
        - phpunit/phpunit 5.7.21 requires ext-dom * -> the requested PHP extension dom is missing from your system.

      To enable extensions, verify that they are enabled in your .ini files:
        - /etc/php/7.0/cli/php.ini
        - /etc/php/7.0/cli/conf.d/10-opcache.ini
        - /etc/php/7.0/cli/conf.d/10-pdo.ini
        - /etc/php/7.0/cli/conf.d/20-calendar.ini
        - /etc/php/7.0/cli/conf.d/20-ctype.ini
        - /etc/php/7.0/cli/conf.d/20-curl.ini
        - /etc/php/7.0/cli/conf.d/20-exif.ini
        - /etc/php/7.0/cli/conf.d/20-fileinfo.ini
        - /etc/php/7.0/cli/conf.d/20-ftp.ini
        - /etc/php/7.0/cli/conf.d/20-gettext.ini
        - /etc/php/7.0/cli/conf.d/20-iconv.ini
        - /etc/php/7.0/cli/conf.d/20-json.ini
        - /etc/php/7.0/cli/conf.d/20-mbstring.ini
        - /etc/php/7.0/cli/conf.d/20-phar.ini
        - /etc/php/7.0/cli/conf.d/20-posix.ini
        - /etc/php/7.0/cli/conf.d/20-readline.ini
        - /etc/php/7.0/cli/conf.d/20-shmop.ini
        - /etc/php/7.0/cli/conf.d/20-sockets.ini
        - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
        - /etc/php/7.0/cli/conf.d/20-sysvsem.ini
        - /etc/php/7.0/cli/conf.d/20-sysvshm.ini
        - /etc/php/7.0/cli/conf.d/20-tokenizer.ini
        - /etc/php/7.0/cli/conf.d/20-zip.ini
      You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
    Application ready! Build something amazing.

3 个答案:

答案 0 :(得分:1)

假设您已成功安装php7.0-cli。

现在在终端中运行以下命令:

sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-xml

然后尝试再次安装Laravel。

如果您仍然遇到任何问题,请告诉我。

答案 1 :(得分:0)

首先为php扩展安装ext-dom,然后再次运行compser update

答案 2 :(得分:0)

在安装laravel之前,您可以先完成Laravel所需的依赖项。有关依赖项信息,请参阅here

我可以这样做:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

这里我使用PHP 7.1

sudo apt-get install php7.1

如果您想使用其他版本,请自行更改。

PHP安装完成后,可以继续安装所需的扩展名。

sudo apt-get install php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-xml php7.1-gd

上面的扩展应该可以顺利安装laravel。您也可以使用上面的一个或多个扩展名,例如:

sudo apt-get install php7.1-mbstring php7.1-xml

然后重新启动服务器。

希望有用。