AMP AMP

How to Install LAMP on Popos

To Install LAMP on PopOS

LAMP Stands for Linux, Apache, MySQL, MariaDB, MongoDB, PHP, PERL, PYTHON, PhpMyAdmin. LAMP is a server configuration for various web applications. It helps in running servers and dynamic websites. It is a web development platform that uses Linux operating system, Apache web server, MySQL relational database management system and PHP scripting language.

Installation

First, let' s install the Apache using the following command.

root@linuxhelp:~# apt-get install apache2 -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
0 upgraded, 8 newly installed, 0 to remove and 150 not upgraded.
Need to get 1,503 kB of archives.
After this operation, 6,175 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu artful/main amd64 libapr1 amd64 1.6.2-1 [90.9 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu artful/main amd64 libaprutil1 amd64 1.6.0-2 [84.2 kB]

.
.
.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service ? /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for libc-bin (2.26-0ubuntu2.1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (234-2ubuntu12.1) ...
Processing triggers for ufw (0.35-5) ...

Start and enable the Apache web server as follows.

root@linuxhelp:~# systemctl start apache2
root@linuxhelp:~# systemctl enable apache2
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2


After installing you can verify the Apache web server by navigating to the following URL http://localhost If you see the following page, Apache has been successfully installed on your machine.

After installing Apache web server we are going to install MariaDB database as follows.

root@linuxhelp:~# apt-get install mariadb-server mariadb-client -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  galera-3 gawk libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libjemalloc1 libmysqlclient20
  libsigsegv2 libterm-readkey-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
  mariadb-server-10.1 mariadb-server-core-10.1 mysql-common socat
Suggested packages:
  gawk-doc libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test
  tinyca
The following NEW packages will be installed:
  galera-3 gawk libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libjemalloc1 libmysqlclient20
  libsigsegv2 libterm-readkey-perl mariadb-client mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
  mariadb-server mariadb-server-10.1 mariadb-server-core-10.1 mysql-common socat
0 upgraded, 19 newly installed, 0 to remove and 150 not upgraded.
Need to get 25.2 MB of archives.
After this operation, 191 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu artful/main amd64 libsigsegv2 amd64 2.11-1 [13.2 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu artful/main amd64 gawk amd64 1:4.1.4+dfsg-1 [401 kB]
.
.
.
Setting up mariadb-server (10.1.30-0ubuntu0.17.10.1) ...
Processing triggers for libc-bin (2.26-0ubuntu2.1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (234-2ubuntu12.1) ...

Start and enable MariaDB service as follows.

root@linuxhelp:~# systemctl start mariadb &  systemctl enable mariadb

Next, secure the database by executing mysql_secure_installation.

root@linuxhelp:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we' ll need the current
password for the root user.  If you' ve just installed MariaDB, and
you haven' t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from ' localhost' .  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
 ... Success!

By default, MariaDB comes with a database named ' test'  that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

All done!  If you' ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[1]+  Done                    systemctl start mariadb

To verify the functionality of Maria DB database login as follows.

root@linuxhelp:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 10
Server version: 10.1.30-MariaDB-0ubuntu0.17.10.1 Ubuntu 17.10

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> 
MariaDB [(none)]>  exit
Bye

After installing MariaDB database, we are going to install PHP as follows

root@linuxhelp:~# apt-get install php php-mysql -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libapache2-mod-php7.1 php-common php7.1 php7.1-cli php7.1-common php7.1-json php7.1-mysql php7.1-opcache
  php7.1-readline
Suggested packages:
  php-pear
The following NEW packages will be installed:
  libapache2-mod-php7.1 php php-common php-mysql php7.1 php7.1-cli php7.1-common php7.1-json php7.1-mysql
  php7.1-opcache php7.1-readline
0 upgraded, 11 newly installed, 0 to remove and 150 not upgraded.
Need to get 3,785 kB of archives.
After this operation, 15.0 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu artful/main amd64 php-common all 1:54ubuntu1 [12.1 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 php7.1-common amd64 7.1.15-0ubuntu0.17.10.1 [839 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 php7.1-json amd64 7.1.15-0ubuntu0.17.10.1 [17.5 kB]
.
.
.
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php7.1
Setting up php7.1 (7.1.15-0ubuntu0.17.10.1) ...
Setting up php (1:7.1+54ubuntu1) ...

Let' s test the PHP installation using the following method.

root@linuxhelp:~# nano /var/www/html/phpinfo.php
< ?php
phpinfo() 
?> 

Now restart apache web server to make the changes effect.

root@linuxhelp:~# systemctl restart apache2

After installing you can verify the PHP by navigating to the following URL http://localhost/phpinfo.php If you see the following page, PHP has been successfully installed on your machine.

With this, the method to install lamp stack on pop OS comes to an end

Tag : LAMP Pop OS
FAQ
Q
I have mariadb installed already shall I skip mysql installation
A
Yes you can skip the installation.
Q
how to exit from DB?
A
simply type exit or quit and press enter
Q
Why does we require php my admin?
A
In order to monitor the Database through graphical interface
Q
How do you see the PHP info?
A
The file contains the PHP code that displays the PHP information that installed
Q
Is there a single command for LAMP installation ?
A
Yes There is ! But Not for openBSD