【问题标题】:Getting Errors while creating Laravel Application in Ubuntu在 Ubuntu 中创建 Laravel 应用程序时出现错误
【发布时间】:2017-08-09 03:46:57
【问题描述】:

我使用的是 Ubuntu 17.04。我试图访问和 /etc/php/7.0/cli 并编辑了 php.ini 文件。但无论如何也没有帮助。如何启用以下这些扩展。

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.


执行服务命令时也出错
ninja@ninja:~/Documents/lartest/demo$ php artisan serve
PHP Warning:  require(/home/ninja/Documents/lartest/demo/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/ninja/Documents/lartest/demo/bootstrap/autoload.php on line 17
PHP Fatal error:  require(): Failed opening required '/home/ninja/Documents/lartest/demo/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/ninja/Documents/lartest/demo/bootstrap/autoload.php on line 17

【问题讨论】:

标签: php laravel ubuntu


【解决方案1】:

假设你已经成功安装了php7.0-cli。

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

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

然后尝试再次安装 Laravel。

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

【讨论】:

  • 在执行 php artisan serve pastebin.com/ZwEuXxTV时仍然面临错误
  • 运行这个命令:composer install 然后 php artisan serve
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    在安装 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
    

    然后重启你的服务器。

    希望有用。

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多