XAMPP老的开机启动方式
在以前,我们希望XAMPP能够自动随服务器启动,那么请使用下面的命令来添加开机启动服务。- sudo ln -s /opt/lampp/lampp /etc/init.d/lampp
- sudo chkconfig --add lampp
XAMPP新的开机启动方式
登录系统后,切换到以下目录- cd /lib/systemd/system/
- vi /lib/systemd/system/lampp.service
- [Unit]
- Description=lampp
- After=network.target
- [Service]
- Type=forking
- ExecStart=/opt/lampp/lampp start
- ExecReload=/opt/lampp/lampp restart
- ExecStop=/opt/lampp/lampp stop
- PrivateTmp=true
- [Install]
- WantedBy=multi-user.target

编辑好了,就保存退出。用下面的命令来修改文件权限。
- chmod 754 /lib/systemd/system/lampp.service
- systemctl enable lampp.service
新老方式命令对比
| 任务 | 旧指令 | 新指令 |
| 使某服务自动启动 | chkconfig –level 3 lampp on | systemctl enable lampp.service |
| 使某服务不自动启动 | chkconfig –level 3 lampp off | systemctl disable lampp.service |
| 检查服务状态 | service lampp status | systemctl status lampp.service (服务详细信息) systemctl is-active lampp.service (仅显示是否 Active) |
| 显示所有已启动的服务 | chkconfig –list | systemctl list-units –type=service |
| 启动某服务 | service lampp start | systemctl start lampp.service |
| 停止某服务 | service lampp stop | systemctl stop lampp.service |
| 重启某服务 | service lampp restart | systemctl restart lampp.service |
- systemctl start lampp.service
- systemctl enable lampp.service
- systemctl disable lampp.service
- systemctl status lampp.service

- systemctl restart lampp.service
- systemctl list-units --type=service
评论 (0)