How to install LAMP stack by Bash Script on Ubuntu 21.04
Installation of LAMP stack by Bash Script on Ubuntu 21.04
Introduction:
BASH is short for Bourne Again Shell, a UNIX shell and command language, LAMP is a common stack for web servers, and Linux, Apache, MySQL, and PHP make up its components.
Installation Procedure:
Step 1: Check the OS version by using the following command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
Step 2: Create a Bash script file to install LAMP stack
root@linuxhelp:~# vi lamp.sh
#!bin/bash
echo 'Installing Apache Web Server'
apt install apache2 -y
echo 'Apache Web Server is installed'
echo 'Installing Maria DB'
apt install mariadb-server -y
echo 'Maria db installed'
echo 'Installing php and its modules'
apt install php-pear php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php -y
echo 'php and its modules installed'
echo 'Starting the services'
systemctl restart apache2
systemctl restart mariadb
echo 'Enabling the services'
systemctl enable apache2
systemctl enable mariadb
echo 'Finally Checking status of services'
echo Apache service is $(systemctl show -p ActiveState --value apache2)
echo Maria DB service is $(systemctl show -p ActiveState --value mariadb)
echo LAMP setup installed on ubuntu Successfully
Step 3: Run the Script file by using the following command
root@linuxhelp:~# sh lamp.sh
Installing Apache Web Server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libllvm11 net-tools
Use 'apt autoremove' to remove them.
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 0 not upgraded.
Need to get 1,741 kB of archives.
After this operation, 7,550 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 libapr1 amd64 1.7.0-6ubuntu0.1 [96.9 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 libaprutil1 amd64 1.6.1-5ubuntu1 [84.9 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 libaprutil1-dbd-sqlite3 amd64 1.6.1-5ubuntu1 [10.6 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu hirsute/main amd64 libaprutil1-ldap amd64 1.6.1-5ubuntu1 [8,748 B]
Get:5 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 apache2-bin amd64 2.4.46-4ubuntu1.3 [1,201 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 apache2-data all 2.4.46-4ubuntu1.3 [158 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 apache2-utils amd64 2.4.46-4ubuntu1.3 [84.8 kB]
Get:8 http://in.archive.ubuntu.com/ubuntu hirsute-updates/main amd64 apache2 amd64 2.4.46-4ubuntu1.3 [95.9 kB]
Fetched 1,741 kB in 1s (1,851 kB/s)
Selecting previously unselected package libapr1:amd64.
(Reading database ... 191742 files and directories currently installed.)
Preparing to unpack .../0-libapr1_1.7.0-6ubuntu0.1_amd64.deb ...
Unpacking libapr1:amd64 (1.7.0-6ubuntu0.1) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../1-libaprutil1_1.6.1-5ubuntu1_amd64.deb ...
Unpacking libaprutil1:amd64 (1.6.1-5ubuntu1) ...
Unpacking apache2-bin (2.4.46-4ubuntu1.3) ...
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
Processing triggers for install-info (6.7.0.dfsg.2-6) ...
Processing triggers for libc-bin (2.33-0ubuntu5) ...
Processing triggers for php7.4-cli (7.4.16-1ubuntu2.2) ...
Processing triggers for libapache2-mod-php7.4 (7.4.16-1ubuntu2.2) ...
php and its modules installed
Starting the services
Enabling the services
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mariadb
Finally Checking status of services
Apache service is active
Maria DB service is active
LAMP setup installed on ubuntu Successfully
By this installation of LAMP stack using Bash Script on Ubuntu 21.04 comes to an end
Comments ( 0 )
No comments available