How to install Apache Web Server on Ubuntu 18.10

0
265
how to install apache web server on ubuntu 18 10 5c5744ed34070 - How to install Apache Web Server on Ubuntu 18.10

Apache HTTP server is an immensely popular cross-platform web server that’s used worldwide. It is a free, open source, powerful and can run on UNIX/Linux as well as MS Windows platforms.

Notable features include the ability to allow the server to serve more concurrent requests due to Multi-Processing Module (MPM) and integrated proxy module support for the FastCGI protocol, asynchronous read and write handling, and major integration with different application/software, various modules etc. It also supports embedded Lua scripting. It’s not just a web server, it also works as a reverse proxy for other web servers.

Installing Apache Web Server on Ubuntu 18.10

Official Ubuntu software repositories come with Apache and its dependencies. Hence, it’s simpler to update the system’s package index and then use the APT package manager to install the Apache package and its dependencies.

Step 1) Launch Terminal and enter the following command to update the system.

sudo apt-get update

Step 2) Check available Apache version on Ubuntu repository

sudo apt-cache policy apache2
how to install apache web server on ubuntu 18 10 5c5744ee05acc - How to install Apache Web Server on Ubuntu 18.10
Check available Apache Version

Step 3) Install apache2

sudo apt-get install apache2
how to install apache web server on ubuntu 18 10 5c5744ee44cb1 - How to install Apache Web Server on Ubuntu 18.10
Install Apache

Step 4) It will ask “do you want to continue”. Type Y.

Step 5) Normally Apache service should be started automatically. we can check apache status.

sudo systemctl status apache2.service
how to install apache web server on ubuntu 18 10 5c5744ef45187 - How to install Apache Web Server on Ubuntu 18.10
Apache-Status-Check

Starting and managing Apache Services

Apache services can be managed by using the following commands:

To start Apache2 service

sudo systemctl start apache2

To stop Apache2 Service

sudo systemctl stop apache2

To Restart Apache2 Service

sudo systemctl restart apache2

To Reload Apache2 service after configuration changes

sudo systemctl reload apache2

Enable Apache2 service start at boot

sudo systemctl enable apache2

Disable Apache2 on boot

sudo  systemctl disable apache2

Checking UFW Firewall

If you have the UFW firewall enabled, you need to open port 80 and 443. This is due to the fact that Apache web server gets client requests via HTTP and HTTPS. Check UFW status by entering the following command:

sudo systemctl status ufw.service
how to install apache web server on ubuntu 18 10 5c5744efd938e - How to install Apache Web Server on Ubuntu 18.10
Checking UFW status

Now you can allow ports 80 and 443 as follows:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw  reload

how to install apache web server on ubuntu 18 10 5c5744f06bc71 - How to install Apache Web Server on Ubuntu 18.10
Allowing Ports

By chance, if you see a message “Firewall not enabled (skipping reload)”  at the reload UFW command, edit “ufw.conf” file using VIM command as follows:

sudo  vim /etc/ufw/ufw.conf

how to install apache web server on ubuntu 18 10 5c5744f0d9e90 - How to install Apache Web Server on Ubuntu 18.10
Editing Conf

Change ENABLED=no to ENABLED=yes
save and exit file using: wq

Here is how the final edited file will look like:

how to install apache web server on ubuntu 18 10 5c5744f1619e0 - How to install Apache Web Server on Ubuntu 18.10
Edited Conf

Now try to reload Firewall again. It should work without issue this time.

sudo ufw  reload
how to install apache web server on ubuntu 18 10 5c5744f1dfd6c - How to install Apache Web Server on Ubuntu 18.10
UFW Reload

Checking the Apache installation

To check the Apache installation running status launch the browser using hostname/server IP address:

Hostname

http://localhost/

Using server Ip

http://192.168.10.25 (Your server IP)

This is Apache default page and if you can see this it means your apache server is working well.

how to install apache web server on ubuntu 18 10 5c5744f217ad9 - How to install Apache Web Server on Ubuntu 18.10
Apache2 default page

Additional Note:- Main directories of Apache can be classified as follows

Web DocumentRoot: /var/www/html/
Main config files directory: /etc/apache2/
Main config file: /etc/apache2/apache2.conf
Additional configuration : /etc/apache2/conf-available/ and /etc/apache2/conf-enabled/
Virtual hosts configuration : /etc/apache2/sites-available/ and /etc/apache2/sites-enabled/
Configuration  for loading modules: /etc/apache2/mods-available/ and /etc/apache2/mods-enabled/
Log files directory: /var/log/apache2/

Hope it worked well for you. Got any questions? Shoot below.