How to install LAMP Stack in Linux Mint

To install LAMP Stack in Linux Mint

LAMP stands for Linux, Apache, MySQL & PHP. In this article we will learn how to install LAMP stack in Linux Mint.

To install Apache

Run the following command to install the Apache services.

linuxhelp Desktop # apt-get install apache2 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...


Open your web browser and navigate to http://localhost/ or http://< IP_address> /

To install MariaDB

Run the following command to install MariaDB.

linuxhelp Desktop # apt-get install mariadb-server mariadb-client 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Setting up mariadb-client (5.5.49-1ubuntu0.14.04.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up mariadb-server (5.5.49-1ubuntu0.14.04.1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
During installation set the root user password
Adjust other settings in Mysql
mysql_secure_installation 
/usr/bin/mysql_secure_installation: 379: /usr/bin/mysql_secure_installation: find_mysql_client: not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
All done!  If you' ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!


Once MariaDB database is installed, login by using the following command.

linuxhelp Desktop # mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 42
Server version: 5.5.49-MariaDB-1ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.
MariaDB [(none)]>  exit
Bye

To install PHP

Run the following command to install the PHP.

linuxhelp Desktop # apt-get install php5 php5-mysql php5-cli php5-curl php5-gd php5-mcrypt 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Setting up php5-json (1.3.2-2build1) ...
php5_invoke: Enable module json for cli SAPI
php5_invoke: Enable module json for apache2 SAPI


Create test PHP file to check whether php is working with apache or not.

linuxhelp Desktop # nano /var/www/html/phpinfo.php 
Add the following line to the file

< ?php phpinfo()  ?> 

Save and exit the file
Restart apache web server by running the following command.

linuxhelp Desktop # service apache2 restart 
 * Restarting web server apache2


Open your web browser and navigate to http://localhost/phpinfo.php or http://< IP_address> /phpinfo.php

To install phpMyAdmin

Run the following command to install phpmyadmin.

linuxhelp Desktop # apt-get install phpmyadmin &ndash y 



Reading package lists... Done
Building dependency tree
Reading state information... Done
&hellip 
&hellip 
populating database via sql... done.
dbconfig-common: flushing administrative password
apache2_invoke: Enable configuration phpmyadmin
* Reloading web server apache2


Open your web browser and navigate to http://localhost/phpmyadmin or http://< IP_address> /phpmyadmin


Tag : LAMP
FAQ
Q
What is SQL Injection and how do you deal with that?
A
SQL injection is a technique utilized by hackers to get access into your database by using malicious SQL statements. Using this, anyone can gain complete access to your database without any authorization or permission.
Q
How Can you increase the execution time of a php script?
A
Yes, we can use the max_execution_time variable to set the desired time you needed for executing a php script.
Q
State how can you take a backup of the whole database in MySQL?
A
You can use the command line utility to take a backup of all the mysql table or a specific mysql table easily with the following:



mysqldump –-user [user_name] –-password=[password] [database_name] > [dump_file_name]
Q
How to destroy a session variable?
A
To destroy Session_unregister() Unregister a global variable from the current session
Q
How can I install two software at the same time?
A
Yes, you can choose several applications but it gets installed one by one.