Install LAMP stack on Debian

LAMP stack is used for hosting Websites and Apps. LAMP stack is a set of packages such as Linux, Apache, MySQL, and PHP. In this tutorial, you are going to learn How to install LAMP stack on Debian.

Prerequisites

Before you start to install LAMP stack on Debian 9. You must have the non-root user account on your server/desktop with sudo privileges.

1. Install Apache

Update the apt package manager index by running following command

sudo apt update

Now install Apache web server by typing following command

sudo apt install apache2

Confirm the installation of Apache by using the following command

sudo systemctl status apache2

If you have UFW firewall enabled then you should open port 80 for HTTP and 443 for HTTPS to Apache Web Server. Enter the following commands to enable ports.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Now you can verify your Apache installation by visiting http://YOUR_DOMAIN_NAME/ or http://localhost/

2. Install MariaDB

Update apt package manager index by typing following command

sudo apt update

Now you can install MariaDB by running following command

sudo apt install mariadb-server mariadb-client

Check the status and confirm installation by typing following command

sudo systemctl status apache2

To secure MariaDB run following command.

sudo mysql_secure_installation

Once you execute above command you will be asked to enter current password (Press ENTER for none) then you will be asked following questions, enter y for following questions:

  • Set root password? : y
  • Remove anonymous users? : y
  • Disallow root login remotely? : y
  • Remove test database and access to it? : y
  • Reload privilege tables now? : y

3. Install PHP

To install PHP you should first update package manager index. Update apt package manager index by typing

sudo apt update

Install PHP and some of its common extensions by typing

sudo apt install php php-common php-mysql php-gd php-cli

After installing PHP you can confirm installtion by creating info.php file. Run following command to create info.php file.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now visit http://YOUR_DOMAIN_NAME/info.php or http://localhost/info.php in your browser to confirm installation.

Conclusion

You have successfully learned how to install LAMP stack on Debian 9. If you have any queries regarding this please don’t forget to comment below.

Install phpMyAdmin on CentOS 7

phpMyAdmin is one of the best web interface based database management tool for MySQL. Using phpMyAdmin users can interact with the MySQL database easily. It provides the most useful functions to interact with the MySQL databases. In this tutorial, you will learn how to install phpMyAdmin on CentOS 7.

Prerequisites

1. Before you start installing phpMyAdmin on CentOS 7. You must have the non-root user account on your server with sudo privileges.

2. Make it sure that LAMP stack is installed on the server. If you have not installed it please use the following link to install LAMP: How to install LAMP stack on CentOS 7

1. Install phpMyAdmin on CentOS 7

phpMyAdmin is not available in CentOS core repositories so you will need to add EPEL reposiory by running following command

sudo yum install epel-release

Now you can install phpMyAdmin by typing following command. It will also install all the dependencies required.

sudo yum install phpmyadmin

2. Configure phpMyAdmin

As you are going to access phpMyAdmin from the remote location you will need to configure some settings. The configuration file for apache created during installation. By default, all connections are denied except localhost so you will need to modify config file and add allowed IP Addresses.

To get your IP Address enter following command in terminal.

curl ipinfo.io/ip

Enter following command to edit configuration file.

sudo nano /etc/httpd/conf.d/phpMyAdmin.conf

Replace Require ip 127.0.0.1 with Require ip YOUR_IP_ADDRESS

Example is given in following code.

# Apache 2.4
<RequireAny>
    Require ip 192.168.43.103 Require ip ::1 </RequireAny>

Now restart Apache By entering following command.

sudo systemctl restart httpd

Now you can login to phpMyAdmin by going to following link https://YOUR_DOMAIN_NAME/phpmyadmin or on your desktop http://127.0.0.1/phpmyadmin/.

NOTE : Remember you should know username and password for database. if you don’t know follow next step and create a user with permissions.

Install phpMyAdmin on CentOS - Login to phpMyAdmin
Install phpMyAdmin on CentOS – Login to phpMyAdmin

3. Create Database User (Optional)

Open MySQL shell by typing following command

sudo mysql

Create a new user by typing following command

CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';

Grant all permissions to the created user by typing

GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' WITH GRANT OPTION;

Exit MySQL shell by typing

exit;

Now you can login to phpMyAdmin by going to following link https://YOUR_DOMAIN_NAME/phpmyadmin or on your desktop http://127.0.0.1/phpmyadmin/.

Conclusion

You have successfully installed phpMyAdmin on CentOS 7. If you have any queries regarding this please don’t forget to comment below.

Install phpMyAdmin on Debian

phpMyAdmin is a database management tool for MySQL which comes with web interface. By using phpMyAdmin users can interact with MySQL easily. I also provides most useful functions to interact with the MySQL databases. This tutorial outlines how to install phpMyAdmin on Debian 9.

Prerequisites

1. Before you start installing phpMyAdmin on Debian 9. You must have the non-root user account on your server/desktop with sudo privileges.

2. Make it sure that LAMP stack is installed on the server. If you have not installed it please use the following link to install How to install LAMP stack on Debian 9.

Install phpMyAdmin on Ubuntu

First, you will need to update apt package manager index then you will install and configure phpMyAdmin on Ubuntu.

Update apt package manager index by running following command.

sudo apt update

Now install phpMyAdmin by typing following command in terminal, it will also install required dependencies for phpMyAdmin.

sudo apt install phpmyadmin php-mbstring php-gettext

You will be asked for basic configuration for phpMyAdmin. First, you will need to select apache as web server. Select Apache and click OK.

Install phpMyAdmin on Debian - select web server
Install phpMyAdmin on Debian – select web server

Now it will ask you to configure the database for phpMyAdmin. Select YES and press Enter to continue.

Install phpMyAdmin on Debian - configuare database for phpmyadmin
Install phpMyAdmin on Debian – configure database for phpmyadmin

Now you will be prompted for setting the password. Enter the password and click OK to continue.

Install phpMyAdmin on Debian - Enter password for phpMyAdmin
Install phpMyAdmin on Debian – Enter password for phpMyAdmin

Now enter the following command to enable php-mbstring extension

sudo phpenmod php-mbstring

Restart apache2 by typing following command

sudo systemctl restart apache2

Configure phpMyAdmin

Apache configuration file will be created at /etc/phpmyadmin/apache.conf. You can edit configuration file.

Now check if soft link is created at /etc/apache2/conf-enabled/phpmyadmin.conf. If not created by default then please create by typing following.

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf

Now enter following

sudo a2enconf phpmyadmin

After executing above entries please type following in terminal to restart Apache service

sudo systemctl restart apache2

Now you can login to phpMyAdmin by going to following link https://YOUR_DOMAIN_NAME/phpmyadmin or on your desktop http://127.0.0.1/phpmyadmin/

URL not found error (Optional)

If you dont get any error then please drop this step and If you get http://127.0.0.1/phpmyadmin/ this URL not found error then do following things

Enter following command to edit Apache configuration file.

sudo -H gedit /etc/apache2/apache2.conf

Now add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

Then restart apache server by typing.

sudo systemctl restart apache2

Now you can login to phpMyAdmin by going to following link https://YOUR_DOMAIN_NAME/phpmyadmin or on your desktop http://127.0.0.1/phpmyadmin/

Create Database User

Open MySQL shell by typing following command

sudo mysql

Create a new user by typing following command

CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';

Grant all permissions to the created user by typing

GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' WITH GRANT OPTION;

Exit MySQL shell by typing

exit;

Now you can login with created users credentials and access phpMyAdmin

Install phpMyAdmin on Debian - Login to phpMyAdmin
Install phpMyAdmin on Debian – Login to phpMyAdmin

Conclusion

In this tutorial you have learned how to install phpMyAdmin on Debian 9. If You have any queries regarding this please comment below.

Migrate MySQL database between two servers

Many times we need to clone/transfer database from one server to another. Whenever we are moving projects to new server from old server we need to copy files between to servers. SCP (Secure Copy) command is used to transfer files between two servers. In this tutorial you are going to learn to migrate MySQL database between two servers by using SCP command.

Prerequisites

Before you start to migrate MySQL databases between two servers. You must have the non-root user account on both of your servers with sudo privileges.

Migrate Database between two servers

First you will need to backup the database then transfer it remotely to destination server and finally you will restore backup on destination server.

To backup the database enter following command.

sudo mysqldump -u root -p --opt [database_name]> [database_name].sql

Example:

sudo mysqldump -u root -p --opt test_database > test_database.sql

Copy backup file to destination server by using following command.

sudo scp [database_name].sql [user_name]@[server_name]:path/on/destination/

Example:

sudo scp test_database.sql [email protected]:/temp/backup/

Import backup file on destination server.

sudo mysql -u root -p database_name < /path/to/database_name.sql

Example:

sudo mysql -u root -p test_database < /temp/backup/test_database.sql

Useful Commands

To backup database on remote server using port and host. Use following command.

sudo mysqldump -P [port]-h [host]-u [user_name]-p [database_name]> database_name.sql

To backup multiple databases, Use following command

sudo mysqldump -u [user_name]-p --databases [database_name1] [database_name2] > databases.sql

To import multiple databases on destination server.

sudo mysql -u root -p < databases.sql

Backup all the databases, enter following command.

sudo mysqldump -u [user_name]-p --all-databases > databases.sql

When you need to backup specific database tables then use following command.

sudo mysqldump -u [user_name]-p [database_name][table1] [table2] > database_name.sql

Conclusion

You have successfully learned to migrate MySQL databases between two servers by using SCP command. If you have any queries regarding this then dont forget to comment bellow.

Install phpMyAdmin on Ubuntu

phpMyAdmin is a web interface based database management tool for MySQL. Using phpMyAdmin users can interact with MySQL easily. phpMyAdmin provides most useful functions to interact with the MySQL database. In this tutorial you will learn how to install phpMyAdmin on Ubuntu.

Prerequisites

1. Before you start installing phpMyAdmin on Ubuntu 18.04. You must have the non-root user account on your server/desktop with sudo privileges.

2. Make it sure that LAMP stack is installed on the server. If you have not installed it please use the following link to install LAMP: How to install LAMP stack on Ubuntu 18.04

1. Install phpMyAdmin on Ubuntu

To start installing you need to update Ubuntu package index by using the following command

sudo apt update

Here you will install phpMyAdmin from default Ubuntu repositories. Now to install phpMyAdmin and required extensions please use the following command

sudo apt install phpmyadmin php-mbstring php-gettext

On executing above command it will ask you some questions about configuration

1. To select apache server, please press ==SPACE,TAB== and then ==ENTER==

2. When it will ask you to use ==dbconfig-common== to select database enter ==YES==.

3. Then enter the password for MySQL and complete the installation

Now you need to enable php-mbstring extension.

sudo phpenmod mbstring

Restart apache to reload all the changes done.

sudo systemctl restart apache2

2. Configure phpMyAdmin

Apache configuration file will be created at /etc/phpmyadmin/apache.conf. You can edit configuration by using your favourite text editor.

Check if soft link is created at /etc/apache2/conf-available/phpmyadmin.conf. If not created by default then please create by typing following.

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

Now enter following

sudo a2enconf phpmyadmin

After executing above entries please type following in terminal to restart Apache service

sudo a2enconf phpmyadmin

Login to phpMyAdmin, Now you can login to phpMyAdmin by going to following link https:// YOUR DOMAIN NAME /phpmyadmin.

3. URL not found error (Optional)

When you get http://127.0.0.1/phpmyadmin/ this URL not found error then do following things otherwise you can skip this step.

Enter following command to edit Apache configuration file.

sudo -H gedit /etc/apache2/apache2.conf

Now add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

Then restart apache server by typing.

sudo systemctl restart apache2

Login to phpMyAdmin by going to following link https://YOUR_DOMAIN_NAME/phpmyadmin or on your desktop http://127.0.0.1/phpmyadmin/

4. Create Database User

Open MySQL shell by typing following command.

sudo mysql

Create a new user by typing following command in the terminal.

CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password';

Grant all permissions to the created user by running following query.

GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' WITH GRANT OPTION;

Exit MySQL shell by typing

exit;

Now you can login with created users credentials and access phpMyAdmin

Install phpMyAdmin on Debian - Login to phpMyAdmin

Conclusion

In this tutorial you have learned how to install phpMyAdmin on Ubuntu 18.04. If You have any queries regarding this please comment below.