我需要部署一个用 Laravel 和 vue.js 编写的 Web 应用程序。服务器在 AWS 上,使用 ubuntu 18.04。最初,开发是在装有 Xampp v7.4.10、控制面板 v3.2.4 和 PHP v7.4.10 的 Windows 机器上进行的。后来,我在装有相同版本的 Xampp 和 PHP v7.4.28 的 macOs 机器上进行了开发。我发现服务器上装有 PHP v7.3.18,当我尝试运行命令时
composer install
给了我这个错误:
Cannot create cache directory /home/ubuntu/.composer/cache/repo/https---packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/ubuntu/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for psr/container 1.1.2 -> satisfiable by psr/container[1.1.2].
- psr/container 1.1.2 requires php >=7.4.0 -> your PHP version (7.3.18) does not satisfy that requirement.
Problem 2
- psr/container 1.1.2 requires php >=7.4.0 -> your PHP version (7.3.18) does not satisfy that requirement.
- symfony/service-contracts v2.5.0 requires psr/container ^1.1 -> satisfiable by psr/container[1.1.2].
- Installation request for symfony/service-contracts v2.5.0 -> satisfiable by symfony/service-contracts[v2.5.0].
我使用以下 shell 命令安装并启用了 PHP v7.4:
sudo apt install php7.4
sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
sudo a2dismod php7.3
sudo a2enmod php7.4
sudo systemctl restart apache2
sudo update-alternatives --set php /usr/bin/php7.4
但现在它给了我这个错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'gd2' (tried: /usr/lib/php/20190902/gd2 (/usr/lib/php/20190902/gd2: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/gd2.so (/usr/lib/php/20190902/gd2.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib/php/20190902/mysqli (/usr/lib/php/20190902/mysqli: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/mysqli.so (/usr/lib/php/20190902/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20190902/pdo_mysql (/usr/lib/php/20190902/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib/php/20190902/pdo_sqlite (/usr/lib/php/20190902/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_sqlite.so (/usr/lib/php/20190902/pdo_sqlite.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: Module 'bz2' already loaded in Unknown on line 0
PHP Warning: Module 'curl' already loaded in Unknown on line 0
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: pdo_parse_params), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
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 nikic/php-parser v4.13.2 -> satisfiable by nikic/php-parser[v4.13.2].
- nikic/php-parser v4.13.2 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 2
- Installation request for psy/psysh v0.11.1 -> satisfiable by psy/psysh[v0.11.1].
- psy/psysh v0.11.1 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 3
- Installation request for tijsverkoyen/css-to-inline-styles 2.2.4 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.4].
- tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 4
- Installation request for phar-io/manifest 2.0.3 -> satisfiable by phar-io/manifest[2.0.3].
- phar-io/manifest 2.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 5
- Installation request for php-parallel-lint/php-console-highlighter v0.5 -> satisfiable by php-parallel-lint/php-console-highlighter[v0.5].
- php-parallel-lint/php-console-highlighter v0.5 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 6
- Installation request for phpunit/php-code-coverage 7.0.15 -> satisfiable by phpunit/php-code-coverage[7.0.15].
- phpunit/php-code-coverage 7.0.15 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 7
- Installation request for phpunit/php-token-stream 4.0.4 -> satisfiable by phpunit/php-token-stream[4.0.4].
- phpunit/php-token-stream 4.0.4 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 8
- Installation request for phpunit/phpunit 8.5.23 -> satisfiable by phpunit/phpunit[8.5.23].
- phpunit/phpunit 8.5.23 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 9
- Installation request for theseer/tokenizer 1.2.1 -> satisfiable by theseer/tokenizer[1.2.1].
- theseer/tokenizer 1.2.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
Problem 10
- tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- laravel/framework v6.20.44 requires tijsverkoyen/css-to-inline-styles ^2.2.1 -> satisfiable by tijsverkoyen/css-to-inline-styles[2.2.4].
- Installation request for laravel/framework v6.20.44 -> satisfiable by laravel/framework[v6.20.44].
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-mysqlnd.ini
- /etc/php/7.4/cli/conf.d/10-opcache.ini
- /etc/php/7.4/cli/conf.d/20-bcmath.ini
- /etc/php/7.4/cli/conf.d/20-bz2.ini
- /etc/php/7.4/cli/conf.d/20-curl.ini
- /etc/php/7.4/cli/conf.d/20-gd.ini
- /etc/php/7.4/cli/conf.d/20-imagick.ini
- /etc/php/7.4/cli/conf.d/20-imap.ini
- /etc/php/7.4/cli/conf.d/20-intl.ini
- /etc/php/7.4/cli/conf.d/20-json.ini
- /etc/php/7.4/cli/conf.d/20-mbstring.ini
- /etc/php/7.4/cli/conf.d/20-mysqli.ini
- /etc/php/7.4/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.4/cli/conf.d/20-readline.ini
- /etc/php/7.4/cli/conf.d/20-soap.ini
- /etc/php/7.4/cli/conf.d/20-xmlrpc.ini
- /etc/php/7.4/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.
答案1
您已安装缺少的扩展“dom”(php7.4-xml
)和“tokenizer”(php7.4-common
),但请确保它们已启用。
您可以使用命令检查它php -m
。
要启用这些扩展,请使用以下命令:
sudo phpenmod xml tokenizer