Setting Services to Start at Boot

Last Updated At: 2025-10-16 09:54:17

Set Auto-Scaling Machines to Start Services at Boot

Use Cases

When using auto scaling to scale-out, we aim for no manual intervention throughout the entire process. Therefore, we strongly advocate for setting auto-scaling machines to automatically start services upon boot. For example:

  • httpd service
  • mysqld service
  • php-fpm service
  • tomcat service
    It only takes a minute to modify the /etc/rc.d/rc.local file to complete the settings.

Method for Setting (Taking CentOS as an example)

Step 1: Open the rc.local file

Input vim /etc/rc.d/rc.local
Keep existing content unchanged, and add new content at the end of the file.

TIPS (Advanced users may skip):
Enter i to go into vim's insert mode, then you can type the content. At this point, press the ↓ key to move to the end of the file.

Step 2: Specify the services to start

This example is to set up the websites to automatically start httpd, mysqld, php-fpm services upon server boot. Add the following codes at the end of the rc.local file:

service httpd start
service mysqld start
service php-fpm start


Save and exit. Afterwards, the websites will be accessible automatically once this server boots up. Note that different websites require different services, so customize this step according to your needs.

TIPS (Advanced users may skip):
After completing the content entry, press esc, then hold shift + press z twice to exit. That is, enter ZZ.

Step 3: Verification (optional)

Restart the server (you can restart it by entering reboot, or restart it from the console). After the server restarts, do not enter the server; instead, you can directly refresh the website's page to see if there is a response. If there is, then the setting is successful.

Step 4: Create an image based on this machine, and use this image when creating a launch configuration

This step is relatively simple. If you encounter difficulties during the process,see the following tutorials:
Creating custom image
Creating launch configuration