Importing large xml file

I’m trying to import a content xml wordpress file to a develop environment. The file has 26mb and Nginx returns

413 Request Entity Too Large

I edited /etc/nginx/nginx.conf adding

client_max_body_size 200m;

(as documentation say)

Also, I edited /etc/php5/fpm/php.ini adding

memory_limit = 32M
upload_max_filesize = 200M
post_max_size = 300M

After restart Nginx, nothing change. Iknow this issue is all about third party software. In order to keep on topic I ask about specific Trellis configuration. There is something I must to know about it?

Thanks a lot. This simple issue involves a lot of things: Vagrant boxes, Nginx and php, actually away of my knowledge.

You did re-provision (run server.yml) after editing those values I assume?

edit: oops read too quickly and I see that you edited those files directly on the server. Maybe you did that just to test it quickly but always update those values in the Trellis configs itself. You ideally never want to make manual changes like those straight on the server.

1 Like

The value you edited in nginx.conf most likely gets overridden one in the WP site config.

See https://github.com/roots/trellis/blob/c52c245b9854c09b57781c1e505510354d2499f5/roles/nginx/templates/wordpress.conf.j2#L13. So you should be setting php_post_max_size in a group_vars file and re-provisioning.

2 Likes

I did it but nothing changed. I put
php_post_max_size: 40m inside group_vars/development/wordpress_sites.yml
inside specific site, between system_cron and env. Here is:

contraindicaciones.net:
    site_hosts:
      - contraindicaciones.dev
    local_path: ../contraindicaciones # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@bitbucket.org:aitormendez/contraindicaciones.git
    site_install: true
    site_title: contraindicaciones
    admin_user: aitor
    admin_password: **************
    admin_email: aitor@e451.dev
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    cache:
      enabled: false
      duration: 30s
    system_cron: true
    php_post_max_size: 40m
    env:
      wp_home: http://contraindicaciones.dev
      wp_siteurl: http://contraindicaciones.dev/wp
      wp_env: development
      db_name: contraindicaciones_dev
      db_user: aitor_contraindicaciones
      db_password: ****************

Is it right place?
I did first a vagrant destroy and vagrant up again because an error in vagrant provision so, system core is clean. I this order:

vagrant destroy
vagrant up
vagrant provision (with php_post_max_size: 40m)

Also I tried with errors:

$ ansible-playbook -i hosts/development server.yml

PLAY [Determine Remote User] ************************************************** 

TASK: [remote-user | Determine whether to connect as root or admin_user] ****** 
ok: [127.0.0.1 -> 127.0.0.1]

TASK: [remote-user | Set remote user for each host] *************************** 
ok: [127.0.0.1]

TASK: [remote-user | Announce which user was selected] ************************ 
ok: [127.0.0.1] => {
    "msg": "Note: Ansible will attempt connections as user = aitor"
}

PLAY [WordPress Server - Install LEMP Stack with PHP 5.6 and MariaDB MySQL] *** 

GATHERING FACTS *************************************************************** 
fatal: [127.0.0.1] => SSH Error: ssh: connect to host 127.0.0.1 port 22: Connection refused
    while connecting to 127.0.0.1:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

TASK: [common | Validate Ansible version] ************************************* 
FATAL: no hosts matched or all hosts have already failed -- aborting


PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/Users/aitor/server.retry

127.0.0.1                  : ok=3    changed=0    unreachable=1    failed=0

Solved!

I edited group_vars/development/php.yml instead wordpresss_sites.yml:

php_post_max_size: '40m'

First, Nginx allow to upload file, but WordPress show me another error about upload_max_filesize exceed. So, I wrote another line at php.yml:

php_upload_max_filesize: '40m'

It works! Thank you for the help.

1 Like

Sorry, @swalkinshaw, a last question. When I try to do the same at production environment, there is no php.yml inside /group_vars/production. Should I create it?

It doesn’t exist because our defaults are meant for production. So just create it and override that one variable :smile:

1 Like

I keep in troubles. Everything seems ok at remote server WP interface. Import plugin shows a 40mb max file size allowed. I upload my 26mb xml file.

After a minute uploading, upload stop and a mesage is shown “connection was reset”.

I’m lost. What is the problem?

Thanks!

Solved again, using wp CLI import. Sorry about noise.

1 Like

try to add the max_execution_time and set it to 300. // 300s = 5Minutes

2 Likes

Hi, I’m a newbie and I don’t know how can I increase “max time execution”.

I edited “group_vars/development/php.yml” as Aitor did with the other variables.

Then " vagrant reload ".

But it doesn’t seem to work.

Thanks in advance.

You’d need to run vagrant provision again. reload isn’t enough.

1 Like

Thanks @swalkinshaw, it worked perfectly.

I tried vagrant up but it didn’t work either.