PHP : enable Ioncube loader extension in GAE standard environment - php

I have issue in enable ioncube loader extension in google app engine standard envirenement,
I get this error :
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
I already added it in first of php.ini file :
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
I think I need to add it in default php.ini file to execute at first but I dont know how to rewrite default php.ini file or replace it...

First you need to change environment to flex and use custom runtime
add dockerfile
move your app to sub directory www
create sub directory config and create empty php.ini file inside him
download ioncube loader and move it to main directory
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
after that deploy your application and navigate txt file url "yourdomain.com/phpconfig.txt" copy contain and add it to your config/php.ini
don't forget add ioncube in first line :
zend_extension = "/app/ioncube_loader_lin_7.2.so"
edit dockerfile again :
# 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
and deploy your application thats all.

Related

how to add these settings to my php.ini in docker

I'm using docker-compose, and I want to add this setting to my php.ini
upload_max_filesize = 50M
but I'm confused I have 2 php.ini, please see the screenshot
how can I persist my additional setting to the php.ini?
Thank you in advance
Use docker cp <php_container_name>:/usr/local/etc/php/php.ini-development . to copy the ini file from the container to host. Change the settings as you like then mount the edited file into the container. In the compose file add this to your php service:
volumes:
- /home/user/my-edited-php.ini:/usr/local/etc/php/php.ini
It should appear in the directory inside the container as php.ini.

Problem with: Maximum upload file size: 2 MB in Google Kubernetes Wordpress

I deployed this Wordpress kubernetes container: https://console.cloud.google.com/marketplace/details/google/wordpress?project
But I have a problem with upload the theme in Wordpress.
The uploaded file exceeds the upload_max_filesize directive in php.ini.
I can't find the file: php.ini. in the pods of kubernetes.
I tried to use plugin for edit php.ini in Wordpress https://wordpress.org/plugins/php-settings/ but it's no write the file.
Could someone help me with a step-by-step guide to modify the container's yaml or other solution?
As adviced here, the recommended way is to mount a php config ini file. The most convenient way to expose it is using Kubernetes ConfigMaps. Pls create a new config map:
apiVersion: v1
kind: ConfigMap
metadata:
name: wp-php-config
namespace: default
data:
uploads.ini: |-
file_uploads = On
upload_max_filesize = 256M
post_max_size = 256M
memory_limit = 64M
max_execution_time = 600
And then expose the configMap as a volume in your pod by adding the following config to you're pod spec.template.spec.containers:
... (wordpress container specs)
volumeMounts:
- mountPath: /usr/local/etc/php/conf.d/uploads.ini
name: php-config
subPath: uploads.ini
(...)
volumes:
- configMap:
defaultMode: 420
name: wp-php-config
name: php-config
You might also need to adjust your ingress max upload limit. Assuming you're using nginx ingress, pls decorate it with an annotation:
nginx.ingress.kubernetes.io/proxy-body-size: 50m
If you want to apply the change to the ingress globally, search for the ingress configMap and add the setting there.
You can execute 'kubectl get pods' to list the pods and then get into a shell using 'kubectl exec -it [POD_NAME] -- /bin/bash'. You can then follow methods mentiond in this link to change the value.
Another option is to create a ConfigMap with your custom configuration similar to this link to increase the size of the upload file size.
Then you need to go to your GKE workloads and in “wordpress-1-wordpress” workload of type “StatefulSet” you need to modify the YAML file where you can add the ConfigMap data to a Volume.
Another workaround is that, you can rebuild the image that you are using in a docker file.
This is what I did to resolve the issue:
I added these lines to my Dockerfile
file upload
RUN touch /usr/local/etc/php/conf.d/uploads.ini \
&& echo "file_uploads = On \n\
max_execution_time = 600 \n\
upload_max_filesize = 200M \n\
post_max_size = 200M" >> /usr/local/etc/php/conf.d/uploads.ini
in nginx-ingress dependencies.yml,i added these 'data' parameters in the configmap and it worked.
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-configuration
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
data:
proxy-body-size: "200m"
client-max-body-size: "200m"
After that, *kubectl apply -f ingress/dependencies.yml* and i was able to upload more than 2mb.
Try this and see if it works for you

/etc/php/7.0/fpm/zz_overrides.ini isn't effective (isn't counted) after server restart

In Ubuntu 16.04 with Nginx (LEMP) I created the file /etc/php/7.0/fpm/zz_overrides.ini.
The file contains only this code:
[PHP]
post_max_size = 2000M
upload_max_filesize = 2000M
max_execution_time = 3000
cgi.fix_pathinfo=0
After creating the file I saved it and restarted Nginx and PHP-FPM:
systemctl restart nginx.service
/etc/init.d/php*-fpm restart
And yet, I don't see the effect. For example, I can still upload data up until 2 megabytes instead 2000 megabytes, see:
My question
Why is the zz_overrides.ini file isn't effective?
Create a php file with the following content:
<?php
phpinfo();
?>
There you can see all current settings.
In the first section you have "Additional .ini files parsed".
So you can see which files are loaded.
Also "Scan this dir for additional .ini files" shows you which additional folders are scanned for config files.
What I had to do is to enable my additional php.ini file
I did so by creating a softlink (symlink) to it, in conf.d directory:
ln -s /etc/php/7.0/fpm/zz_overrides.ini 20-zz-overrides.ini
Then indeed I saw the desired change:
Version-agnostic variant
A version-agnostic (version independent) variant of this command is this:
ln -s /etc/php/*/fpm/zz_overrides.ini 20-zz-overrides.ini

AWS Elastic BeanStalk php.ini file update

I would like to increase my minimum upload filesize from 2MB to 64 MB for my php web application.. I have a config file stored in an .ebextensions directory.. While deploying to aws, an error occurred:
The configuration file .ebextensions/yep.config in application version try10 contains invalid YAML or JSON. YAML exception: while scanning a simple key in "", line 7, column 7: upload_max_filesize = 64M ^ could not found expected ':' in "", line 8, column 7: post_max_size = 64M ^ , JSON exception: Unexpected character (f) at position 0.. Update the configuration file.
Below is my config file that I am starting out with. I have spend 8 hours troubleshooting with no luck. Any help will be very much obliged.
files:
"/etc/php.ini":
mode: "000755"
owner: root
group: root
content: |
upload_max_filesize = 64M
post_max_size = 64M
I am using this successfully in an Elastic Beanstalk application. Just put the following into your yep.config file inside of your .ebextensions directory in the root of your application.
files:
"/etc/php.d/project.ini" :
mode: "000644"
owner: root
group: root
content: |
upload_max_filesize=64M
post_max_size=64M

Changing php.ini on Elastic Beanstalk

I am trying to configure my beanstalk application, setting the max_input_vars=5000 in php.ini.
I found this link which does pretty close to what I want except a little different. Instead of copying from S3 I just want to create a file with that line. The below is my code in a file named phpini.config found in the .elasticbeanstalk folder.
files:
"/etc/php.d/project.ini" :
mode: "000777"
owner: root
group: root
content: |
max_input_vars=5000
However, the value is not changing, as I seen when I run phpinfo(), nor is there a project.ini file created in /etc/php.d/.
Is there something I am missing out? Or is there a way I can see if this config file is being run?
Edit
Seems like the .config file is supposed to be in .ebextensions instead of .elasticbeanstalk according to AWS Docs. Making the change didnt make things work though.
The cleanest way what we did to install a svn plugin that is to use a .ebextensions config file in my project archive:
Sample you can go like this create a file .ebextensions/eb.config file:
files:
"/etc/php.d/project.ini" :
mode: "000644"
owner: root
group: root
content: |
u max_input_vars=5000
I tried the abaid778 snippet code and does not work so I remove de 'u' before max_input_vars and that work now.
files:
"/etc/php.d/project.ini" :
mode: "000644"
owner: root
group: root
content: |
max_input_vars = 5000
I couldn't make the previous suggestions work but was able to change the php.ini value with .htaccess:
php_value max_input_vars 5000
How to set the max_input_vars directive in an .htaccess file

Categories