Created
July 26, 2019 12:09
-
-
Save NirajVisana/48d14fece5057b15788f7a53b8bcbb11 to your computer and use it in GitHub Desktop.
Amazon Linux 2 AMI EC2 - LAMP Configuration Best Practice Script - PHP , Apache , UserGroup , mariadb , PhpMyAdmin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum -y install expect | |
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2 | |
yum install -y httpd mariadb-server | |
systemctl start httpd | |
systemctl enable httpd | |
usermod -a -G apache ec2-user | |
chown -R ec2-user:apache /var/www | |
chmod 2775 /var/www | |
find /var/www -type d -exec chmod 2775 {} \; | |
find /var/www -type f -exec chmod 0664 {} \; | |
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php | |
sudo systemctl start mariadb | |
#mysql_install | |
SECURE_MYSQL=$(expect -c " | |
set timeout 10 | |
spawn sudo mysql_secure_installation | |
expect \"Enter current password for root (enter for none):\" | |
send \"\r\" | |
expect \"Change the root password?\" | |
send \"y\r\" | |
expect \"New password:\" | |
send \"root\r\" | |
expect \"Re-enter new password:\" | |
send \"root\r\" | |
expect \"Remove anonymous users?\" | |
send \"y\r\" | |
expect \"Disallow root login remotely?\" | |
send \"y\r\" | |
expect \"Remove test database and access to it?\" | |
send \"y\r\" | |
expect \"Reload privilege tables now?\" | |
send \"y\r\" | |
expect eof | |
") | |
echo "$SECURE_MYSQL" | |
sudo systemctl stop mariadb | |
sudo systemctl enable mariadb | |
# php my admin install | |
sudo yum install php-mbstring -y | |
sudo systemctl restart httpd | |
sudo systemctl restart php-fpm | |
cd /var/www/html | |
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz | |
mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin --strip-components 1 | |
rm phpMyAdmin-latest-all-languages.tar.gz | |
sudo systemctl start mariadb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PhpMyAdmin Password By default is :
Username: root
Password: root
Link to open phpMyAdmin will be:
{Your Server Ip or Domain Name}/phpMyAdmin