Amazon EC2 Ubuntu Instance Maximum File Upload Size

alyssaeliyah picture alyssaeliyah · May 24, 2018 · Viewed 9k times · Source

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

Answer

Lenon Tolfo picture Lenon Tolfo · Jan 15, 2020

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