

1、找到 php.ini 的位置
使用 php 的 phpinfo() 函式取得 php 環境設定,新增一個內容如下的 php 檔,並存成檔案名為 info.php:
<?php phpinfo(); ?>將這個檔案上傳網站伺服器,瀏覽器輸入網址開啟 info.php 檔就會看到如下很重要的 php 環境設定。這裡可以看到 php 的版本 Version 7.1.17,以及第6行 php.ini 的位置 /etc/php/7.1/apache2/php.ini。

若您的 WordPress 是在 Linux 伺服器上請用 sudo vi /etc/php/7.1/apache2/php.ini 開啟,若是桌面版可以用 gedit 進行編輯,以下列指令開啟檔案:
xhost +si:localuser:root sudo gedit /etc/php/7.1/apache2/php.ini3、upload_max_filesize 上傳最大單一檔案大小
預設為 2M,改成您想要的大小,但檔案大小限制越寬,使用者就可以上傳越大的檔案,對伺服器的空間要求就會越高,這一點必須有所取捨。
; Maximum allowed size for uploaded files. upload_max_filesize = 2M4、post_max_size POST資料量大小
預設為 8M,最好要比 upload_max_filesize 再大些。
; Maximum size of POST data that PHP will accept. ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. post_max_size = 8M5、memory_limit 記憶體限制
預設為 128M,最好要比 post_max_size 再大些。
; Maximum amount of memory a script may consume (128MB) memory_limit = 128M6、max_execution_time 最大執行時間
預設為 30秒,上傳的檔案越大,上傳需要的時間就會越長,這個執行時間就要跟著調大。
; Maximum execution time of each script, in seconds ; Note: This directive is hardcoded to 0 for the CLI SAPI max_execution_time = 307、修改完成存檔,重新啟動 apache 讓新設定生效,以下指令任一都可以:
sudo service apache2 restart
sudo /etc/init.d/apache2 restart
sudo systemctl restart apache2apache 重新啟動後就可以再到 WordPress 的媒體 --> 媒體庫 --> 新增檔案,檢查上傳檔案的大小限制是否改變了。


