在 Ubuntu 服务器上重启 php-fpm失败

Ubuntu 服务器上修改过 PHP 配置文件后,想重启 php-fpm ,结果出现了这样的问题:

root@example:/# service php-fpm restart
php-fpm: unrecognized service

查看一下对应服务:

root@example:/# service --status-all | grep -i fpm
[ ? ]  aliyun-rdate
[ ? ]  console-setup
[ ? ]  dns-clean
[ ? ]  irqbalance
[ ? ]  killprocs
[ ? ]  kmod
[ ? ]  mysql
[ ? ]  networking
[ ? ]  ondemand
[ + ]  php5-fpm
[ + ]  php7.0-fpm
[ ? ]  pppd-dns
[ ? ]  rc.local
[ ? ]  sendsigs
[ ? ]  umountfs
[ ? ]  umountnfs.sh
[ ? ]  umountroot

原来之前的人给服务器装了两个版本的 php-fpm ,而且都不名字都不叫 php-fpm ,所以我光打个 php-fpm 系统是不认识的。

查看一下对应的 nginx 的配置文件:

root@example:/# vim /etc/nginx/sites-enabled/example.conf
1 server {
2         listen 80;
3         server_name abc.example.com;
4         root /mnt/www/example;
5         index index.php index.html;
6
7         location ~ \.php$ {
8                 fastcgi_pass unix:/run/php/php7.0-fpm.sock;
9                 fastcgi_index index.php;
10                 include fastcgi_params;
11         }
12
13         location / {
14                 if (!-e $request_filename) {
15                         rewrite ^(.*)$ /index.php?s=$1 last;
16                         break;
17                 }
18         }
19
20 }

它监听的是 php7.0-fpm , 所以只需重启这个就行:

root@example:/etc/nginx/sites-enabled# service php7.0-fpm restart
php7.0-fpm stop/waiting
php7.0-fpm start/running, process 2807
root@example:/etc/nginx/sites-enabled#
Last modification:March 14th, 2019 at 01:33 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment