Linux Ubuntu

Host a website on LAMP Ubuntu 20.04

You can install LAMP Server with one command, later you only need to configure it, please follow the tutorial below to configure.

//to install LAMP server with one command
sudo tasksel install lamp-server
Step 1: Install Apache
sudo apt update && sudo apt upgrade
sudo apt install apache2
Configure Apache
sudo nano /etc/apache2/apache2.conf
KeepAlive Off


   <IfModule mpm_prefork_module>
       StartServers 4
       MinSpareServers 20
       MaxSpareServers 40
       MaxClients 200
       MaxRequestsPerChild 4500
Restart Apache
sudo systemctl restart apache2
Step 2: Host Website

Disable the default Apache virtual host

sudo a2dissite *default

Create folder for your website

sudo mkdir -p /var/www/html/{public_html,log,backups}

Configure Virtual host

sudo nano /etc/apache2/sites-available/
# domain:
# public: /var/www/html/

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/
  CustomLog /var/www/html/ combined

Enable your website

sudo a2ensite


sudo systemctl reload apache2

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.