Where is php.ini file?

I have a WP problem, namley, I tried uploading a new theme in the dashboard and got this error:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

googled it, possible solutions:

however:

  1. can’t find php.ini anywhere in my computer
  2. don’t have access to edit .htaccess file… have tried before… (have been advised here on SP PHP forum to never edit this file…:wink:
  3. did what it said for wp-config.php file (added that code they say at bottom of it), but that did not solve problem (do I have to restart the server for that to work? I never turned Apache Server off and on… I don’t even need to turn it on when I restart my machine…)

when googled this it said this is a common error in WP… maybe these files should come with higher filesize limits out of the box, then, no??? :wink:

thank you…

php.ini is located in the PHP folder you installed PHP in.

1 Like

thank you for your response… my mac came with php installed… I didn’t have to install it…

I searched for it in the HD (i.e., entire computer), I didn’t find it… I don’t know where PHP is installed… so whether or not WP dashboard accepts this theme depends on this PHP config file that actually is not part of WP? hmmm…

thank you…

PS: why on earth is it so hard to find this file?

???

PS2: this is ridiculous…
https://www.google.com/search?q=php+i+can't+find+php.ini&oq=php+i+can't+find+php.ini&aqs=chrome..69i57.4305j0j7&sourceid=chrome&ie=UTF-8

Then it is within the /etc/ folder.

  • Open a Finder Window.
  • Next, right click on the Finder icon at the bottom of your Dock.
  • From the context menu, click on Go to Folder...
  • When the search bar drops down, type /etc/ into the search bar.
  • Then click on the Go button on the right corner of the search bar.
  • Once in the /etc/ folder, scroll down until you find php.ini.default.
  • Create a backup of that file by copying php.ini.default and pasting it inside /etc/. This may require your password.
  • Once you have created an extra copy of php.ini.default, go a head and rename the copy to php.ini.back.default. Again, this may require your password.
  • Once you are finished with backing up the php.ini.default file, remove the .default extension and just have php.ini. Again, this may require your password.

After this, this should allow you to use the php.ini file. Though I highly suggest you upgrade your PHP and take advantage of PHP 7.

Here is a tutorial I made on how to do so. I am planning on making more for all versions of Mac, Windows, and Linux. Even though it is listed as El Capitan, it virtually works on all Mac versions. There is only a few slight difference in things, roughly on the SSL part.

hi… thank you for your response… just as I thought, it’s not letting me edit the file, permission denied… I tried this in unix

sudo chmod 644 /etc/php.ini

but it still won’t let me…

thank you…

PS: I have always found this thing of not having access to edit files in your own computer very annoying (and slightly absurd, to put it lightly…)

I don’t know about macs, but for Windows I sometimes need to “edit as administrator” and turn off the service so that it isn’t “currently open in another program” in order to edit some files.

ok… I opened it in terminal thus:

sudo pico /etc/php.ini
(yes I use pico, it’s the only unix editor I know how to use relatively well, I hate vi…;~))

and that finally worked… but: after making the changes to php.ini shown here

namely:

upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 400M
file_uploads = On
max_execution_time = 180

I get the exact same error…

The uploaded file exceeds the upload_max_filesize directive in php.ini.

the file (WP theme) I’m trying to upload is 3.3 MB

:~((

thank you for your help…

If you’re running on your local machine, can you not just copy the file to the appropriate directory rather than using WP to upload it?

If you don’t have permissions, you’ll have to rename them in the terminal. This may take a bit since you don’t have a graphical interface to work with. Most people prefer a graphical interface. Also, that isn’t the correct permissions. 644 is not a usable permission. There are far too much things behind permissions that I don’t want to get into since this is just for solving php.ini.

Set these to be something like this

upload_max_filesize = 120M
post_max_size = 120M
memory_limit = 400M
file_uploads = On
max_execution_time = 180

Next, in the terminal, type this in

sudo apachectl restart

To make sure that it restarted without a problem, I suggest doing

sudo apachectl configtest

If there are any problems/errors, configtest will tell you what file and what line the problem is on. I usually restart my Apache after I make changes to my php.ini file and my httpd.conf file.

Run this short script:

<?php

phpinfo();

?>

With the output, scroll down to “Loaded Configuration File” and check that the copy of php.ini that you think is the one that you need to edit actually is the one that you need to edit

well, I’m learning WP, I want to learn everything properly; I looked up how to install a theme that does not appear in your dashboard when you go to change themes; this is the proper way to do it… hit “upload” button, choose file in your computer where the theme is (that I downloaded from online, it’s a zip file, you’re supposed to upload this zip file to your dashboard…) in WP, if you do “by hand” things you should do thru the interface there are more possibilities things can go wrong down the line…

but I guess you’re right, I could try that (“themes” dir in the WP site, yes? ;~)

thank you for your response…

thank you for your help… I don’t have time right now… will try this later in the evening…

thank you…

Instead of changing the PHP.ini file it is possible to temporarily increase the max_file_size and many other values using PHP ini_set.

http://php.net/manual/en/function.ini-set.php

Edit:
Check the returned ini_set(…) result to ensure the value was changed.

http://php.net/manual/en/ini.list.php

2 Likes

thank you, spaceshiptrooper I finally got it to work, BUT:

  1. when I typed sudo apachectl configtest I got this prompt:

Could not reliably determine the server's fully qualified domain name, using <myCompName>.local for ServerName

however, it still worked – I was finally able to upload my theme, HOWEVER:

it said it needs my FTP info, the WP dashboard (or CP, as some would call it), said:

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed.

but I’m only working locally!! I’m just learning WP… I don’t have any site up online, or a domain, or webhosting set… man, what a pain… well, I suppose this is for the WP forum… oh brother… I have been hand-coding (HTML, JS, CSS, PHP…) for the longest time… I’m having a hard time with WP, I hate to work with blog-editing or WYSIWYG systems, but I have to learn it in order to be able to get more freelance gigs (I’m retired now, and where I live people like to have their websites done in WP…)

ok… thank you very much for your help and to everyone who responded…

The message from configtest is from httpd.conf. it isn’t really required. It’s just telling you that the default domain isn’t set. That’s about it. It doesn’t really hurt your environment or development experience.

As for the FTP part, why don’t you just copy and paste the theme into the Themes folder? Is this message coming from a theme you already are using? If it is, then this problem resides in WordPress and not PHP.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.