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
Related
I have deployed an application in Elastic Beanstalk, changed some configuration so that I can upload larger files and restart nginx server.
When I upload one file less than 2 GB, it is uploaded successfully. However, when I upload a file more than 2 GB, it does not upload successfully. Below are the lines that I have added in /etc/nginx/nginx.conf file:
client_max_body_size 7500M;
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;
Also, I have added config file in .ebextensions and put in the following content:
files:
"/etc/php.d/99uploadsize.ini":
mode: "000644"
owner: root
group: root
content: |
post_max_size = 5000M
upload_max_filesize = 5000M
memory_limit = 5000M
commands:
remove_old_ini:
command: "rm -f /etc/php.d/99uploadsize.ini.bak"
and also tried the following content:
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000755"
owner: root
group: root
content: |
post_max_size = 7500M
upload_max_filesize = 5000M
memory_limit = 7500M
client_max_body_size = 5000M
Here is the phpinfo() snapshot:
Where am I going wrong? Kindly assist me
PHP Settings
Your PHP Settings are absolute correct are there is no error is the settings.
Uploading Error Not PHP
As per you picture posted the Error Code i.e. 7 which means
UPLOAD_ERR_CANT_WRITE - 7; Failed to write file to disk. Introduced in PHP 5.1.0
It means you uploading code is correct but at the time of writing the file on the system it is failed.
Apache Settings
LimitRequestBody
This directive specifies the number of bytes from 0 (meaning unlimited) to 2147483647 (2GB) that are allowed in a request body.
The LimitRequestBody directive allows the user to set a limit on the allowed size of an HTTP request message body within the context in which the directive is given (server, per-directory, per-file or per-location). If the client request exceeds that limit, the server will return an error response instead of servicing the request. The size of a normal request message body will vary greatly depending on the nature of the resource and the methods allowed on that resource. CGI scripts typically use the message body for retrieving form information. Implementations of the PUT method will require a value at least as large as any representation that the server wishes to accept for that resource.
This directive gives the server administrator greater control over abnormal client request behavior, which may be useful for avoiding some forms of denial-of-service attacks.
Solution:
You cannot post/upload the file through PHP more than 2 GB as Apache server will not let it do it.
The Only solution through is that you can zip it and while doing zip split the file less then 2 GB per file and then unzip them, to server which each request.
Run the script to unzip the file and do things.
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.
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
I am running a website using AWS Elastic Beanstalk. In AWS Elastic Beanstalk, the default upload_max_filesize in php.ini is limited to 2M. I want to increase the upload_max_filesize to 20M. I do the following thing and 'Upload and Deploy' EBS by uploading the new application source codes with the new 99my_php_ini_change.config. But it does not automatically create the /etc/php.d/zzz_my_own_php.ini. I also
'Create New Application' using Elastic Beanstalk, but I did not see the file /etc/php.d/zzz_my_own_php.ini was successfully created either.
Where is the error?
I thing I did was:
put file 99my_php_ini_change.config inside folder .ebextensions under application root.
99my_php_ini_change.config contains :
files:
"/etc/php.d/zzz_my_own_php.ini" :
mode: "000644"
owner: root
group: root
content: |
upload_max_filesize=20M
Do you see any error messages in the log file at /var/log/eb-activity.log? You can view the full log file by doing an eb ssh, or you can retrieve it through the EB console or from the command-line using eb logs. If there are any errors, please show your log file here.
Also, YAML files are very sensitive to whitespace. You might try the following instead (notice the two spaces per indent level, lack of space before the colon, and lack of newline):
files:
"/etc/php.d/zzz_my_own_php.ini":
mode: "000644"
owner: root
group: root
content: |
upload_max_filesize=20M
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