简体   繁体   English

Amazon EC2 Ubuntu 实例最大文件上传大小

[英]Amazon EC2 Ubuntu Instance Maximum File Upload Size

I was given an Amazon EC2 Ubuntu Instance.我得到了一个 Amazon EC2 Ubuntu 实例。 We are task to create a web application that includes uploading a client video.我们的任务是创建一个包含上传客户端视频的 Web 应用程序。 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 .当我将代码迁移到虚拟主机服务器时,我无法上传任何视频,甚至任何超过2Mb文件。 I tried editing the php.ini setting upload_max_filesize to 50M and post_max_size to 1000M .我尝试将php.ini设置upload_max_filesize编辑为50M并将 post_max_size 设置为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.多次重启 Apache 后,更新没有反映在我的phpinfo()信息中,但更改保存在我的php.ini文件中。

在此处输入图片说明 在此处输入图片说明

I was suspecting that the Amazon EC2 instance given to me has a file upload restrictions but Im not sure if Im right.我怀疑给我的 Amazon EC2 实例有文件上传限制,但我不确定我是否正确。 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:以下是屏幕截图:

在此处输入图片说明

在此处输入图片说明

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 ? tomcatchesidesS3 bucket意味着什么? I uploaded the config file in /var/www/html/.ebextensions .我将配置文件上传到/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 :我的zzz.ini包含下面的代码,我把它放在/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:我的myconfigfile.config位于/var/www/html/.ebextensions/myconfigfile.config并包含以下代码:

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.我还将我的php.ini/etc/php/7.0/apache2/php.ini复制到/etc/php.ini并重新启动了 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.我向提供 EC2 实例的人询问存储桶名称,她的回答是。

Yes, you were given access to an EC2 instance.是的,您获得了对 EC2 实例的访问权限。 S3 is a different service provided by Amazon and that's not automatically available to EC2 instances. S3 是 Amazon 提供的不同服务,EC2 实例不会自动提供该服务。 We can create a bucket in S3 for you but it may no longer be needed.我们可以在 S3 中为您创建一个存储桶,但可能不再需要它。

The EC2 instance has around 8GB storage space. EC2 实例有大约 8GB 的​​存储空间。 You should be able to store multiple videos greater than 2MB in the EC2 file system and access them directly.您应该能够在 EC2 文件系统中存储多个大于 2MB 的视频并直接访问它们。

Using S3 for file uploads is a good idea especially when your software goes to production.使用 S3 进行文件上传是一个好主意,尤其是当您的软件投入生产时。 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产量: 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我的phpinfo()可以通过这个链接访问

Check also for:还要检查:

/etc/php.ini or /etc/php.ini

/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.事实上,AWS 可能会覆盖您的价值。 If this is the case, the solution is to create a file named /etc/php.d/99uploadsize.ini containing only:如果是这种情况,解决方案是创建一个名为 /etc/php.d/99uploadsize.ini 的文件,该文件仅包含:

[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.名称 99uploadsize.ini 不是强制性的,但请记住,名称应按字母顺序排列在 aws.ini 之后且位于同一目录中,因为这是读取这些 ini 文件的顺序。 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:即使示例不是关于带有 Apache 的通用 Ubuntu,亚马逊也针对 WP 的类似问题提供了这种解决方案:

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

After changin the php.ini file I also had to restart FPM:更改 php.ini 文件后,我还必须重新启动 FPM:

sudo systemctl restart php-fpm.service

before restarting apache:在重新启动 apache 之前:

sudo systemctl restart httpd

Sorry guys, for bothering all of you, my bad.对不起各位,打扰你们了,我的错。 I was banging my head for this for almost 4 days and it turns out that I have only made a syntax error in my php.ini.我为此苦恼了将近 4 天,结果我只在 php.ini 中犯了一个语法错误。 I updated my server php.ini with my newly installed php in my localhost and phpinfo() was updated after apache restart.我使用本地主机中新安装的 php 更新了我的服务器 php.ini,并且 phpinfo() 在 apache 重启后更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM