cover installation apache on ubuntu
4–5 minutes

Apache installation on Ubuntu

The Apache HTTP server is the most widely used web server in the world. It provides many powerful features including dynamically loadable modules, robust multimedia support and broad integration with other popular software.

Step 1: Installation of Apache

Apache is available within Ubuntu’s default software repository, making installation possible using conventional package management tools.

Update the local package index:

sudo apt update

Then run the package installation apache2:

sudo apt install apache2

After confirming the installation, apt install Apache and all dependencies.

Step 2: Firewall regulation

Before testing Apache, you need to change firewall settings to allow external access to predefined web ports. There should be a configured UFW firewall to limit server access.

During the installation, Apache registers with UFW to provide some application profiles that can be used to enable or disable access to Apache through the firewall.

List the profiles contained within the application ufw:

sudo ufw app list

An example of output could be as follows:

Applications available: Apache Apache Full Apache Secure

APAI

As indicated by the output, three profiles for Apache are available:

  • Apache: This profile only opens the door 80 (normal and unencrypted web traffic)
  • Apache Full: This profile opens both the door 80 that the door 443 (TLS/SSL encrypted wire)
  • Apache Secure: This profile only opens the door 443 It is advisable to enable the most restrictive profile that will still allow data traffic, since there is still no SLL configuration for the server, so you will only have to allow traffic on the port 80:
sudo utf allow 'Apache'

You can check the change by checking the status with the following command:

sudo utf status

APAI

Step 3: Web server verification

After the installation procedure, it starts automatically Apache, so the web server will be immediately active and working.

To make sure the service is active just run the command:

sudo systemctl status apache2

The output will confirm that the service has already been started correctly. However the best way to verify it is to request a page in Apache.

You can access the Apache default destination page to confirm that the software works properly through your IP address. If you do not know the address of your server, you can get it as follows:

hostname -I

APAI

As output you will get some addresses separated from spaces. Usually it should be the first if it were not proceeding with carrying out a check on the other addresses.

Obtained the server’s IP address, just enter it in the address bar of your browser:

http://{ip server}

You can view the default Ubuntu 22.04 Apache Web page

This page indicates that Apache works correctly. It also includes some basic information about important Apache files and directory locations.

Step 4: Apache Process Management

After making the web server active and working, you have to examine some basic management commands using systemctl.

To stop the web server:

sudo systemctl stop apache2

To start the web server when it is off:

sudo systemctl start apache2

To stop and restart the service:

sudo systemctl restart apache2

If you are making changes to the configuration, Apache can recharge without interrupting the connections:

sudo systemctl reload apache2

By default, Apache is configured to automatically start the server startup. If you want to change the rule:

sudo systemctl disable apache2

To reactivate the service at startup

sudo systemctl enable apache2

Step 5: Familiarity with important Apache files and directories

CONTENT

/var/www/html: the actual web content, which by default consists only of the default Apache page (previously presented). This setting can be changed by altering Apache configuration files.

SERVER CONFIGURATION

  • /etc/apache2: Apache configuration directory. All configuration files reside here.
  • /etc/apache2/apache2. config: the Apache main configuration file. This can be modified to make changes to the overall Apache configuration. This file is responsible for loading many other files in the configuration directory.
  • /etc/apache2/ports. ♪: This file specifies the doors on which Apache will listen. By default, Apache is listening to port 80 and is also listening to port 443 when a module that provides SSL functionality is enabled.

SERVER REGISTRIES

  • /var/log/apache2/access. log log: By default, each request to your web server is recorded in this log file unless Apache is configured to do otherwise.
  • /var/log/apache2/error.log: By default, all errors are recorded in this file. The Log in Apache configuration directive specifies how many details will contain error logs.

Step 6: Customize Web Space

In order to change the page that you have access to the IP address indicated before you have to make some very simple steps. All your HTML files must be inserted in the directory /var/www/html/, if no changes were made with the folders.

  • Delete or rename that index. html in that directory. (Probably you will have to do it in sudo mode via terminal, otherwise you just need to read/write/run all files within the html directory).
  • Place the HTML file desired that it must be the “Homepage” and make sure it is called index. html
  • That's enough. Enter the IP in the browser to see the HTML file.
EnglishenEnglishEnglish