How to Install and configure Apache2 web Service on Ubuntu 20.04 LTS.

Apache2 web Server is a open-source software that means we can easily used and modified freely.We can easily install & configure web servers like Apache2 or Nginx.

The basic objective of the web server is to store, process and deliver web pages to the users. This intercommunication is done using Hypertext Transfer Protocol (HTTP).We can easily create an application in HTML or PHP & run on a web server.

Install Apache2 Web Server

Update the required packages.

apt-get update

Install apache2 web server.

apt-get install apache2

Start & Enable Apache2 Service.

systemctl start apache2
systemctl enable apache2

Check Apache2 Status.

systemctl status apache2

Here is the command output.

Fig 1

Access Apache2 Web Interface.

  • Access Apache2 Web Interface by using the URL.
http://server-ip

Here is the URL output.

Fig 2

We can create a own html page.Go to /var/www/html/ directory.Edit the index.html page.

cd /var/www/html
vim index.html

Restart apache2 service.

systemctl restart apache2

If we needs to create own directory & .html page or php.info page.

mkdir example
cd example
vim index.html

Edit 000-default.conf Configure file.Set Document Root path & Restart the service.

vim /etc/apache2/sites-available/000-default.conf

Create own Configure file.

vim /etc/apache2/sites-available/example.conf

Provide the code.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName server-name.com
    ServerAlias www.server-alies
    DocumentRoot /path/of/example/folder/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /path/of/example/folder/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Enable the config file.

a2ensite example.conf

Disable the default site.

a2dissite 000-default.conf

Enable the write mode.

a2enmod rewrite

Restart Apache2 Service.

systemctl restart apache2

 

Leave a Reply