Database Uploads for WordPress with PHP: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 4: | Line 4: | ||
Change some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions. | Change some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions. | ||
= | = PHP Settings for Large phpMyAdmin Imports = | ||
Large | |||
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"> | <syntaxhighlight lang="ini"> | ||
| Line 19: | Line 18: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
; <code>upload_max_filesize</code> | |||
: Maximum size of an uploaded SQL file. | |||
; <code>post_max_size</code> | |||
: Maximum total HTTP POST request size. Set this larger than <code>upload_max_filesize</code>. | |||
; <code>memory_limit</code> | |||
: Maximum memory PHP may use. For large imports, set this larger than <code>post_max_size</code>. | |||
; <code>max_execution_time</code> | |||
: Maximum script execution time, in seconds. | |||
; <code>max_input_time</code> | |||
: Maximum time PHP may spend receiving input, including uploads. | |||
== phpMyAdmin Settings == | |||
These go in phpMyAdmin's <code>config.inc.php</code> file. | |||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
| Line 44: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>$cfg['UploadDir']</code> | ; <code>$cfg['ExecTimeLimit']</code> | ||
: phpMyAdmin execution time limit. | |||
; <code>$cfg['MemoryLimit']</code> | |||
: phpMyAdmin memory limit override. | |||
; <code>$cfg['UploadDir']</code> | |||
: Allows SQL files to be copied to a server-side upload directory and selected from phpMyAdmin, avoiding browser upload limits. | |||
== Per-Site Configuration == | == Per-Site Configuration == | ||
If PHP runs as an Apache module, settings may be placed in <code>.htaccess</code>: | |||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
php_value upload_max_filesize 512M | php_value upload_max_filesize 512M | ||
php_value post_max_size 600M | php_value post_max_size 600M | ||
| Line 59: | Line 64: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If PHP runs through CGI, FastCGI, or PHP-FPM, use <code>.user.ini</code> instead: | |||
<syntaxhighlight lang="ini"> | <syntaxhighlight lang="ini"> | ||
| Line 71: | Line 76: | ||
== Notes == | == Notes == | ||
* | * Reload or restart the web server or PHP-FPM service after global PHP changes. | ||
* | * For very large databases, command-line import with <code>mysql</code> or <code>mariadb</code> is usually more reliable than browser upload through phpMyAdmin. | ||
* Web server limits may also apply, such as Apache request limits or Nginx <code>client_max_body_size</code>. | |||
== | == References == | ||
* [https://www.php.net/manual/en/ini.core.php PHP Manual: Core php.ini directives] | * [https://www.php.net/manual/en/ini.core.php PHP Manual: Core php.ini directives] | ||
* [https://www.php.net/manual/en/features.file-upload.common-pitfalls.php PHP Manual: File upload common pitfalls] | * [https://www.php.net/manual/en/features.file-upload.common-pitfalls.php PHP Manual: File upload common pitfalls] | ||
* [https://www.php.net/manual/en/configuration.changes.php PHP Manual: | * [https://www.php.net/manual/en/configuration.changes.php PHP Manual: Changing configuration settings] | ||
* [https://www.php.net/manual/en/configuration.file.per-user.php PHP Manual: .user.ini files] | * [https://www.php.net/manual/en/configuration.file.per-user.php PHP Manual: .user.ini files] | ||
* [https://docs.phpmyadmin.net/en/latest/config.html phpMyAdmin Documentation: Configuration] | * [https://docs.phpmyadmin.net/en/latest/config.html phpMyAdmin Documentation: Configuration] | ||
* [https://docs.phpmyadmin.net/en/ | * [https://docs.phpmyadmin.net/en/latest/faq.html#i-cannot-upload-big-dump-files-memory-http-or-timeout-problems phpMyAdmin FAQ: Cannot upload big dump files] | ||