Wordpress upload file size

2019-02-17 16:30发布

问题:

I'm a noob and using Wordpress on Google cloud. When attempting to upload a new theme, I get the following error message:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

This is a limitation seems to be set by Google Compute Engine. I've found info about the limitation being set in the php.ini file, but I can't seem to locate that file anywhere.

Can anyone give some idiot proof, step-by-step instructions to increase the upload size beyond 2MB? I've installed the WP plug-ins that should do this, but the problem must be server side.

回答1:

I'm not sure what operating system you are using or what version of PHP you are using. I run an Ubuntu 12.04 instance from Amazon Web Services using PHP-FPM. But, the instructions should be basically the same for you. The directory where your php.ini file is saved may be slightly different in item 3. Go hunt for it.

  1. Log in to your server via SSH.
  2. Change user to root: sudo /bin/bash
  3. Edit the php.ini file: nano /etc/php5/fpm/php.ini
  4. Find the line that says upload_max_filesize = 2M . In nano, you can search by typing Ctrl W.
  5. Change to whatever file size you want Whatever you type must have an M (megabytes) or G (gigabytes) at the end (e.g. upload_max_filesize = 200M or =1G).

Aim for the lowest number that you NEED, and keep in mind that PHP has another setting elsewhere that sets how long it will wait before a timeout. You can set a 2G upload limit, but if your timeout is 30 seconds you're still going to fail unless you can upload 2G in 30 seconds. As a general rule, aim low.

  1. Type Ctrl X to exit, save your file changes.
  2. Restart PHP by typing service php5-fpm restart


回答2:

In your Google development console dashboard, at the left, under Compute you have Instance of MV

  1. click to see all your instance parameters
  2. click on ssh button to access to your server
  3. tape find / -name php.ini to find the directory of your php.ini
  4. tape sudo nano in my case it was sudo nano /etc/php5/apache2/php.ini
  5. find the line upload_max_filesize = 2M and change it to 20M or more
  6. restart your server with sudo /etc/init.d/apache2 restart

It worked fine for me !



回答3:

  1. Install Google Cloud SDK (GCS) https://cloud.google.com/sdk/gcloud/
  2. GCS: Setup you account in Google Cloud SDK Shell gcloud auth login
  3. Get connection string from web console https://console.developers.google.com

    • YourProject > Compute > Compute Engine > VM instances
    • On instance line: connect/SSH > popup menu > view gcloud command
    • Copy gcloud compute command line
  4. GCS: Run it in Google Cloud SDK Shell to open SSH gcloud compute --project "your_project-id" ssh --zone "us-central1-a" "wordpress-your_id"

  5. GCS: Copy php.ini to your localhost: gcloud compute --project "your_project-id" copy-files "wordpress-your_id":/etc/php5/apache2/php.ini php.ini --zone "us-central1-a"
  6. Edit line upload_max_filesize = 2M in php.ini located in your Cloud SDK folder

  7. GCS: Upload back to the host in your home directory:gcloud compute --project "your_project-id" php.ini copy-files "wordpress-your_id":~/php.ini --zone "us-central1-a"

  8. SSH: Change user to root in PuTTY: sudo /bin/bash

  9. SSH: Replace php.ini: cp php.ini /etc/php5/apache2/php.ini
  10. SSH: Restart service: service apache2 restart


回答4:

I did this steps

  1. In the terminal console you need to edit the correct php.ini, in my case was:

    vi /etc/php5/apache2/php.ini

    1. I made the seek and changed the upload_max_filesize and post_max_size variables like this:

    post_max_size = 256M

    upload_max_filesize = 256M

  2. I restarted the apache server

    /etc/init.d/apache2 restart

And work for me.



回答5:

You must know about how Google products works.

At least, there are two things you can control.

  1. The memory that WP itself will try to use as max: define('WP_MEMORY_LIMIT', '256M');
  2. The value of the "container" you are using (600Mhz/128Mb on the free usage).

Even if it's running PHP, it's using their own infraestructure, based on Python and using it's own config files. So no .htaccess or php.ini will be parsed here. Just the config files that you can read about on the Documentation.

Anyway, im watching people's reports and being know that you can at least run the 128Mb of the minumun instance. Also, i don't recommend you to use AppEngine to host a blog.