2023 ACHIEVEMENTS

Take a closer look at all the achieved milestones during 2023.

Watch Short Video
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Install MariaDB 10.5, Apache 2.4,...

How To Install MariaDB 10.5, Apache 2.4, PHP 7.4 (LAMP) on Debian 11 Server

How To Install MariaDB 10.5, Apache 2.4, PHP 7.4 (LAMP) on Debian 11 Server

NetShop ISP

NetShop ISP · Blog Author

Nov 09, 2022 · Technical Tutorials

The LAMP stack is a popular set of open-source software used on Linux environment for hosting database-driven websites. The acronym LAMP stands for Linux, Apache, MySQL/MariaDB, PHP/Perl/Python.

In this article we are going to demonstrate, in a few very easy steps, how to install LAMP on a Debian 11 Server. All you have to do is connect on your server, follow this article and copy/paste the commands we provide in each step below.

Pre-requisites

  • Server with Debian 11 OS installed
  • Root access on your server with SSH enabled
  • Temporarily disable firewall/iptables, or keep enabled with port 80 allowed/unfiltered

Steps To Install LAMP Stack on Debian 11 Server

Before getting into install the necessary software, update your system as follows:

apt-get update && apt-get upgrade

Step 1. Install Apache 2.4 Web Server

Run the following command to install apache2 and the associated libraries:

apt-get install apache2 apache2-utils -y

Now, verify the Apache version installed by executing the following command:

apache2 -v

You should see the following output:

Server version: Apache/2.4.51 (Debian)
Server built:   2022-11-05T09:31:22

The following command will start Apache2 and enable it so that it automatically starts at system boot:

systemctl start apache2 && systemctl enable apache2

Step 2. Install MariaDB 10.5 Database Server

MariaDB 10.5 version will be installed on Debian 11 system. Simply execute the following command:

apt-get install mariadb-server -y

As soon as mariadb is installed, execute the following command to start the service and enable it so it’s auto-started on server boot:

systemctl start mariadb && systemctl enable mariadb

Verify that MariaDB is running.

systemctl status mariadb

The following sample output is what you should get if everything went ok:

mariadb.service - MariaDB 10.5.15 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-11-09 06:28:03 EST; 43min ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 3103 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 8 (limit: 2340)
     Memory: 74.1M
        CPU: 1.817s
     CGroup: /system.slice/mariadb.service
             └─3103 /usr/sbin/mariadbd

By default, MariaDB is installed with empty root password. As this is insecure, we will execute the following command to set the root password and a few more security related settings:

mysql_secure_installation

First prompt will be to set a root password, so type a strong one. Then, answer to the following questions as follows:

Enter current password for root (enter for none):
Change the root password? [Y/n] Y
New password: ***********
Re-enter new password: ***********
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Now, restart MariaDB service with the following command:

systemctl restart mariadb

Step 3. Install PHP 7.4

The last step in our LAMP stack environment is to install PHP 7.4.

Use the following command to install PHP and other commonly used extensions:

apt-get install php libapache2-mod-php php-cli php-mysql php-zip php-curl php-xml -y

Once all installations are done, verify the version of PHP by executing the following command:

php -v

Step 3.2. Create Apache Virtual Host

The following commands will create a directory where you can upload your website files and set the right permissions: and will create the necessary apache virtual host configuration.

mkdir /var/www/html/awesomewebsite
chown -R www-data:www-data /var/www/html/awesomewebsite

Now, lets create the virtual host configuration file:

nano /etc/apache2/sites-available/awesomewebsite.conf

Paste the following content in the awesomewebsite.conf. Then save and exit.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName awesomewebsite.com
    DocumentRoot /var/www/html/awesomewebsite.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now, activate your newly created virtual host and disable the default one as follows:

a2ensite awesomewebsite.conf
a2dissite 000-default

You are all set! Now, reload Apache2 and check the service status by typing:

systemctl reload apache2 && systemctl status apache2

If all went well, you should see the following output:

apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-11-09 06:30:40 EST; 51min ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 14140 (apache2)
Tasks: 8 (limit: 2340)
Memory: 19.1M
CPU: 852ms
CGroup: /system.slice/apache2.service
├─14140 /usr/sbin/apache2 -k start
├─14292 /usr/sbin/apache2 -k start
├─14293 /usr/sbin/apache2 -k start
├─14294 /usr/sbin/apache2 -k start

Congrats! You now have a properly configured environment with MariaDB database, Apache web server and PHP 7.4!

Press Releases
71

Free VPS Trial

No Credit Card Required.

Recent Posts

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

Navigating Forex Server Hosting: Key Distinctions from Conventional Providers

23 February, 2024

How to Install Nginx, MariaDB, PHP-FPM on AlmaLinux 9 Server (LEMP)

How to Install Nginx, MariaDB, PHP-FPM on AlmaLinux 9 Server (LEMP)

16 February, 2024

How To Reset Forgotten MySQL 5.7 Root Pass in Linux

How To Reset Forgotten MySQL 5.7 Root Pass in Linux

09 February, 2024

4 Things Web Developers Should Know about Virtual and Dedicated Server Hosting

4 Things Web Developers Should Know about Virtual and Dedicated Server Hosting

05 February, 2024

How to Install Docker Compose on Debian 12 Server

How to Install Docker Compose on Debian 12 Server

22 January, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer