Showing posts with label LAMP. Show all posts
Showing posts with label LAMP. Show all posts

Monday, 8 April 2019

How to Install phpMyAdmin on LAMP server by Raj Gupta

phpMyAdmin is a web-based database management tool that we can use to view and edit the MySQL databases on our EC2 instance.



1. Install the required dependencies
[root@ip-172-31-95-205 ~]# sudo yum install php-mbstring -y

2. Restart Apache.
[root@ip-172-31-95-205 ~]# sudo systemctl restart httpd

3. Restart php-fpm.
[root@ip-172-31-95-205 ~]# sudo systemctl restart php-fpm

4. Now go to Apache document root at /var/www/html.
[root@ip-172-31-95-205 ~]# cd /var/www/html

5. Now download the required package from  https://www.phpmyadmin.net/downloads
[root@ip-172-31-95-205 html]# wget https://files.phpmyadmin.net/phpMyAdmin/4.8.5/phpMyAdmin-4.8.5-all-languages.zip

6. Now unzip the downloaded file
[root@ip-172-31-95-205 html]#unzip phpMyAdmin-4.8.5-all-languages.zip
[root@ip-172-31-95-205 html]# ls
phpinfo.php  phpMyAdmin-4.8.5-all-languages  phpMyAdmin-4.8.5-all-languages.zip

7. Now rename the unzip file name phpMyAdmin-4.8.5-all-languages to phpMyAdmin
[root@ip-172-31-95-205 html]# mv phpMyAdmin-4.8.5-all-languages phpMyAdmin

8. If the MySQL server is not running, start it now
[root@ip-172-31-95-205 html]# sudo systemctl start mariadb

9. In a web browser, give the below URL

http://100.26.104.220/phpMyAdmin

you will get output like below


10. Now enter Username and password of your MySQL database then click on Go

In my case Username is root and password is raj123456



Now we get the GUI mode of our database,
We are able to perform all the action on our database by using this GUI screen.


How to Secure the LAMP Server Database by Raj Gupta

The default installation of the MySQL(MariaDB) server has several features that are great for testing and development, but they should be disabled or removed for production servers. The mysql_secure_installation command walks you through the process of setting a root password and removing the insecure features from your installation.



In my case we using MariaDB(a community-developed fork of MySQL)

1. Start the MariaDB server.
[root@ip-172-31-95-205 ~]# sudo systemctl start mariadb

2. Run mysql_secure_installation.
[root@ip-172-31-95-205 ~]# sudo mysql_secure_installation

Enter current password for root (enter for none):    ---->Just press enter to set new password

Set root password? [Y/n] y      ------> give y to set new password
New password:                    -------> Enter your new password
Re-enter new password:       ------->reenter your new password
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

If we've completed all of the above steps, our MariaDB installation should now be secure.


How to Install a LAMP Web Server on Amazon Linux 2 by Raj Gupta

We can use LAMP(Linux, Apache, Mysql, and PHP) server to host a static website or deploy a dynamic PHP application that reads and writes information to a database.



We are going to use:-

L  --> Amazon Linux 2
A --> Apache
M --> MariaDB (a community-developed fork of MySQL)
P --> PHP 7.2

We assumes that we have already launched a new instance using Amazon Linux 2, that is reachable from the internet. We must also have configured our security group to allow SSH (port 22), HTTP (port 80), and HTTPS (port 443) connect.



Now logging into our EC2 server and run the below command

1. Update of system.
[root@ip-172-31-95-205 ~]# yum update -y

2. Now install the required repositories for LAMP
[root@ip-172-31-95-205 ~]# sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

3.Now install the Apache web server, MariaDB, and PHP software required for LAMP
[root@ip-172-31-95-205 ~]#  sudo yum install -y httpd mariadb-server

4.Start the Apache web server.
[root@ip-172-31-95-205 ~]# sudo systemctl start httpd

5.Use the systemctl command to configure the Apache web server to start at each system boot.
[root@ip-172-31-95-205 ~]# sudo systemctl enable httpd

6.We can verify that httpd is on by running the following command:
[root@ip-172-31-95-205 ~]# sudo systemctl is-enabled httpd

Now To test web server copy the public IP of EC2 and past in browser.



Now To test our LAMP server

Create a PHP file in the Apache document root
[root@ip-172-31-95-205 ~]# echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

Now in Browser past the below
http://100.26.104.220/phpinfo.php



Now our server is ready for host a static website or deploy a dynamic PHP application.