Install LAMP Stack on Ubuntu Server 18.04 LTS - CentLinux

Latest

Monday, 24 February 2020

Install LAMP Stack on Ubuntu Server 18.04 LTS

Install LAMP Stack on Ubuntu Server 18.04 LTS

LAMP Stack is a set of free and open source software that can be used to create web applications. LAMP is a acronym and named after the original stack components i.e. Linux operating system, Apache web server, MySQL relational database management system and PHP programming language.

In this article, you will learn how to install LAMP stack on Ubuntu Server 18.04 LTS and deploy phpMyAdmin web application on it.

 

 

This Article Provides:

     

    Environment Specification:

    We have installed a Ubuntu Server virtual machine with following specification.

    • CPU - 3.4 Ghz (2 cores)
    • Memory - 2 GB
    • Storage - 20 GB
    • Operating System - Ubuntu Server 18.04 LTS
    • Hostname – lamp-stack-01.centlinux.com
    • IP Address - 192.168.116.218 /24

     

    Upgrading Ubuntu Server 18.04 LTS Packages:

    Connect with lamp-stack-01.centlinux.com as a privileged user by using a ssh tool like PuTTY.

    Download latest package list from repositories and update apt available package list.

    ahmer@lamp-stack-01:~$ sudo apt update Hit:1 http://pk.archive.ubuntu.com/ubuntu bionic InRelease Get:2 http://pk.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Get:3 http://pk.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Get:4 http://pk.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Get:5 http://pk.archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB] Get:6 http://pk.archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3,584 B] Get:7 http://pk.archive.ubuntu.com/ubuntu bionic/universe Translation-en [4,941 kB] Get:8 http://pk.archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB] Get:9 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [871 kB] Get:10 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [303 kB] Get:11 http://pk.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [32.9 kB] Get:12 http://pk.archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [8,468 B] Get:13 http://pk.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,053 kB] Get:14 http://pk.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [326 kB] Get:15 http://pk.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [9,908 B] Get:16 http://pk.archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [4,608 B] Get:17 http://pk.archive.ubuntu.com/ubuntu bionic-backports/main Translation-en [1,644 B] Get:18 http://pk.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4,028 B] Get:19 http://pk.archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1,900 B] Get:20 http://pk.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [650 kB] Get:21 http://pk.archive.ubuntu.com/ubuntu bionic-security/main Translation-en [211 kB] Get:22 http://pk.archive.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [23.8 kB] Get:23 http://pk.archive.ubuntu.com/ubuntu bionic-security/restricted Translation-en [6,528 B] Get:24 http://pk.archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [648 kB] Get:25 http://pk.archive.ubuntu.com/ubuntu bionic-security/universe Translation-en [218 kB] Get:26 http://pk.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [6,552 B] Get:27 http://pk.archive.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2,668 B] Fetched 10.2 MB in 22s (459 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 115 packages can be upgraded. Run 'apt list --upgradable' to see them.

    We have now an updated package list. Therefore, we can now upgrade our Ubuntu Server 18.04 LTS with latest version of packages.

    Install all the new packages using apt command.

    ahmer@lamp-stack-01:~$ sudo apt upgrade -y Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages were automatically installed and are no longer required: libdumbnet1 linux-headers-4.15.0-76 linux-headers-4.15.0-76-generic linux-image-4.15.0-76-generic linux-modules-4.15.0-76-generic linux-modules-extra-4.15.0-76-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: linux-headers-4.15.0-88 linux-headers-4.15.0-88-generic linux-image-4.15.0-88-generic linux-modules-4.15.0-88-generic linux-modules-extra-4.15.0-88-generic The following packages will be upgraded: apport apt apt-utils base-files bind9-host bsdutils cloud-init cpio curl distro-info-data dmeventd dmidecode dmsetup dnsutils dpkg e2fsprogs fdisk file git git-man grep initramfs-tools initramfs-tools-bin initramfs-tools-core landscape-common libapt-inst2.0 libapt-pkg5.0 libbind9-160 libblkid1 libbsd0 libcom-err2 libcurl3-gnutls libcurl4 libdevmapper-event1.02.1 libdevmapper1.02.1 libdns-export1100 libdns1100 libdrm-common libdrm2 libexpat1 libext2fs2 libfdisk1 libgcrypt20 libgnutls30 libidn2-0 libirs160 libisc-export169 libisc169 libisccc160 libisccfg160 libldap-2.4-2 libldap-common liblvm2app2.2 liblvm2cmd2.02 liblwres160 libmagic-mgc libmagic1 libmount1 libnss-systemd libpam-systemd libpcap0.8 libprocps6 libpython3.6 libpython3.6-minimal libpython3.6-stdlib libsasl2-2 libsasl2-modules libsasl2-modules-db libsmartcols1 libsqlite3-0 libss2 libssl1.1 libsystemd0 libudev1 libuuid1 libxml2 libxslt1.1 libzstd1 linux-generic linux-headers-generic linux-image-generic lvm2 mdadm mount netplan.io nplan open-vm-tools openssl procps python-apt-common python3-apport python3-apt python3-distupgrade python3-gdbm python3-problem-report python3-software-properties python3.6 python3.6-minimal snapd software-properties-common sosreport sudo systemd systemd-sysv tcpdump tzdata ubuntu-minimal ubuntu-release-upgrader-core ubuntu-server ubuntu-standard udev unattended-upgrades util-linux uuid-runtime xkb-data 115 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 155 kB/115 MB of archives. After this operation, 335 MB of additional disk space will be used. Get:1 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libldap-2.4-2 amd64 2.4.45+dfsg-1ubuntu1.4 [155 kB] Fetched 155 kB in 2s (89.7 kB/s) Extracting templates from packages: 100% Preconfiguring packages ... (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../base-files_10.1ubuntu2.8_amd64.deb ... Warning: Stopping motd-news.service, but it can still be activated by: motd-news.timer Unpacking base-files (10.1ubuntu2.8) over (10.1ubuntu2.6) ... Setting up base-files (10.1ubuntu2.8) ... Installing new version of config file /etc/issue ... Installing new version of config file /etc/issue.net ... Installing new version of config file /etc/lsb-release ... Installing new version of config file /etc/update-motd.d/50-motd-news ... motd-news.service is a disabled or a static unit, not starting it. (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../bsdutils_1%3a2.31.1-0.4ubuntu3.5_amd64.deb ... Unpacking bsdutils (1:2.31.1-0.4ubuntu3.5) over (1:2.31.1-0.4ubuntu3.3) ... Setting up bsdutils (1:2.31.1-0.4ubuntu3.5) ... (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../dpkg_1.19.0.5ubuntu2.3_amd64.deb ... Unpacking dpkg (1.19.0.5ubuntu2.3) over (1.19.0.5ubuntu2.1) ... Setting up dpkg (1.19.0.5ubuntu2.3) ... (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../initramfs-tools-bin_0.130ubuntu3.9_amd64.deb ... Unpacking initramfs-tools-bin (0.130ubuntu3.9) over (0.130ubuntu3.8) ... Preparing to unpack .../initramfs-tools-core_0.130ubuntu3.9_all.deb ... Unpacking initramfs-tools-core (0.130ubuntu3.9) over (0.130ubuntu3.8) ... Preparing to unpack .../initramfs-tools_0.130ubuntu3.9_all.deb ... Unpacking initramfs-tools (0.130ubuntu3.9) over (0.130ubuntu3.8) ... Preparing to unpack .../libext2fs2_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking libext2fs2:amd64 (1.44.1-1ubuntu1.3) over (1.44.1-1ubuntu1.1) ... Setting up libext2fs2:amd64 (1.44.1-1ubuntu1.3) ... (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../e2fsprogs_1.44.1-1ubuntu1.3_amd64.deb ... Unpacking e2fsprogs (1.44.1-1ubuntu1.3) over (1.44.1-1ubuntu1.1) ... Setting up e2fsprogs (1.44.1-1ubuntu1.3) ... update-initramfs: deferring update (trigger activated) (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../libudev1_237-3ubuntu10.39_amd64.deb ... Unpacking libudev1:amd64 (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Setting up libudev1:amd64 (237-3ubuntu10.39) ... (Reading database ... 66944 files and directories currently installed.) Preparing to unpack .../udev_237-3ubuntu10.39_amd64.deb ... Unpacking udev (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Preparing to unpack .../libpam-systemd_237-3ubuntu10.39_amd64.deb ... Unpacking libpam-systemd:amd64 (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Preparing to unpack .../libnss-systemd_237-3ubuntu10.39_amd64.deb ... Unpacking libnss-systemd:amd64 (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Preparing to unpack .../systemd_237-3ubuntu10.39_amd64.deb ... Unpacking systemd (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Preparing to unpack .../libsystemd0_237-3ubuntu10.39_amd64.deb ... Unpacking libsystemd0:amd64 (237-3ubuntu10.39) over (237-3ubuntu10.24) ... Setting up libsystemd0:amd64 (237-3ubuntu10.39) ... Setting up systemd (237-3ubuntu10.39) ... Installing new version of config file /etc/dhcp/dhclient-enter-hooks.d/resolved ...

    After upgrading Ubuntu software packages, you may also need to restart your Server.

    ahmer@lamp-stack-01:~$ sudo reboot

    All package in our Ubuntu Server 18.04 LTS has been upgraded to latest versions.

     

    Installing Apache on Ubuntu Server 18.04 LTS:

    Apache HTTP Server can be installed on Ubuntu Server by using the apt command.

    ahmer@lamp-stack-01:~$ sudo apt install apache2 -y [sudo] password for ahmer: Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libdumbnet1 Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 ssl-cert Suggested packages: www-browser apache2-doc apache2-suexec-pristine | apache2-suexec-custom openssl-blacklist The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 ssl-cert 0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. Need to get 1,730 kB of archives. After this operation, 6,982 kB of additional disk space will be used. Get:1 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libapr1 amd64 1.6.3-2 [90.9 kB] Get:2 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1 amd64 1.6.1-2 [84.4 kB] Get:3 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-2 [10.6 kB] Get:4 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libaprutil1-ldap amd64 1.6.1-2 [8,764 B] Get:5 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 liblua5.2-0 amd64 5.2.4-1.1build1 [108 kB] Get:6 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-bin amd64 2.4.29-1ubuntu4.11 [1,071 kB] Get:7 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-utils amd64 2.4.29-1ubuntu4.11 [83.9 kB] Get:8 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2-data all 2.4.29-1ubuntu4.11 [160 kB] Get:9 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2 amd64 2.4.29-1ubuntu4.11 [95.1 kB] Get:10 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 ssl-cert all 1.0.39 [17.0 kB] Fetched 1,730 kB in 5s (315 kB/s) Preconfiguring packages ... Selecting previously unselected package libapr1:amd64. (Reading database ... 102494 files and directories currently installed.) Preparing to unpack .../0-libapr1_1.6.3-2_amd64.deb ... Unpacking libapr1:amd64 (1.6.3-2) ... Selecting previously unselected package libaprutil1:amd64. Preparing to unpack .../1-libaprutil1_1.6.1-2_amd64.deb ... Unpacking libaprutil1:amd64 (1.6.1-2) ... Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64. Preparing to unpack .../2-libaprutil1-dbd-sqlite3_1.6.1-2_amd64.deb ... Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ... Selecting previously unselected package libaprutil1-ldap:amd64. Preparing to unpack .../3-libaprutil1-ldap_1.6.1-2_amd64.deb ... Unpacking libaprutil1-ldap:amd64 (1.6.1-2) ... Selecting previously unselected package liblua5.2-0:amd64. Preparing to unpack .../4-liblua5.2-0_5.2.4-1.1build1_amd64.deb ... Unpacking liblua5.2-0:amd64 (5.2.4-1.1build1) ... Selecting previously unselected package apache2-bin. Preparing to unpack .../5-apache2-bin_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2-bin (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2-utils. Preparing to unpack .../6-apache2-utils_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2-utils (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2-data. Preparing to unpack .../7-apache2-data_2.4.29-1ubuntu4.11_all.deb ... Unpacking apache2-data (2.4.29-1ubuntu4.11) ... Selecting previously unselected package apache2. Preparing to unpack .../8-apache2_2.4.29-1ubuntu4.11_amd64.deb ... Unpacking apache2 (2.4.29-1ubuntu4.11) ... Selecting previously unselected package ssl-cert. Preparing to unpack .../9-ssl-cert_1.0.39_all.deb ... Unpacking ssl-cert (1.0.39) ... Setting up libapr1:amd64 (1.6.3-2) ... Setting up apache2-data (2.4.29-1ubuntu4.11) ... Setting up ssl-cert (1.0.39) ... Setting up libaprutil1:amd64 (1.6.1-2) ... Setting up liblua5.2-0:amd64 (5.2.4-1.1build1) ... Setting up libaprutil1-ldap:amd64 (1.6.1-2) ... Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-2) ... Setting up apache2-utils (2.4.29-1ubuntu4.11) ... Setting up apache2-bin (2.4.29-1ubuntu4.11) ... Setting up apache2 (2.4.29-1ubuntu4.11) ... Enabling module mpm_event. Enabling module authz_core. Enabling module authz_host. Enabling module authn_core. Enabling module auth_basic. Enabling module access_compat. Enabling module authn_file. Enabling module authz_user. Enabling module alias. Enabling module dir. Enabling module autoindex. Enabling module env. Enabling module mime. Enabling module negotiation. Enabling module setenvif. Enabling module filter. Enabling module deflate. Enabling module status. Enabling module reqtimeout. Enabling conf charset. Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service â /lib/systemd/system/apache2.service. Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service â /lib/systemd/system/apache-htcacheclean.service. Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.39) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for ufw (0.36-0ubuntu0.18.04.1) ... Processing triggers for ureadahead (0.100.0-21) ...

    During installation, a systemd service for Apache web server is automatically created and started.

    Check status of Apache service.

    ahmer@lamp-stack-01:~$ systemctl status apache2 â apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: Drop-In: /lib/systemd/system/apache2.service.d ââapache2-systemd.conf Active: active (running) since Fri 2020-02-21 14:50:33 UTC; 1min 27s ago Main PID: 2294 (apache2) Tasks: 55 (limit: 2290) CGroup: /system.slice/apache2.service ââ2294 /usr/sbin/apache2 -k start ââ2297 /usr/sbin/apache2 -k start ââ2298 /usr/sbin/apache2 -k start Feb 21 14:50:33 lamp-stack-01.centlinux.com systemd[1]: Starting The Apache HTTP Feb 21 14:50:33 lamp-stack-01.centlinux.com systemd[1]: Started The Apache HTTP

    Apache installation also allows the defaults services and ports in Linux firewall.

    ahmer@lamp-stack-01:~$ sudo ufw app list Available applications: Apache Apache Full Apache Secure OpenSSH

    Open URL http://lamp-stack-01.centlinux.com/ in a browser.

    01-apache-ubuntu-default-webpage

    The browser will serve the default page of Apache Web Server. It confirms that the Apache has been installed and configured on Ubuntu Server 18.04 LTS.

     

    Installing MySQL Database on Ubuntu Server 18.04 LTS:

    Install MySQL database available in apt repository. If you want to install a latest version of MySQL that was not available in apt repository, then you have to download it from MySQL website.

    ahmer@lamp-stack-01:~$ sudo apt install mysql-server -y Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libdumbnet1 Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-6 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7 Suggested packages: libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca The following NEW packages will be installed: libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-6 libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7 0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded. Need to get 19.7 MB of archives. After this operation, 156 MB of additional disk space will be used. Get:1 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B] Get:2 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B] Get:3 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-core-5.7 amd64 5.7.29-0ubuntu0.18.04.1 [6,642 kB] Get:4 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-5.7 amd64 5.7.29-0ubuntu0.18.04.1 [1,942 kB] Get:5 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-core-5.7 amd64 5.7.29-0ubuntu0.18.04.1 [7,430 kB] Get:6 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libevent-core-2.1-6 amd64 2.1.8-stable-4build1 [85.9 kB] Get:7 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-5.7 amd64 5.7.29-0ubuntu0.18.04.1 [2,933 kB] Get:8 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-tagset-perl all 3.20-3 [12.1 kB] Get:9 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 liburi-perl all 1.73-1 [77.2 kB] Get:10 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-parser-perl amd64 3.72-3build1 [85.9 kB] Get:11 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libcgi-pm-perl all 4.38-1 [185 kB] Get:12 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libfcgi-perl amd64 0.78-2build1 [32.8 kB] Get:13 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libcgi-fast-perl all 1:2.13-1 [9,940 B] Get:14 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libencode-locale-perl all 1.05-1 [12.3 kB] Get:15 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB] Get:16 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libtimedate-perl all 2.3000-2 [37.5 kB] Get:17 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libhttp-date-perl all 6.02-1 [10.4 kB] Get:18 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libio-html-perl all 1.001-1 [14.9 kB] Get:19 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 liblwp-mediatypes-perl all 6.02-1 [21.7 kB] Get:20 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 libhttp-message-perl all 6.14-1 [72.1 kB] Get:21 http://pk.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server all 5.7.29-0ubuntu0.18.04.1 [9,944 B] Fetched 19.7 MB in 1min 52s (176 kB/s) Preconfiguring packages ... Selecting previously unselected package mysql-common. (Reading database ... 103209 files and directories currently installed.) Preparing to unpack .../0-mysql-common_5.8+1.0.4_all.deb ... Unpacking mysql-common (5.8+1.0.4) ... Selecting previously unselected package libaio1:amd64. Preparing to unpack .../1-libaio1_0.3.110-5ubuntu0.1_amd64.deb ... Unpacking libaio1:amd64 (0.3.110-5ubuntu0.1) ... Selecting previously unselected package mysql-client-core-5.7. Preparing to unpack .../2-mysql-client-core-5.7_5.7.29-0ubuntu0.18.04.1_amd64.deb ... Unpacking mysql-client-core-5.7 (5.7.29-0ubuntu0.18.04.1) ... Selecting previously unselected package mysql-client-5.7. Preparing to unpack .../3-mysql-client-5.7_5.7.29-0ubuntu0.18.04.1_amd64.deb ... Unpacking mysql-client-5.7 (5.7.29-0ubuntu0.18.04.1) ... Selecting previously unselected package mysql-server-core-5.7. Preparing to unpack .../4-mysql-server-core-5.7_5.7.29-0ubuntu0.18.04.1_amd64.deb ... Unpacking mysql-server-core-5.7 (5.7.29-0ubuntu0.18.04.1) ... Selecting previously unselected package libevent-core-2.1-6:amd64. Preparing to unpack .../5-libevent-core-2.1-6_2.1.8-stable-4build1_amd64.deb ... Unpacking libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ... Setting up mysql-common (5.8+1.0.4) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode Selecting previously unselected package mysql-server-5.7. (Reading database ... 103377 files and directories currently installed.) Preparing to unpack .../00-mysql-server-5.7_5.7.29-0ubuntu0.18.04.1_amd64.deb ... Unpacking mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ... Selecting previously unselected package libhtml-tagset-perl. Preparing to unpack .../01-libhtml-tagset-perl_3.20-3_all.deb ... Unpacking libhtml-tagset-perl (3.20-3) ... Selecting previously unselected package liburi-perl. Preparing to unpack .../02-liburi-perl_1.73-1_all.deb ... Unpacking liburi-perl (1.73-1) ... Selecting previously unselected package libhtml-parser-perl. Preparing to unpack .../03-libhtml-parser-perl_3.72-3build1_amd64.deb ... Unpacking libhtml-parser-perl (3.72-3build1) ... Selecting previously unselected package libcgi-pm-perl. Preparing to unpack .../04-libcgi-pm-perl_4.38-1_all.deb ... Unpacking libcgi-pm-perl (4.38-1) ... Selecting previously unselected package libfcgi-perl. Preparing to unpack .../05-libfcgi-perl_0.78-2build1_amd64.deb ... Unpacking libfcgi-perl (0.78-2build1) ... Selecting previously unselected package libcgi-fast-perl. Preparing to unpack .../06-libcgi-fast-perl_1%3a2.13-1_all.deb ... Unpacking libcgi-fast-perl (1:2.13-1) ... Selecting previously unselected package libencode-locale-perl. Preparing to unpack .../07-libencode-locale-perl_1.05-1_all.deb ... Unpacking libencode-locale-perl (1.05-1) ... Selecting previously unselected package libhtml-template-perl. Preparing to unpack .../08-libhtml-template-perl_2.97-1_all.deb ... Unpacking libhtml-template-perl (2.97-1) ... Selecting previously unselected package libtimedate-perl. Preparing to unpack .../09-libtimedate-perl_2.3000-2_all.deb ... Unpacking libtimedate-perl (2.3000-2) ... Selecting previously unselected package libhttp-date-perl. Preparing to unpack .../10-libhttp-date-perl_6.02-1_all.deb ... Unpacking libhttp-date-perl (6.02-1) ... Selecting previously unselected package libio-html-perl. Preparing to unpack .../11-libio-html-perl_1.001-1_all.deb ... Unpacking libio-html-perl (1.001-1) ... Selecting previously unselected package liblwp-mediatypes-perl. Preparing to unpack .../12-liblwp-mediatypes-perl_6.02-1_all.deb ... Unpacking liblwp-mediatypes-perl (6.02-1) ... Selecting previously unselected package libhttp-message-perl. Preparing to unpack .../13-libhttp-message-perl_6.14-1_all.deb ... Unpacking libhttp-message-perl (6.14-1) ... Selecting previously unselected package mysql-server. Preparing to unpack .../14-mysql-server_5.7.29-0ubuntu0.18.04.1_all.deb ... Unpacking mysql-server (5.7.29-0ubuntu0.18.04.1) ... Setting up libhtml-tagset-perl (3.20-3) ... Setting up libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ... Setting up libencode-locale-perl (1.05-1) ... Setting up libtimedate-perl (2.3000-2) ... Setting up libio-html-perl (1.001-1) ... Setting up liblwp-mediatypes-perl (6.02-1) ... Setting up libaio1:amd64 (0.3.110-5ubuntu0.1) ... Setting up liburi-perl (1.73-1) ... Setting up libhtml-parser-perl (3.72-3build1) ... Setting up libcgi-pm-perl (4.38-1) ... Setting up mysql-client-core-5.7 (5.7.29-0ubuntu0.18.04.1) ... Setting up libfcgi-perl (0.78-2build1) ... Setting up libhttp-date-perl (6.02-1) ... Setting up libhtml-template-perl (2.97-1) ... Setting up mysql-server-core-5.7 (5.7.29-0ubuntu0.18.04.1) ... Setting up libcgi-fast-perl (1:2.13-1) ... Setting up libhttp-message-perl (6.14-1) ... Setting up mysql-client-5.7 (5.7.29-0ubuntu0.18.04.1) ... Setting up mysql-server-5.7 (5.7.29-0ubuntu0.18.04.1) ... update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode Renaming removed key_buffer and myisam-recover options (if present) Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service â /lib/systemd/system/mysql.service. Setting up mysql-server (5.7.29-0ubuntu0.18.04.1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.39) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-21) ...

    Configure MySQL database server and set root user password.

    ahmer@lamp-stack-01:~$ sudo mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2 Please set the password for root here. New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : y 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? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : y - 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? (Press y|Y for Yes, any other key for No) : y Success. All done!

    MySQL installation process automatically creates and starts a systemd service of MySQL database server.

    Check status of MySQL service.

    ahmer@lamp-stack-01:~$ systemctl status mysql â mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en Active: active (running) since Fri 2020-02-21 16:02:28 UTC; 5min ago Main PID: 3396 (mysqld) Tasks: 29 (limit: 2290) CGroup: /system.slice/mysql.service ââ3396 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid Feb 21 16:02:27 lamp-stack-01.centlinux.com systemd[1]: Starting MySQL Community Feb 21 16:02:28 lamp-stack-01.centlinux.com systemd[1]: Started MySQL Community

    MySQL database has been installed on Ubuntu Server 18.04 LTS.

     

    Installing PHP on Ubuntu Server 18.04 LTS:

    Install PHP and relevant packages using following command.

    ahmer@lamp-stack-01:~$ sudo apt-get install php libapache2-mod-php php-mysql -y Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libdumbnet1 Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libapache2-mod-php7.2 libsodium23 php-common php7.2 php7.2-cli php7.2-common php7.2-json php7.2-mysql php7.2-opcache php7.2-readline Suggested packages: php-pear The following NEW packages will be installed: libapache2-mod-php libapache2-mod-php7.2 libsodium23 php php-common php-mysql php7.2 php7.2-cli php7.2-common php7.2-json php7.2-mysql php7.2-opcache php7.2-readline 0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded. Need to get 12.1 kB/4,134 kB of archives. After this operation, 18.0 MB of additional disk space will be used. Get:1 http://pk.archive.ubuntu.com/ubuntu bionic/main amd64 php-common all 1:60ubuntu1 [12.1 kB] Fetched 12.1 kB in 1s (16.0 kB/s) Selecting previously unselected package php-common. (Reading database ... 103736 files and directories currently installed.) Preparing to unpack .../00-php-common_1%3a60ubuntu1_all.deb ... Unpacking php-common (1:60ubuntu1) ... Selecting previously unselected package php7.2-common. Preparing to unpack .../01-php7.2-common_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-common (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package php7.2-json. Preparing to unpack .../02-php7.2-json_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-json (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package php7.2-opcache. Preparing to unpack .../03-php7.2-opcache_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-opcache (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package php7.2-readline. Preparing to unpack .../04-php7.2-readline_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-readline (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package libsodium23:amd64. Preparing to unpack .../05-libsodium23_1.0.16-2_amd64.deb ... Unpacking libsodium23:amd64 (1.0.16-2) ... Selecting previously unselected package php7.2-cli. Preparing to unpack .../06-php7.2-cli_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-cli (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package libapache2-mod-php7.2. Preparing to unpack .../07-libapache2-mod-php7.2_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking libapache2-mod-php7.2 (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package libapache2-mod-php. Preparing to unpack .../08-libapache2-mod-php_1%3a7.2+60ubuntu1_all.deb ... Unpacking libapache2-mod-php (1:7.2+60ubuntu1) ... Selecting previously unselected package php7.2. Preparing to unpack .../09-php7.2_7.2.24-0ubuntu0.18.04.3_all.deb ... Unpacking php7.2 (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package php. Preparing to unpack .../10-php_1%3a7.2+60ubuntu1_all.deb ... Unpacking php (1:7.2+60ubuntu1) ... Selecting previously unselected package php7.2-mysql. Preparing to unpack .../11-php7.2-mysql_7.2.24-0ubuntu0.18.04.3_amd64.deb ... Unpacking php7.2-mysql (7.2.24-0ubuntu0.18.04.3) ... Selecting previously unselected package php-mysql. Preparing to unpack .../12-php-mysql_1%3a7.2+60ubuntu1_all.deb ... Unpacking php-mysql (1:7.2+60ubuntu1) ... Setting up libsodium23:amd64 (1.0.16-2) ... Setting up php-common (1:60ubuntu1) ... Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer â /lib/systemd/system/phpsessionclean.timer. Setting up php7.2-common (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/calendar.ini with new version Creating config file /etc/php/7.2/mods-available/ctype.ini with new version Creating config file /etc/php/7.2/mods-available/exif.ini with new version Creating config file /etc/php/7.2/mods-available/fileinfo.ini with new version Creating config file /etc/php/7.2/mods-available/ftp.ini with new version Creating config file /etc/php/7.2/mods-available/gettext.ini with new version Creating config file /etc/php/7.2/mods-available/iconv.ini with new version Creating config file /etc/php/7.2/mods-available/pdo.ini with new version Creating config file /etc/php/7.2/mods-available/phar.ini with new version Creating config file /etc/php/7.2/mods-available/posix.ini with new version Creating config file /etc/php/7.2/mods-available/shmop.ini with new version Creating config file /etc/php/7.2/mods-available/sockets.ini with new version Creating config file /etc/php/7.2/mods-available/sysvmsg.ini with new version Creating config file /etc/php/7.2/mods-available/sysvsem.ini with new version Creating config file /etc/php/7.2/mods-available/sysvshm.ini with new version Creating config file /etc/php/7.2/mods-available/tokenizer.ini with new version Setting up php7.2-readline (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/readline.ini with new version Setting up php7.2-json (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/json.ini with new version Setting up php7.2-opcache (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/opcache.ini with new version Setting up php7.2-mysql (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.2/mods-available/mysqli.ini with new version Creating config file /etc/php/7.2/mods-available/pdo_mysql.ini with new version Setting up php7.2-cli (7.2.24-0ubuntu0.18.04.3) ... update-alternatives: using /usr/bin/php7.2 to provide /usr/bin/php (php) in auto mode update-alternatives: using /usr/bin/phar7.2 to provide /usr/bin/phar (phar) in auto mode update-alternatives: using /usr/bin/phar.phar7.2 to provide /usr/bin/phar.phar (phar.phar) in auto mode Creating config file /etc/php/7.2/cli/php.ini with new version Setting up libapache2-mod-php7.2 (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/apache2/php.ini with new version Module mpm_event disabled. Enabling module mpm_prefork. apache2_switch_mpm Switch to prefork apache2_invoke: Enable module php7.2 Setting up php-mysql (1:7.2+60ubuntu1) ... Setting up libapache2-mod-php (1:7.2+60ubuntu1) ... Setting up php7.2 (7.2.24-0ubuntu0.18.04.3) ... Setting up php (1:7.2+60ubuntu1) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ...

    Restart Apache service.

    ahmer@lamp-stack-01:~$ sudo systemctl restart apache2

    Create a php file in Apache document root.

    ahmer@lamp-stack-01:~$ sudo vi /var/www/html/phpinfo.php

    Add following lines of code in this file.

    <?php phpinfo (); ?>

    Open URL http://lamp-stack-01.centlinux.com/phpinfo.php in a browser.

    02-apache-ubuntu-phpinfo

    Our PHP script has created a complete web page that displays the detailed information about PHP and related plugins.

    Our LAMP Stack has been installed on Ubuntu Server 18.04 LTS.

     

    Installing phpMyAdmin on Ubuntu Server 18.04 LTS:

    To install phpMyAdmin and related packages, we can use apt command.

    ahmer@lamp-stack-01:~$ sudo apt install phpmyadmin php-mbstring php-gettext -y

    After successful installation, the installer will launch the TUI (Terminal User Interface) based configuration setup.

    03-phpmyadmin-config-web-server

    Choose the web server that we have installed on our LAMP Server.

    We have chosen Apache web server. Click on Ok.

    04-phpmyadmin-config-database

    phpMyAdmin needs a MySQL database to use as its data repository. Since, we have already installed MySQL database on our LAMP Server. Therefore, click on Yes.

    05-phpmyadmin-config-database-password

    Enter the root user password and click on Ok.

    06-phpmyadmin-config-database-password-confirm

    Re-enter the root password and click on Ok.

    ... Creating config file /etc/phpmyadmin/config-db.php with new version checking privileges on database phpmyadmin for phpmyadmin@localhost: user creation needed. granting access to database phpmyadmin for phpmyadmin@localhost: success. verifying access for phpmyadmin@localhost: success. creating database phpmyadmin: success. verifying database phpmyadmin exists: success. populating database via sql... done. dbconfig-common: flushing administrative password apache2_invoke: Enable configuration phpmyadmin Setting up php-gettext (1.0.12-0.1) ... Setting up libfontconfig1:amd64 (2.12.6-0ubuntu2) ... Setting up libgd3:amd64 (2.2.5-4ubuntu0.3) ... Setting up php7.2-gd (7.2.24-0ubuntu0.18.04.3) ... Creating config file /etc/php/7.2/mods-available/gd.ini with new version Setting up php-gd (1:7.2+60ubuntu1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for libapache2-mod-php7.2 (7.2.24-0ubuntu0.18.04.3) ...

    Restart Apache service to load changes.

    ahmer@lamp-stack-01:~$ sudo systemctl restart apache2

    Open URL http://lamp-stack-01.centlinux.com/phpmyadmin/ in a browser.

    07-phpmyadmin-login-page

    We have successfully installed LAMP Stack on Ubuntu Server 18.04 LTS and deploy phpMyAdmin web application on it. If you want to customize the LAMP stack according to your requirements than you should read Learning PHP, MySQL & JavaScript by O'Reilly Media.

    No comments:

    Post a comment