How to start or stop lampp or any other script on linux boot ?
If you want your lampp server to start automatically when the linux boots by accident or knowingly, create a following linux script and call it start_lampp.sh
| #!/bin/bash service httpd stop /opt/lampp/lampp restart |
Copy start_lampp.sh to /etc/init.d/:
shell> cp start_lampp.sh /etc/init.d/
Give executable permissions:
shell> chmod +x /etc/init.d/start_lampp.sh
Create a symbolic link:
shell> ln -s /etc/init.d/start_lampp.sh /etc/rc.d/rc5.d/S50start_lampp.sh
Repeat the above process for shutdown and call it shut_lampp.sh:
| #!/bin/bash /opt/lampp/lampp stop |
Copy shut_lampp.sh to /etc/init.d/:
shell> cp shut_lampp.sh /etc/init.d/
Give executable permissions:
shell> chmod +x /etc/init.d/shut_lampp.sh
Create a symbolic link:
shell> ln -s /etc/init.d/shut_lampp.sh /etc/rc.d/rc5.d/K50shut_lampp.sh
The S50 is to tell the system to start the script when it boots up, the K50 is to tell the system to shut down cleanly when you do a shut down.
The number representates in which order the script should start/shut down in. This way you have the possibility to explicity start your server after like when you started networking and other servers that is required by your server.
- geekyguy's blog
- login or register to post comments