PHP:在GAE标准环境中启用Ioncube加载程序扩展

时间:2019-01-10 20:05:32

标签: php apache google-app-engine ioncube

我在Google App Engine标准环境中启用ioncube loader扩展程序时遇到问题,  我收到此错误:

NOTICE: PHP message: PHP Fatal error: [ionCube Loader] The Loader must appear as the first entry in the php.ini file in Unknown on line 0

我已经将它添加到了php.ini文件的第一个:

zend_extension = /srv/modules/ioncube_loader_lin_7.2.so
asp_tags = Off
display_errors = Off
max_execution_time = 3600
max_input_time = 3600
max_input_vars = 1000
memory_limit = 512M
post_max_size = 128M
session.gc_maxlifetime = 1440
upload_max_filesize = 1G
zlib.output_compression = On

我认为我需要先将其添加到默认的php.ini文件中才能执行,但我不知道如何重写默认的php.ini文件或替换它...

1 个答案:

答案 0 :(得分:0)

首先,您需要更改环境以灵活使用自定义运行时

添加dockerfile

将您的应用移动到子目录www

创建子目录配置并在其中创建空的php.ini文件

下载ioncube加载程序并将其移至主目录

Direcotory:

-config
   php.ini
-www
app.yaml
composer.json
dockerfile
ioncube_loader_lin_7.2.so

app.yaml:

runtime: custom
env: flex

runtime_config:
  document_root: www
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

composer.json:

{
  "require": {
    "php": "7.2.*"
  }
}

Dockerfile:

# Dockerfile extending the generic PHP image with application files for a
# single application.
FROM gcr.io/google-appengine/php:latest
# environment variable.
ENV DOCUMENT_ROOT /app/www
# copy default php.ini to txt file
RUN cp /opt/php72/lib/php.ini www/phpconfig.txt

在部署您的应用程序并浏览txt文件网址“ yourdomain.com/phpconfig.txt”后,将其包含并添加到您的config / php.ini中 别忘了在第一行中添加ioncube:

zend_extension = "/app/ioncube_loader_lin_7.2.so"

再次编辑dockerfile:

# Dockerfile extending the generic PHP image with application files for a
# single application.
FROM gcr.io/google-appengine/php:latest
# environment variable.
ENV DOCUMENT_ROOT /app/www
COPY config/php.ini /opt/php72/lib/php.ini

并部署您的应用程序。