php在centos下作为开机启动设置
1.在系统服务目录里创建php-fpm.service文件 vi /lib/systemd/system/php-fpm.service写入以下内容(路径改成自己的)
[Unit] Description=php-fpm After=network.target [Service] Type=forking ExecStart=/usr/local/php7/sbin/php-fpm ExecStop= kill -9 php-fpm PrivateTmp=true [Install] WantedBy=multi-user.target
注意:[Service]的启动、重启、停止命令全部要求使用绝对路径
[Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3
2.测试并加入开机自启
先关闭nginx,php-fpm
使用以下命令开启 systemctl start nginx.service #如果服务是开启状态,使用此命令会启动失败。
systemctl start php-fpm.service开启成功,将服务加入开机自启 systemctl enable nginx.service #注意后面不能跟空格
systemctl enable php-fpm.service重启服务器,查看是否启动
shutdown -r now #重启systemctl list-units --
type=service #查看运行的服务