Preparation for Amazon LAMP
The OpenVPN on Amazon Linux AMI is a good place to start in preping the L for the AMP part of the lamp stack.
The Order of Things with Amazon Linux AMI
Amazon Linux AMI is a bit picky about the order of things. Otherwise there will be dependency conflicts, which is a rife problem. Also, make sure to disable (at least temporarily) other repositories, otherwise there can be even more dependency conflicts.
Here is a handy script to ensure that an upgrade (or fresh install) will go well, starting with Apache httpd, php, and ssl:
service httpd stop yum -y erase httpd httpd-tools apr apr-util yum -y remove php* yum -y install php56 yum -y install php56-xml php56-xmlrpc php56-soap php56-gd php56-mbstring yum -y install php56-cli php56-common php56-pdo yum -y install php56-mysqlnd yum -y install php56-opcache yum -y install mod24_ssl sed -i -e 's/SSLMutex/Mutex/g' /etc/httpd/conf.d/ssl.conf service httpd start service httpd restart
... MORE ...
- more stuff
... MORE ...
MySQL 5.6 vs. MySQL 5.7
As of mid-July, 2017 there are two main options for MySQL: version 5.6 or version 5.7. MySQL 5.6 is available from the AMI repository, but 5.7 only from Oracle's community repository. Many people have complained about this, as they well should. MariaDB 10.x is a competitor, but without much adoption. The speed and functionality improvements of 5.7 make it the desired distribution release.
The issue with the community repository is that it is unclear which distribution to use on Amazon Linux AMI. The standard redhat and fedora distributions don't work because they assume systemd (e.g., RHEL/CentOS 7.x). Some sources suggest using the generic linux distribution. Another option is the RHEL/CentOS 6.x build. Both seem viable, as long as 7.x repositories and distributions are disabled.
RDS with MySQL and Aurora
Besides installing and configuring a database on an EC2 or Lightsail instance (same thing), there are other Amazon database server options. The Amazon Relaltional Database Service (RDS), supports multiple engines including:
Note that along with these there are other options such as nosql, redis, etc., and also various caching options.
For a basic MySQL installation (not on RDS, a separate database server), installing via a yum repository makes a shortcut.
MySQL 5.7 on Amazon Linux AMI standard installation
Install some new dependencies, if not present:
yum -y install libaio yum -y install numactl
Download the repository (see latest version numbers here):
wget http://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm yum -y localinstall mysql57-community-release-el6-11.noarch.rpm
Check to see if repo is installed, which ones are installed, and which available:
yum repolist | grep mysql
Read more about installing and enabling these MySQL repositories.
Run the installation command, which will also install various common, libs, client, and server packages.
yum -y install mysql-community-server
Start the service
service mysqld start
Grep the error log which will have the generated password
grep 'temporary password' /var/log/mysqld.log
Login with that password
mysql –uroot –p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
Check to see if the password is hashed in the database, and also the version of MySQL installed.
select user,host,authentication_string from mysql.user; select @@version,@@basedir,@@datadir;