问题
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
回答1:
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.
回答2:
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
回答3:
Up to MAC OS Catalina this one-liner works:
lsof -Pni4 | grep LISTEN | grep php
Output:
php-fpm 93649 asrar 9u IPv4 0xd7c340d64c780f97 0t0 TCP 127.0.0.1:9073 (LISTEN)
php-fpm 94392 asrar 9u IPv4 0xd7c340d64c780f97 0t0 TCP 127.0.0.1:9073 (LISTEN)
php-fpm 94393 asrar 9u IPv4 0xd7c340d64c780f97 0t0 TCP 127.0.0.1:9073 (LISTEN)
来源:https://stackoverflow.com/questions/48033668/where-is-php-fpm-getting-its-config-values-on-osx