One of the solutions I found is this:
check process php5-fpm with pidfile /var/run/php5-fpm.pid
group php
start program = "/etc/init.d/php5-fpm start"
stop program = "/etc/init.d/php5-fpm stop"
if failed unixsocket /tmp/php-fpm.sock then restart
if 4 restarts within 5 cycles then timeout
depends on nginx
This does not work because the following file does not exist in my system:
/tmp/php-fpm.sock
When I run sudo find / -name *.sock I get:
/run/mysqld/mysqld.sock
/run/fail2ban/fail2ban.sock
/var/lib/php5-fpm/web2.sock
/var/lib/php5-fpm/ispconfig.sock
/var/lib/php5-fpm/apps.sock
If it helps, this is the file I change to configure how php behaves with the particular domain I use : /etc/php5/fpm/pool.d/web2.conf. So MAYBE the right file is `/var/lib/php5-fpm/web2.sock ?
This is a VPS with ubuntu 12.04 and nginx 1.4.4.
Related
I am facing a weird issue on windows machine. I am using php-cgi and nginx to run my php project. Everything works fine for a specific period of time like for example 15 to 20 hours then php-cgi and nginx both services stopped working. This happens repeatedly when I start the services again. Please check below is my bat file content.
Bat file content:
#ECHO OFF
ECHO Starting PHP FastCGI...
SET PHP_FCGI_MAX_REQUESTS=0
start C:\webserver\nginx\nginx.exe
C:\RunHiddenConsole.exe C:\webserver\php\php-cgi.exe -b 127.0.0.1:9000 -c "C:\werbserver\php.ini"
I'm trying to create a bash script that starts two processes: PHP-FPM and Nginx.
First PHP-FPM should start and once that has finished starting up (port 9000 will then be reachable for example, but there might be other means of checking it has finished starting up) the Nginx server should be started.
My current script looks like this:
#!/usr/bin/env bash
set -e
php-fpm -F &
nginx &
wait -n
But sometimes early on nginx will give me a 502 gateway error because php-fpm is not ready yet.
What's the cleanest/best way of getting this startup in order?
Regards,
Kees.
You can modify your script in this way:
#!/usr/bin/env bash
set -e
php-fpm -F && nginx
wait -n
As you can see in this answer on Unix&Linux, the && operator allows you to run the second command only if the first exited successfully.
I'm currently trying to update the "session.save_handler = files" and "session.save_path = null" to my own values but they always default to files.
In my case I have setup the php redis extensions and I would like to setup to "session.save_handler = redis" and "session.save_path = https://rediserver:6375", however, after updating the config files either updating directly on /usr/local/etc/php-fpm.d/www.conf or adding an extra .conf file to /usr/local/etc/php-fpm.d/session.conf and restarting php-fpm with "kill -USR2 1" the values are not updated when I check using php-info(); function.
Any idea what might be happing ? I'm using docker image php:7.2-fpm .
Thanks
I found the issue, I was using supervisorD to load my php-fpm therefore the command kill -USR2 1 wasn't making any effect to reload the php changes. The solution was to kill manually my php-fpm process and make supervisord start again with '"supervisorctl restart [task name]"'
I use nginx and php7.1-fpm. I want to run a background process using PHP and exec().
My short code:
<?php
exec('/usr/local/bin/program > /dev/null 2>&1');
Unfortunately after the systemd restart php7.1-fpm the program is killed.
I have tried to run with a different user than the one running the pool:
<?php
exec('sudo -u another_user /usr/local/bin/program > /dev/null 2>&1');
However, this does not solve the problem - still kills.
I can not use ssh2_connect(). How can I solve this problem?
It seems this is due to the php-fpm service being managed by the systemd.
All processes launched from php-fpm belong to its control-group and when you restart the service systemd sends the SIGTERM to all the processes in the control-group even if they are daemonized, detached and/or belong to another session.
You can check your control-groups with this command:
systemd-cgls
What I've done is to change the KillMode of the php-fpm service to process.
Just edit it's .service file:
vi /etc/systemd/system/multi-user.target.wants/php7.0-fpm.service
and change or add the line to the [Service] block:
KillMode=process
Then reload the configuration by executing:
systemctl daemon-reload
That worked for me.
References:
Can't detach child process when main process is started from systemd
http://man7.org/linux/man-pages/man5/systemd.kill.5.html
What would be wonderful would be a command (similar to setsid) that allowed to launch a process and detach from control-group but I haven't been able to find it.
Stopping XAMPP for Linux 1.8.3-3...
XAMPP: Stopping Apache...fail.
apachectl returned 1.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
fail.
kill returned 1
i am getting the above error while stopping the apache please help me and i am using ubuntu
I had the exact same issue. Since you are getting an error stopping Apache and ProFTP only, you need to delete these two files:
/opt/lampp/logs/httpd.pid
and
/opt/lampp/var/proftpd.pid
When you delete the httpd.pid, Apache is automatically killed. And similar happens when you remove the proftpd.pid.
So now you can go ahead and restart the server and new fresh files will be created. :)
Delete the following files:
$XAMPP_ROOT/logs/httpd.pid
$XAMPP_ROOT/var/mysql/$(hostname).pid
$XAMPP_ROOT/var/proftpd.pid
When runningsudo /opt/lampp/lampp stop I get
Stopping XAMPP for Linux 5.6.30-1…
XAMPP: Stopping Apache…fail.
apachectl returned 1.
XAMPP: Stopping MySQL…ok.
XAMPP: Stopping ProFTPD…ok.
And when I open my browser localhost it’s not working
My solution it’s work for me.
run :
sudo rm -f /opt/lampp/logs/httpd.pid
Now restart xampp. You should not face this problem again.
Looks like the script is trying to stop the ProFTPD service but it is not running. The line:
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Indicates that a kill command was issued with malformed or missing parameters. If you are not using ProFTPD, you can remove all instances of it in the startup and termination scripts.
The script that you are running is not only trying to stop the apache service but rather all the services that are related to XAMPP -
X is the platform - could be windows, linux or mac
Apache
MySql
PhpMyAdmin
Php