Install php and phpMyAdmin on CentOS 7 and Redhat

Update the yum services/packages

sudo yum update -y

Install the lamp-mariadb10.2-php7.2 and php7.2 Amazon Linux Extras repositories to get the latest versions of the LAMP MariaDB and PHP packages for Amazon Linux 2.

amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

Install the mariadb and httpd package

yum install -y httpd mariadb-server

Start and enable the Apache web server.

systemctl start httpd
systemctl enable httpd

Create a PHP file in the Apache document root /var/www/html

echo “<?php phpinfo(); ?>” > /var/www/html/phpinfo.php

Restart the apache service and hit the url

Systemctl restart httpd

http://my.public.dns.amazonaws.com/phpinfo.php

Start the MariaDB server

systemctl start mariadb

Run mysql_secure_installation (to reset the root password)

mysql_secure_installation

Install phpMyAdmin

Install the required dependencies.

yum install php-mbstring -y

Restart Apache.

systemctl restart httpd

Restart php-fpm.

systemctl restart php-fpm

Navigate to the Apache document root at /var/www/html.

cd /var/www/html
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

Create a phpMyAdmin folder and extract the package into it with the following command.

mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C phpMyAdmin –strip-com

type the URL of your phpMyAdmin installation

http://my.public.dns.amazonaws.com/phpMyAdmin

 

Check out : How to start-stop an EC2 instance via Lambda function

Leave a Reply

Your email address will not be published. Required fields are marked *