Step by step guide to install LAMP server on Linux.
Use the terminal to execute these commands
sudo apt install apache2
sudo apt install mysql-server
After installation run this command to remove some dangerous defaults and lock down access to your database system.
sudo mysql_secure_installation
This will ask if you want to configure the VALIDATE PASSWORD PLUGIN
.
Answer Y
for yes, or anything else to continue without enabling.
Remove anonymous users? : Y
Disallow root login remotely? : Y
Remove test database and access to it? : Y
Reload privilege tables now? : Y
Now enter mysql
sudo mysql
View all user accounts using
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
Now, to set a new password for root user, replace 'password'
with your own password.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
run FLUSH PRIVILEGES
which tells the server to reload the grant tables and put your new changes into effect:
mysql> FLUSH PRIVILEGES;
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
Exit Mysql
mysql> exit
sudo apt install php libapache2-mod-php php-mysql
Type this command to open the dir.conf
file in a text editor with root privileges:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Now restart apache server
sudo systemctl restart apache2
sudo apt install phpmyadmin php-mbstring php-gettext
If you get any error after running above code such as:
E: Package 'phpmyadmin' has no installation candicate
Then this means your system does not have the required repository in your system, To add it run
sudo add-apt-repository ppa:phpmyadmin/ppa
sudo apt-get update
sudo apt-get install phpmyadmin
Warning: When the prompt appears, “apache2” is highlighted, but not selected. If you do not hit SPACE
to select Apache, the installer will not move the necessary files during installation.
For the server selection, choose apache2
Select Yes
when asked whether to use dbconfig-common to set up the database
You will then be asked to choose and confirm a MySQL application password for phpMyAdmin
Finally run:
sudo phpenmod mbstring
And restart the server.
If you get something like count();
error in your database, refer to this post.
Also refer article for installation.