php-fpm作为Centos 7上的服务

时间:2016-03-16 10:28:15

标签: php centos7 systemd php-7

php 7源自

尝试时

systemctl enable php-fpm.service

获取

The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).

尝试时

chkconfig --levels 235 php-fpm on

获取相同的日志:)

更新

不知何故,我设法从chkconfig开始,但我不记得如何。重新安装操作系统并使用PHP 7.0.6-dev

2 个答案:

答案 0 :(得分:2)

由于您正在编译自己的PHP,需要创建单元/服务,您可以通过chkconfig执行此操作,或者您可以尝试遵循一些指导原则,我建议您这样做:

https://www.howtoforge.com/tutorial/how-to-install-php-7-on-debian/

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html

第一篇教程中的示例文件:

[Unit]
Description=The PHP 7 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php-7.0.3/var/run/php-fpm.pid
ExecStart=/opt/php-7.0.3/sbin/php-fpm --nodaemonize --fpm-config /opt/php-7.0.3/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

我看到更新后你已经解决了这个问题,但我会把它留在这里,因为它可以帮助更多人!

答案 1 :(得分:0)

现在,至于php 7.3,我在构建php后使用了这种方法:

1. cp /path-to-php-src/sapi/fpm/php-fpm.service /etc/systemd/system/php-fpm.service
2. systemctl enable php-fpm.service

文件内容类似于Renato Mefi的答案