Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is php-fpm getting its config values on osx

I'm trying to php-fpm on my osx by running:

php-fpm -t

and I get this error:

[30-Dec-2017 13:36:12] ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
[30-Dec-2017 13:36:12] ERROR: failed to post process the configuration
[30-Dec-2017 13:36:12] ERROR: FPM initialization failed

i don't have that file nor can I create it - even when using sudo:

$:/usr $ sudo mkdir var
Password:
mkdir: var: Operation not permitted

so my next big move is to find where exactly is this log file directory setup in php-fpm configuration (so that i can decide where the log file should go).. there seems to be many configuration files, so I refer to this question in finding the location of my php-fpm configuration file. so in the output of my php -i file I have this:

'--sysconfdir=/usr/local/etc/php/7.1'

and there I have the following files:

php-fpm.conf

// can't be coming from this file
// b/c this is telling me it's /usr/local/var/log/php-fpm.log

; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /usr/local/var
; Default Value: log/php-fpm.log

so where is it coming from?

also when I run this:

which php-fpm
/usr/sbin/php-fpm

note sure if it helps

like image 431
abbood Avatar asked Dec 30 '17 11:12

abbood


2 Answers

php-fpm.conf location is determined by the option

--sysconfdir=/path/to

specified when invoking $ ./confugure just before compiling php-fpm.

Usually it is /etc but may be different in your case.

Invoking $ php-fpm -i will show the options passed to configure.

Just look after Configure Command =>.

From the comments I see you have found '--sysconfdir=/private/etc' so I would look right there.


Note that you can invoke php-fpm specifying a different location for the configuration file using the -y option.

like image 132
Paolo Avatar answered Sep 27 '22 03:09

Paolo


Because you mentioned local you must be using Homebrew and so the php-fpm config file is at:

/usr/local/etc/php/7.4/php-fpm.conf

And the www pool config is at:

/usr/local/etc/php/7.4/php-fpm.d/www.conf

Note the path version number will change in the future.

You can put your own configs in the same folder as www.conf (they must end in .conf to be included). E.g. I added one that had listen = /usr/local/var/run/php-fpm.my-username.sock which I learned here so I could use a socket instead of a port for my Site virtual server.

I found these other commands useful:

To view the logs:

tail -f /usr/local/var/log/php-fpm.log

To check the user fpm was launched as:

ps aux | egrep 'php'

And be sure to start the brew service with sudo and if you accidentally start one without sudo be sure to stop it:

sudo brew services start php

like image 31
malhal Avatar answered Sep 27 '22 03:09

malhal