问题
I am still getting this error below saying that PHP extension mbstring
is missing when deploying my Laravel application (version 6.17.1
) using Dokku (version 0.18.3
) even though I have followed the documentation (https://devcenter.heroku.com/articles/php-support#using-optional-extensions).
-----> Cleaning up...
-----> Building laravel-app from herokuish...
-----> Adding BUILD_ENV to build environment...
-----> Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected buildpacks: multi nodejs php
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-php.git
=====> Detected Framework: PHP
remote: -----> Bootstrapping...
remote: -----> Installing platform packages...
remote: - php (7.4.3)
remote: - ext-mbstring (bundled with php)
remote: - apache (2.4.41)
remote: - nginx (1.16.1)
remote: PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote: PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote: -----> Installing dependencies...
remote: Composer version 1.9.3 2020-02-04 12:58:49
remote: PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring.so' (tried: /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so (libonig.so.4: cannot open shared object file: No such file or directory), /app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so (/app/.heroku/php/lib/php/extensions/no-debug-non-zts-20190902/mbstring.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
remote: Loading composer repositories with package information
remote: Installing dependencies from lock file
remote: Your requirements could not be resolved to an installable set of packages.
remote:
remote: Problem 1
remote: - The requested PHP extension ext-mbstring * is missing from your system. Install or enable PHP's mbstring extension.
remote: Problem 2
remote: - Installation request for laravel/framework v6.17.1 -> satisfiable by laravel/framework[v6.17.1].
remote: - laravel/framework v6.17.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote: Problem 3
remote: - Installation request for league/commonmark 1.3.1 -> satisfiable by league/commonmark[1.3.1].
remote: - league/commonmark 1.3.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote: Problem 4
remote: - Installation request for sentry/sentry 2.3.1 -> satisfiable by sentry/sentry[2.3.1].
remote: - sentry/sentry 2.3.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote: Problem 5
remote: - laravel/framework v6.17.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
remote: - sentry/sentry-laravel 1.7.0 requires illuminate/support 5.0 - 5.8 | ^6.0 | ^7.0 -> satisfiable by laravel/framework[v6.17.1].
remote: - Installation request for sentry/sentry-laravel 1.7.0 -> satisfiable by sentry/sentry-laravel[1.7.0].
remote:
remote: To enable extensions, verify that they are enabled in your .ini files:
remote: - /app/.heroku/php/etc/php/php.ini
remote: - /app/.heroku/php/etc/php/conf.d/000-heroku.ini
remote: - /app/.heroku/php/etc/php/conf.d/010-ext-zend_opcache.ini
remote: - /app/.heroku/php/etc/php/conf.d/100-ext-mbstring.ini
remote: - /tmp/buildpackKITei/conf/php/apm-nostart-overrides/apm-nostart-overrides.ini
remote: You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
remote:
remote: ! ERROR: Dependency installation failed!
remote: !
remote: ! The 'composer install' process failed with an error. The cause
remote: ! may be the download or installation of packages, or a pre- or
remote: ! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote: ! in your 'composer.json'.
remote: !
remote: ! Typical error cases are out-of-date or missing parts of code,
remote: ! timeouts when making external connections, or memory limits.
remote: !
remote: ! Check the above error output closely to determine the cause of
remote: ! the problem, ensure the code you're pushing is functioning
remote: ! properly, and that all local changes are committed correctly.
remote: !
remote: ! For more information on builds for PHP on Heroku, refer to
remote: ! https://devcenter.heroku.com/articles/php-support
remote:
What I have tried:
- Update
composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.2",
"ext-mbstring": "*",
"aws/aws-sdk-php": "^3.133",
"fideloper/proxy": "^4.0",
"laravel/framework": "^6.2",
"laravel/tinker": "^2.0",
"sentry/sentry-laravel": "^1.6"
},
"require-dev": {
"facade/ignition": "^1.4",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^8.0"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
- Run
composer update
git add
andgit commit
bothcomposer.json
andcomposer.lock
files before deploying
Any help is appreciated, thanks!
回答1:
Issue solved, here are the steps:
- Make sure your app uses these 2 buildpacks:
https://github.com/heroku/heroku-buildpack-apt
https://github.com/heroku/heroku-buildpack-php
- Create a new file
Aptfile
on root directory with content as below:
libonig-dev
libonig4
git add
,git commit
and deploy, it should work now
References:
- Answer reference and more detail: https://github.com/gliderlabs/herokuish/issues/529#issuecomment-592938477
- https://github.com/heroku/heroku-buildpack-apt
- https://github.com/heroku/heroku-buildpack-php
- How to set/add buildpacks in dokku: https://github.com/dokku/dokku/blob/master/docs/deployment/methods/buildpacks.md
- About
Aptfile
: https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-apt
来源:https://stackoverflow.com/questions/60468025/dokku-php-extension-mbstring-is-missing-when-deploying-laravel-application