Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 Ubuntu Instance Maximum File Upload Size

I was given an Amazon EC2 Ubuntu Instance. We are task to create a web application that includes uploading a client video. I have created a file upload application in my localhost and it is working fine. When I migrated the code to the virtual host server, I cannot upload any video and even any file that exceeds 2Mb. I tried editing the php.ini setting upload_max_filesize to 50M and post_max_size to 1000M.

After restarting Apache so many times, the update is not reflected in my phpinfo() information but changes were saved in my php.ini file.

enter image description here enter image description here

I was suspecting that the Amazon EC2 instance given to me has a file upload restrictions but Im not sure if Im right. If I was wrong, how can I override the configuration below? Any help would be very much appreciated.

UPDATE:

I even made sure that I was editing the correct configuration file. Below are the screen shots:

enter image description here

enter image description here

UPDATE:

I tried following what is said in the link with no luck. I have a lot of questions in mind about the link like:

  1. What does tomcatchesides mean about S3 bucket? I uploaded the config file in /var/www/html/.ebextensions . Am I doing the right thing?

My zzz.ini contains the code below and I place it in /etc/php.d/zzz.ini:

[php]
post_max_size = 1000M
upload_max_filesize = 50M

My myconfigfile.config was located in /var/www/html/.ebextensions/myconfigfile.config and contains the code below:

files:
  "/etc/php.ini":
    mode: "000644"
    owner: root
    group: root
    source: http://mybucketname.s3.amazonaws.com/php.ini

  "/etc/php.d/zzz.ini":
    mode: "000644"
    owner: root
    group: root
    source: http://mybucketname.s3.amazonaws.com/zzz.ini

How to know the bucket name of my instance?

I also copied my php.ini from /etc/php/7.0/apache2/php.ini to /etc/php.ini and restarted apache. Still no changes. Am I doing the right thing?

UPDATE:

I ask for the bucket name to the person who gave me the EC2 instance and her reply was.

Yes, you were given access to an EC2 instance. S3 is a different service provided by Amazon and that's not automatically available to EC2 instances. We can create a bucket in S3 for you but it may no longer be needed.

The EC2 instance has around 8GB storage space. You should be able to store multiple videos greater than 2MB in the EC2 file system and access them directly.

Using S3 for file uploads is a good idea especially when your software goes to production. However, to simplify the setup, please use the file system instead to store the videos.

UPDATE :

Running the following commands:

php -i | grep -i max_size

yields: post_max_size => 1000M => 1000M

grep -ir "max_size" /etc/php/7.0/apache2/conf.d/

yieds nothing.

grep -ir "max_size" /etc/php/7.0/

yields

/etc/php/7.0/fpm/php.ini:post_max_size = 1000M
/etc/php/7.0/apache2/php.ini:post_max_size = 1000M
/etc/php/7.0/cli/php.ini:post_max_size = 1000M

My phpinfo() can be access through this link

like image 817
alyssaeliyah Avatar asked May 24 '18 07:05

alyssaeliyah


People also ask

How do I increase max upload file size?

Using Plugin MethodGo to your WordPress Dashboard → Plugins → Add new, search “Increase Max Upload Filesize”, then Install and Activate the plugin. Once installed, go to plugin settings and simply enter the value for upload size. Click the Save Changes button to apply the new upload size.

What is the maximum size of document that can be uploaded?

5GB is the maximum upload size for a single Document.


2 Answers

After changin the php.ini file I also had to restart FPM:

sudo systemctl restart php-fpm.service

before restarting apache:

sudo systemctl restart httpd

like image 198
Lenon Tolfo Avatar answered Oct 02 '22 23:10

Lenon Tolfo


Check also for:

/etc/php.ini or

/etc/php-[version].ini

and modify the value also in this file. If this is not sufficient, search for:

/etc/php.d/aws.ini

infact it is possible that AWS is overriding your value. If this is the case, the solution is to create a file named /etc/php.d/99uploadsize.ini containing only:

[php]
upload_max_filesize = 100M
post_max_size = 100M

The name 99uploadsize.ini is not mandatory, but remember that the name should be in alphabetical order after aws.ini and in the same directory, because this is the order these ini files are read. Even if the example is not about generical Ubuntu with Apache, this kind of solution is given by Amazon for a similar issue with WP here:

https://aws.amazon.com/it/premiumsupport/knowledge-center/wordpress-themes-2mb/

like image 34
IgrewupwithSlackware Avatar answered Oct 02 '22 23:10

IgrewupwithSlackware