I have installed Laravel Valet with php70 nginx and mysql so I can work locally on WordPress. All were installed with homebrew with the exception of Valet which is installed with composer. I have everything else working including phpmyadmin and mailcatcher, but have not figured out why a .user.ini or php.ini is not working in a WordPress install. I am setting up WordFence so I need the php.ini to work.
I created php.ini and it contains:
auto_prepend_file = '/Users/user/Sites/mywp/wordfence-waf.php'
.user.ini contains:
auto_prepend_file = '/Users/user/Sites/mywp/wordfence-waf.php'
.htaccess contains:
setEnv PHPRC '/Users/user/Sites/mywp/php.ini'
When I run phpinfo() and look for auto_prepend_file, it is empty. I have already commented it out in the main php.ini (/usr/local/etc/php/7.0/php.ini), as opposed to the local one so that it is not being overwritten to my knowledge.
I can get it to work by defining sections of /usr/local/etc/php/7.0/php.ini:
[HOST=mywp.dev]
auto_prepend_file = '/Users/user/Sites/mainwp/wordfence-waf.php'
But then I have to run valet stop, and brew services stop php70 and brew services stop nginx.
Is there anyway to get local php.ini's working or at get valet start to start all services?
Probably:
Instead of /usr/local/etc/php/7.0/php.ini
Just put it in: /usr/local/etc/php/7.0/conf.d/mywp.ini
Then once you restart php it should take effect from that point forward.
Future changes/additions to that file or other files in conf.d would require a restart of php.
That does look like a better way, I will try it out.
I wasn't sure if I should open my own issue or comment here, but my issue is pretty much the same as this one.
I tried what @drbyte suggested, and it did not work. I'm trying to use the following php.ini for my phpMyAdmin installation:
date.timezone = "UTC"
; Max memory per instance
memory_limit = 128M
;The maximum size of an uploaded file.
upload_max_filesize = 112M
;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 128M
Putting it in /usr/local/etc/php/7.0/conf.d/mysql.ini (because Valet serves phpMyAdmin as mysql.dev - I am assuming from what @drbyte said above that the domain without TLD is used for these ini files) and restarting the PHP service did not change anything. Restarting the MariaDB service also didn't fix the problem.
Am I missing something?
@mikemand wrote:
Putting it in /usr/local/etc/php/7.0/conf.d/mysql.ini (because Valet serves phpMyAdmin as mysql.dev - I am assuming from what @drbyte said above that the domain without TLD is used for these ini files)
Wrong assumption. But not a fatal issue. Call it whatever you want. But it applies universally, not to a specific domain-name.
My use of mywp.ini was really just to call it something unique, and something that denotes it's "my custom configuration", where "my" would be "my" configs, and "wp" was because the original poster was wanting to set custom settings for Wordpress.
That said, putting it in /usr/local/etc/php/7.0/conf.d/mysql.ini should be fine. I haven't used 7.0 in months, but the path seems right too.
I've been using the changes from this PR to properly set memory and other configs for a long time, without issue: https://github.com/laravel/valet/pull/277/files
restarting the PHP service did not change anything
I've seen the case where the service is confused after making changes and messing with all the services, to the point where a reboot releases all the locked processes that are masking the root cause.
Will PHP automatically use *.ini files from /usr/local/php/7.*/conf.d/ or do I need to tell the main php.ini to load them?
Yes, I got the memory and size settings from #277 as well. Except I fixed the max filesize so it won't equal max post size, "just in case"™️️. (I agree with your statements about it being a dev environment and we are unlikely to hit any occasion where uploaded file size equals max post size, and thus post data overflows. Or the file will be the one to overflow; I'm not entirely sure which would win out in that case.)
I digress.
The main problem is my staging/production server(s) are UTC, whereas Valet is using my computer's timezone. Not an absolutely huge problem, but if I am debugging something with a timestamp, then things don't match up. It causes confusion and takes longer to debug.
Is there some way to set the timezone for a specific site? Maybe the site's nginx configuration? I'm just afraid an update to Valet in the future will overwrite my changes without notice and I'll be back where I started.
I will reboot and see if that works. It won't matter too much if the timezone gets changed for all my other sites, because Laravel lets me set the default timezone (and I can do the same for my homegrown sites).
Thank you for the help, @drbyte.
Yes, any *.ini files in /usr/local/etc/php/7.x/conf.d/ are auto-loaded.
That folder is also where Homebrew puts its files when you install extensions like php7-intl or php7-redis.
Putting your own *.ini file/s in that folder is the ideal way to set your own custom configurations. In theory, as long as your choice of filename doesn't match some other extension that puts files in there too, the file will be left alone unless you choose to touch it yourself.
And if you upgrade to PHP 7.1 then you can just copy the custom .ini file over to the 7.1/conf.d folder.
As for setting timezone, you can always just tell your own custom script to set its timezone before you bootstrap it.
Turns out, it wasn't PHP's problem...MariaDB was set up to use my system timezone.
I created a file at /usr/local/etc/my.cnf.d/timezone.cnf with this:
[server]
default-time-zone=+00:00
and what do you know...timestamps are correct now. Hurray.
Thanks for all your help, @drbyte.
Ha! What an adventure ;)
For what it's worth, it's always good to have both the database and PHP set to the same time zone as well ...
Cheers
Probably:
Instead of
/usr/local/etc/php/7.0/php.ini
Just put it in:/usr/local/etc/php/7.0/conf.d/mywp.iniThen once you restart php it should take effect from that point forward.
Future changes/additions to that file or other files in
conf.dwould require a restart of php.
Thank you! Because if this I finaly found that stupid file :P
in my os, I just modify this file , it works: /usr/local/etc/php/7.2/conf.d/php-memory-limits.ini
Most helpful comment
Probably:
Instead of
/usr/local/etc/php/7.0/php.iniJust put it in:
/usr/local/etc/php/7.0/conf.d/mywp.iniThen once you restart php it should take effect from that point forward.
Future changes/additions to that file or other files in
conf.dwould require a restart of php.