If I struggle to find the answer to something, it must be worth a post to help out others. So, here’s where to find the
php.ini file on a standard WordPress install on Raspberry Pi.
I installed a LAMP stack and WordPress on a Raspberry Pi following these excellent instructions. The aim was to import our lab’s ELN onto a fresh WordPress install. To do this, go to the dashboard of your old WordPress and select Tools > Export from the sidebar and select All. This will download an XML file that can be used to import posts, comments, media etc. into another WordPress installation. After setting up my new WordPress on the Pi, I chose Tools > Import… and…
On a fresh install, the limit for the XML import is 2MB. So, a large XML file will not import. The following error pops up.
File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.
It’s just a matter of editing the
php.ini file. But where is it?
To edit it do
sudo nano /etc/php/7.3/apache2/php.ini
and then ctrl+W to find the parameters that need changing, I went for:
upload_max_filesize = 128M post_max_size = 128M
ctrl+X and Y to save. Then you need to restart apache2 with
sudo service apache2 restart or perform a reboot.
The wrong answers
- There is no
php.inifile created by a WordPress installationand there are plenty of posts out there which tell you to create one in
wp-contentor even in root folder (
/var/www/html/). This did not work for me.
php.inion the command line. Over ssh, you can do
php -i | grep iniand this will tell you which
php.inifile is being used on the command line. I got
/etc/php/7.3/cli/php.inibut editing this did not work.
- Many answers on the web refer to other types of installations. My answer above works for WordPress on a Raspberry Pi LAMP stack. If you are running windows or at a webhost, the answer maybe different.
How did I find the php.ini file? I made a file called
/var/www/html/ that said
<?php phpinfo(); ?>
And then in a browser, I went to
http://myipaddress/temp.php where myipaddress is the ip of my Raspberry Pi that runs WordPress. The browser shows a table with lots of info. Look for Loaded Configuration File and you will see
/etc/php/7.3/apache2/php.ini further down you will see the attributes that you need to change. As you update the file and restart the service, you can refresh this page to check your settings have taken hold.
This post is part of a series of tips.