无法在适用于Laravel的App Engine上的php.ini上启用PHP扩展 [英] Can't Enable PHP Extensions on php.ini on App Engine for Laravel
问题描述
我正在尝试启用Laravel所需的一些php扩展. php.ini
文件的文档( https://cloud.google.com/appengine/docs/php/config/php_ini )表示将php.ini文件放置在应用程序的根目录中.
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.
这是我的php.ini
的样子:
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
我尝试更改格式化php.ini
中扩展名的方式:
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.
推荐答案
我发现了问题所在.
在本地提供应用程序以及在进行部署时,App Engine会在应用程序的根目录中使用php.ini
文件.
When you serve the application locally and when you deploy, App Engine uses the php.ini
file in the root of your application.
问题是,当我在本地运行它时,我需要在php.ini
中包含extension=*
行以加载必要的扩展.当我在php.ini
中的那些行中部署它时,出现了我在问题中报告的错误.
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.
我的解决方案是使用php.ini
的两个不同版本:php.ini.local
和php.ini.dev
.
My solution is to have two different versions of php.ini
: php.ini.local
and php.ini.dev
.
php.ini.local
:
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
:
php.ini.dev
:
google_app_engine.enable_functions = "php_sapi_name, php_uname"
根据我的需要,使用Makefile将php.ini替换为dev版本或本地版本.
And use a Makefile to replace php.ini with either the dev version or local version depending on what I need.
Makefile
:
Makefile
:
deploy:
cp php.ini.dev php.ini
# Code used to deploy
serve:
cp php.ini.local php.ini
# Code used to serve locally
这篇关于无法在适用于Laravel的App Engine上的php.ini上启用PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!