问题
I'm trying to enable some php extensions needed by Laravel. The documentation for the php.ini
file (https://cloud.google.com/appengine/docs/php/config/php_ini) says to place a php.ini file in the root of the application.
This is what my php.ini
looks like:
extension=openssl.so
extension=pdo.so
extension=tokenizer.so
extension=mbstring.so
google_app_engine.enable_functions = "php_sapi_name, php_uname"
When I deploy it, my log says:
PHP Warning: PHP Startup: Unable to load dynamic library '/base/php_runtime/modules/openssl.so' - /base/php_runtime/modules/openssl.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 '/base/php_runtime/modules/pdo.so' - /base/php_runtime/modules/pdo.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 '/base/php_runtime/modules/tokenizer.so' - /base/php_runtime/modules/tokenizer.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 '/base/php_runtime/modules/mbstring.so' - /base/php_runtime/modules/mbstring.so: cannot open shared object file: No such file or directory in Unknown on line 0
I've tried changing the way I've formatted the extensions in php.ini
:
extension="openssl.so"
extension="openssl.dll"
extension="php_openssl.so"
extension="php_openssl.dll"
I've tried it with quotations, and without them. With spaces in between them, without them. I'm not sure what else to try.
回答1:
I figured out the problem.
When you serve the application locally and when you deploy, App Engine uses the php.ini
file in the root of your application.
The problem was that when I ran it locally, I needed to have the extension=*
lines in php.ini
to load the necessary extensions. When I deployed it with those lines in php.ini
, I got the error I reported in my question.
My solution is to have two different versions of php.ini
: php.ini.local
and php.ini.dev
.
php.ini.local
:
extension=mbstring.so
extension=pdo.so
extension=openssl.so
extension=tokenizer.so
google_app_engine.enable_functions = "php_sapi_name, php_uname"
php.ini.dev
:
google_app_engine.enable_functions = "php_sapi_name, php_uname"
And use a Makefile to replace php.ini with either the dev version or local version depending on what I need.
Makefile
:
deploy:
cp php.ini.dev php.ini
# Code used to deploy
serve:
cp php.ini.local php.ini
# Code used to serve locally
来源:https://stackoverflow.com/questions/33611598/cant-enable-php-extensions-on-php-ini-on-app-engine-for-laravel