• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install LAMP stack by Bash Script on Ubuntu 21.04

  • 00:39 lsb_release -a
  • 00:51 vi lamp.sh
  • 07:27 sh lamp.sh
{{postValue.id}}

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

Tags:
isaac
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What are LAMP Stacks?

A

The LAMP Stacks are Linux, Apache. Maria DB, and PHP.

Q

What is the default login shell on Linux and Mac OS?

A

Bash is used as a default login shell in Linux systems and in macOS.

Q

What is the replacement of Shell Script?

A

Bash is the replacement for the original Shell Script.

Q

Does Bash requires any third-party software?

A

Bash does not require any third-party software to run.

Q

What is needed for the script file to run?

A

A script file must need to execute permissions to run.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.