Linux设置PHP开机自动启动

PHP 阅读: 93

设置开机启动

打开:

vim /etc/systemd/system/php-fpm.service

写入下面内容:

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

[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target

添加到开机启动:

systemctl enable php-fpm.service

下面就可以使用systemctl命令管理php-fpm了:

# 启动php-fpm:
systemctl start php-fpm.service

# 重启php-fpm:
systemctl reload php-fpm.service

# 停止php-fpm:
systemctl stop php-fpm.service

添加php到环境变量

打开文件:

vim /etc/profile

末尾添加:

PATH=$PATH:/usr/local/php/bin:/usr/local/php/sbin:
export PATH

使配置生效:

source /etc/profile

版权声明:本文为博主原创文章,转载需注明来自: 洛洛の空间