1、在/etc/init.d 目錄下建立lampp.sh 文件,然后添加以下内容:
#!/bin/sh
/opt/lampp/lampp start
2、修改权限:
# chmod 755 /etc/init.d/lampp.sh
3、编辑/etc/init.d/rc.local在最后一行加上: 或者 /etc/rc.local
sh /etc/init.d/lampp.sh
或者
exec /etc/init.d/lampp.sh (注:这种方法即使开机后没有登入,XAMPP还是会启动)
4、重启ubuntu
解决方案-2:
# sudo ln -s /opt/lampp/lampp /etc/init.d/lampp
# sudo update-rc.d -f lampp defaults
Ubuntu 18.04 rc.local 设置开机自启动
Ubuntu 18.04默认进程启动管理已经切换至systemd,不在使用SysV。如果想像之前一样使用/etc/rc.local设置开机自启动,请如下设置
修改rc-local.service
/lib/systemd/system/rc-local.service新增:
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
设置开机自启动rc-local
systemctl enable rc-local
创建/etc/rc.local
vi/etc/rc.local
#!/bin/bash
echo "test rc.local " > /tmp/rctest.log
新增执行权限
chmod +x /etc/rc.local