WordPress knowledge sharing

Solution to the size limit of WordPress uploaded files in Apache

Netizens have encountered a problem with the size limit of WordPress uploaded files. By default, only 2M files are allowed to be uploaded. Weieis Blog The uploaded file exceeded the upload_max_filesize direct in php.ini Throw it away. However, netizens reported that after following the tips in the article, they also restarted PHP, but the size limit remained unchanged. Later, Lao Wei learned that he used the Apache server, so the previous method is invalid (used under nginx). There are other methods in the Apache host.

I seldom touched the problem of Apache before, so I took this opportunity to make a record and share it. In the future, my friends will also be able to find a solution here. The novice will not bother asking for the right answer to solve this problem for several days. It's all from the novice period. Old Wei also had this stage, so friends with basic problems can help and understand each other.

As shown in the figure below, the maximum upload size is 2M, that is, the maximum upload file size is 2M. OK, let's solve this problem.

There are two solutions. The code comes from https://liuyanzhao.com/1764.html , thank the blogger for sharing selflessly.

1、 Create a new php.ini file in the root directory of the host website, add the following code, and restart Apache to take effect.

upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300

2、 If the. htaccess file already exists in the root directory of your website, add the following code to take effect without restarting Apache.

php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300

If there is no. htaccess file in the root directory of your Apache server, you can create one in the root directory and add the following code

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !- f
RewriteCond %{REQUEST_FILENAME} !- d
RewriteRule . /index.php [L]

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
</IfModule>
# END WordPress

The second method is recommended. You don't need to restart Apache, which is more convenient.

Note that the. htaccess file is a hidden file and will not be generated. Please see How to create a. htaccess file , you can upload it to the root directory of the website on the local computer. If you can't see whether this file exists, please see the solution Solution to Winscp not displaying hidden files

The netizen said that after using the second method, the upload limit was successfully modified, and the file could also be uploaded normally. The problem was solved successfully.

Like( zero )
Article name: Solution to the size limit of WordPress uploaded files in Apache
Article link: https://www.vpsss.net/12846.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.