Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto start web services when starting an Amazon EC2 instance?

How do I set the httpd and mysqld services to start automatically upon booting an amazon-ec2 instance?

Currently I have to start them manually by connecting to the instance via ssh and running sudo service httpd start and sudo service mysqld start.

like image 400
user655334 Avatar asked Mar 15 '11 13:03

user655334


People also ask

How do you launch the Web server using user data and EC2 instance?

Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . Choose EC2 Dashboard, and then choose Launch instance, as shown following. Make sure you have opted into the new launch experience. Under Name and tags, for Name, enter tutorial-web-server .


1 Answers

Rather than starting over with a new AMI, you could just issue the following commands on an Amazon Linux EC2 instance...

sudo chkconfig mysqld on sudo chkconfig httpd on 

You can check the settings before & after enabling these services to start on boot using the following commands...

sudo chkconfig --list mysqld sudo chkconfig --list httpd 

See all services using just...

sudo chkconfig --list 

NOTE: If you are having any trouble with chkconfig being in root's path, you can try specifying the full path like this...

sudo /sbin/chkconfig mysqld on sudo /sbin/chkconfig httpd on 
like image 124
QuasarDJ Avatar answered Sep 21 '22 21:09

QuasarDJ