How to Install Apache on Linux Mint 19

The Apache HTTP server is the most popular web server in the world. It is a free, open-source and cross-platform HTTP server a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

In this article is going to show you how to install and manage the Apache web server on Linux Mint 19.

Prerequisites

Before you start install PHP on Linux Mint 19, you must have an account with sudo privilegesand make sure your Linux Mint 19 server can access the Internet.

Install Apache On Linux Mint 19

Apache is available in the default Linux Mint repositories. So in this tutorial, we will install it using the apt package management tool.

First, update the package index by typing the following commands:

sudo apt update

In Debian based system the Apache package and the service is called apache2.So to install apache package on Linux Mint 19 you have to run below command:

sudo apt install apache2

After completion of the above command,Apache is installed and automatically started.You can do this by typing the following command to check apache service status:

sudo systemctl status apache2

The output look like:

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           `-apache2-systemd.conf
   Active: active (running) since Sun 2019-05-06 08:24:35 PDT; 2min 41s ago
 Main PID: 3143 (apache2)
    Tasks: 55 (limit: 2321)
   CGroup: /system.slice/apache2.service
           |-3143 /usr/sbin/apache2 -k start
           |-3144 /usr/sbin/apache2 -k start
           `-3145 /usr/sbin/apache2 -k start

Adjust the Firewall

By Defualt,the Linux Mint 19 firewall is turned on.you will need to open HTTP and HTTPS ports.

If your HTTP and HTTPS ports are open,you don`t need to adjust your firewall configuration,you can skip this step.

You can open HTTP and HTTPS ports for Apache by typing the following command:

sudo ufw allow 'Apache Full'

You can verify change by following command:

sudo ufw status

The output should look like:

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache Full                ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache Full (v6)           ALLOW       Anywhere (v6)

Verifying the Apache Installation

Open your browser and type the address URL http://your_server_ip/ or http://your_server_domain/ ,then you will see the default Linux Mint 19 Apache welcome page as shown below:

The page includes some basic information about Apache configuration files, helper scripts, and directory locations.

Apache Configuration File’s Structure

  • Apache configuration files adirectory: /etc/apache2.
  • The main Apache configuration file: /etc/apache2/apache2.conf.
  • The ports that Apache will listen to are specified :/etc/apache2/ports.conf.
  • Apache Virtual Hosts files directory:/etc/apache2/sites-available . The configuration files found in this directory are not used by Apache unless they are linked to the /etc/apache2/sites-enabled directory.
  • To activate a virtual host you need to create a symlink by using the a2ensitecommand from the configuration files found in the sites-available directory to the sites-enabled directory. To deactivate a virtual host use the a2dissitecommand.
  • It is a good idea to follow a standard naming convention. For example, if your domain name is mydomain.com then the virtual host configuration file should be named /etc/apache2/sites-available/mydomain.com.conf
  • Configuration files which are responsible for loading various Apache modules are located in the /etc/apache2/mods-available/directory. Configurations in the mods-available directory can be enabled by creating a symlink to the /etc/apache2/mods-enable/directory with the a2enconf command and disabled with the a2disconf command.
  • Files containing global configuration fragments are stored in the /etc/apache2/conf-available/ directory. Files in the conf-available directory can be enabled by creating a symlink to the /etc/apache2/conf-enabled/ with the a2enconf command and disabled with the a2disconf command.
  • Apache log files (access.log and error.log) are located in the /var/log/apache/ directory. It is recommended to have different access and error log files for each vhost.
  • You can set your domain document root directory to any location you want. The most common locations for webroot include:
    • /home/<user_name>/<site_name>
    • /var/www/<site_name>
    • /var/www/html/<site_name>
    • /opt/<site_name>

Conclusion

You have learned how to install Apache on Linux Mint 19 server. You can now log in to your Linux Mint to try it.

If you have any question about this tutorial please don’t forget to leave a comment.

Leave a Reply