systemctl开机自启
#cd /usr/lib/systemd/system/xxx.service
=================================================
[Unit]
Description=mysql
#Wants=依赖起他unit,弱依赖,如果是Requires,强依赖
#放在该服务启动后启动,如果是Before,则是之前
After=network-online.target
[Service]
Type=forking
#当意外中止时是否重启
#Restart=always
#在ExecStart之前执行,可以放多个
#ExecStartPre=
#服务执行的路径
ExecStart=/data0/mysql/3306/mysql start
#ExecStart后运行
#ExecStopPost=
#指明停止unit要运行的命令或脚本
ExecStop=/data0/mysql/3306/mysql stop
#指明重启unit要运行的命令或脚本
ExecReload=/data0/mysql/3306/mysql restart
User=mysql
Group=mysql
[Install]
#相当于init 3
WantedBy=multi-user.target
=============================================
[Unit]
Description=php-fpm
After=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
[Install]
WantedBy=multi-user.target
==========================
[Unit]
Description=nginx
After=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
[Install]
WantedBy=multi-user.target
==================================
systemctl enable mysql
systemctl enable php-fpm
systemctl enable nginx
systemctl start xxx.service
journalctl -u php-fpm.service