Skip to content

Instantly share code, notes, and snippets.

@prethiee
Last active August 3, 2019 14:12
Show Gist options
  • Save prethiee/27026c2e71ad1ef176c003dfe9c114cf to your computer and use it in GitHub Desktop.
Save prethiee/27026c2e71ad1ef176c003dfe9c114cf to your computer and use it in GitHub Desktop.
LAMP server installation on Ubuntu step by step guide
Install four packages to install a fully functioning LAMP stack.
1.Apache
2.MySQL
3.PHP
4.phpMyAdmin
STEP 1:
Switching to the root user
sudo su -
Get the current updates
apt-get update && apt-get upgrade -y
STEP 2:
Install Apache2
apt-get install apache2 -y
Verifying if the package is installed
dpkg -l apache2
Check the apache2 installation status navigate to http://localhost
STEP 3:
Install php
apt-get install libapache2-mod-php php -y
Verifying if the package is installed
dpkg -l php
Restart the apache2 service
systemctl restart apache2
To test whether PHP is working fine create a file under
Document Root of apache i.e. “/var/www/html” and then enter to check PHP information.
Create a file
atom /var/www/html/file.php
Enter this code in this file i.e
<?php
echo phpinfo();
?>
Check through by entering the “http://localhost/file.php”
STEP 4:
Install MySQL packages
apt-get install mysql-server -y
Verifying if the package is installed
dpkg -l mysql-server
Check if mysql-server is working properly by creating a database
login mysql-server as a user root
mysql -u root -p
To create a database
create database usersdb;
Check if the database is listed
show databases;
STEP 5:
Install PHPMyAdmin packages
apt-get install phpmyadmin -y
Select apache2 and then press OK to proceed the installation process
Verifying if the package is installed
dpkg -l phpmyadmin
STEP 6:
Configure “php.ini” and “apache.conf” file.
edit the “php.ini”, by atom /etc/php/7.2/apache2/php.ini set
max_execution_time = 600
memory_limit = 2048M
edit the “apache2.conf” by atom /etc/apache2/apache2.conf
Go to the end of the configuration file and add the below line
Include /etc/phpmyadmin/apache.conf
Restart apache
/etc/init.d/apache2 restart
ERROR: The requested URL /phpmyadmin was not found on this server.
MySQL 5.7 changed the secure model: now MySQL root login requires a sudo.
I.e., phpMyAdmin will be not able to use root credentials.
The simplest, safest and permanent solution will be to create a new user and grant required privileges.
1. Connect to mysql
mysql --user=root mysql
2. Create a user for phpMyAdmin
Run the following commands (replacing some_pass by the desired password):
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
If phpMyAdmin is connecting to localhost, this should be enough.
3. Optional and unsafe: allow remote connections
Remember: allow a remote user to have all privileges is a security concern and this is not required in most cases.
With this in mind, if you want this user to have the same privileges during remote connections, additionally run (replacing some_pass by the password used in Step #2):
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4. Update phpMyAdmin
Using sudo, edit /etc/dbconfig-common/phpmyadmin.conf file
updating user/password values in the following sections
(replacing some_pass by the password used in Step #2):
# dbc_dbuser: database user
# the name of the user whom we will use to connect to the database.
dbc_dbuser='phpmyadmin'
# dbc_dbpass: database user password
# the password to use with the above username when connecting
# to a database, if one is required
dbc_dbpass='some_pass'
Open Phpmyadmin web access by using URL “http://localhost/phpmyadmin”
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment