Database Uploads for WordPress with PHP: Difference between revisions

mNo edit summary
 
Line 2: Line 2:


=== Solution? ===
=== Solution? ===
Change some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions.
Change settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions.


= PHP Settings for Large phpMyAdmin Imports =
== php.ini ==
 
Below are the main settings to modify.  Jack 'em up higher if you have the RAM and / or need to import some really big stuff.<syntaxhighlight lang="ini">
Large WordPress database imports through phpMyAdmin can fail when PHP upload limits, POST limits, memory limits, or execution timers are too low.
 
== Main php.ini Settings ==
 
<syntaxhighlight lang="ini">
upload_max_filesize = 512M
upload_max_filesize = 512M
post_max_size = 600M
post_max_size = 600M
Line 18: Line 13:
</syntaxhighlight>
</syntaxhighlight>


=== Directive Definitions ===
; <code>upload_max_filesize</code>
; <code>upload_max_filesize</code>
: Maximum size of an uploaded SQL file.
: Maximum size of an uploaded SQL file.
Line 33: Line 29:
: Maximum time PHP may spend receiving input, including uploads.
: Maximum time PHP may spend receiving input, including uploads.


== phpMyAdmin Settings ==
== Settings can also be done in phpMyAdmin ==


These go in phpMyAdmin's <code>config.inc.php</code> file.
If it isn't desirable to modify system wide php.ini settings, just do it for phpMyAdmin. Location of where the config file is varies depending on the 'flavor' of Linux being used.


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
Line 43: Line 39:
</syntaxhighlight>
</syntaxhighlight>


=== More Definitions ===
; <code>$cfg['ExecTimeLimit']</code>
; <code>$cfg['ExecTimeLimit']</code>
: phpMyAdmin execution time limit.
: phpMyAdmin execution time limit.
Line 52: Line 49:
: Allows SQL files to be copied to a server-side upload directory and selected from phpMyAdmin, avoiding browser upload limits.
: Allows SQL files to be copied to a server-side upload directory and selected from phpMyAdmin, avoiding browser upload limits.


== Per-Site Configuration ==
== .htaccess too ==
 
Settings can be done on a per website basis too.<syntaxhighlight lang="ini">
If PHP runs as an Apache module, settings may be placed in <code>.htaccess</code>:
 
<syntaxhighlight lang="apache">
php_value upload_max_filesize 512M
php_value post_max_size 600M
php_value memory_limit 768M
php_value max_execution_time 600
php_value max_input_time 600
</syntaxhighlight>
 
If PHP runs through CGI, FastCGI, or PHP-FPM, use <code>.user.ini</code> instead:
 
<syntaxhighlight lang="ini">
upload_max_filesize = 512M
upload_max_filesize = 512M
post_max_size = 600M
post_max_size = 600M
Line 74: Line 58:
</syntaxhighlight>
</syntaxhighlight>


== Notes ==
== Remember ==


* Reload or restart the web server or PHP-FPM service after global PHP changes.
* Don't forget to restart PHP-FPM or other PHP related daemons / services if editing php.ini, as those settings won't apply until that's done
* For very large databases, command-line import with <code>mysql</code> or <code>mariadb</code> is usually more reliable than browser upload through phpMyAdmin.
* Restarting httpd or apache2, etc, won't cut it.
* Web server limits may also apply, such as Apache request limits or Nginx <code>client_max_body_size</code>.


== References ==
== References ==