In preparation of a webserver and attached backend database migration I have started working on building an AWS base image for this purpose.
I chose RHEL 7.4 (Maipo) as it is Free Tier eligible on AWS. No hefty bills from the current host – Yay!
As the expected load won’t be too high a micro instance should be sufficient however can scale up/out later bases on demand (more on this on a later post).
Gone through the AWS Launch wizard I connected to the new Red Hat server and started installing the LAMP stack which has gone smooth and dandy up to the MySQL server install.
Upon trying to launch MySQL I ran into a problem. No matter the error was saying the unit was not found.
[ec2-user@ip~]$ sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service
Failed to start mysqld.service: Unit not found.
A quick reference check it was found that RHEL are using MariaDB as the default DB hence not finding the package as such.
Using wget managed to pull the latest repo from MySQL.com and then installed successfully replacing MariaDB.
[ec2-user@ip~]$ sudo yum install wget
[ec2-user@ip~]$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[ec2-user@ip~]$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
[ec2-user@ip~]$ sudo yum install -y mysql-server
mariadb.x86_64 1:5.5.56-2.el7 mariadb-libs.x86_64 1:5.5.56-2.el7
Only one thing remained was to start both Apache and MySQL and set them to start at boot.
[ec2-user@ip~]$ sudo systemctl enable httpd && sudo systemctl enable mysqld
[ec2-user@ip~]$ sudo systemctl start mysqld && sudo systemctl start httpd
To test Apache created a simple website in HTML using touch and vim
Once happy with the site, restarted the server and checked whether Apache and MySQL started at boot.
Both started successfully!
To bootstrap the server the following bash script can be used:
sudo yum update -y
sudo yum install -y httpd php php-mysql wget
sudo wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server
sudo systemctl enable httpd && sudo systemctl enable mysqld
sudo systemctl start mysqld && sudo systemctl start httpd
If you found this helpful leave a comment or drop me a message. Thanks!