如何在 htdocs 資料夾中建立 laravel 項目

如何在 htdocs 資料夾中建立 laravel 項目

我是網路開發人員。我已經在Windows作業系統中建立了項目,但現在我已經完全切換到Ubuntu 20.04。我已經安裝了 PHP 和composer.但是當我想在其中建立 Laravel 專案時,htdocs它會建立專案但vendor缺少資料夾。當我在資料夾composer update中的 CLI 中寫入時htdocs,它顯示以下錯誤:

1=>
Cannot create cache directory /home/saad/.cache/composer/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/saad/.cache/composer/files/, or directory is not writable. Proceeding without cache

2=>
PHP temp directory (/tmp) does not exist or is not writable to Composer. Set sys_temp_dir in your php.ini

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

然後顯示這些:

Problem 1
    - laravel/framework v7.25.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework v7.24.0 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - laravel/framework 7.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
    - Installation request for laravel/framework ^7.24 -> satisfiable by laravel/framework[7.x-dev, v7.24.0, v7.25.0].

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

您必須進入專案資料夾才能運行 Composer ...

例子:

cd path/to/htdocs/your-laravel-project-folder

然後運行

composer install

答案2

您的問題之一是composer沒有 的寫入權限/home/saad/.cache/composer/

另一個問題是您丟失了包裹php-mbstring。透過以下方式安裝:

sudo apt install php7.4-mbstring

相關內容