Linux MintUbuntu Based

How To Install Apache on Linux Mint 22

Install Apache on Linux Mint 22

In this tutorial, we will show you how to install Apache on Linux Mint 22. Apache HTTP Server, often simply called Apache, is the world’s most widely used web server software. It’s open-source, reliable, and highly customizable, making it an ideal choice for both beginners and experienced developers. Installing Apache on Linux Mint 22 opens up a world of possibilities for hosting websites, testing web applications, and learning about server administration.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Apache HTTP server on Linux Mint 22.

Prerequisites

  • A server running one of the following operating systems: Linux Mint 22.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
  • An active internet connection.
  • Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.

Install Apache on Linux Mint 22

Step 1. Update Your Linux Mint System.

Keeping your system updated is crucial for security and performance. Before installing any new software, it’s a good practice to update your package repository and upgrade existing packages. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade

The sudo apt update command fetches the latest package lists from the repositories, while sudo apt upgrade installs the newest versions of all packages currently installed on your system. This step ensures that you have the latest software and security patches.

Step 2. Installing Apache HTTP Server.

With your system updated, you can now proceed to install Apache. Execute the following command in the terminal:

sudo apt install apache2

This command will install the Apache HTTP Server along with its dependencies. Once the installation is complete, you can verify that Apache is installed correctly by checking its status:

sudo systemctl status apache2

You should see an output indicating that the Apache service is active and running. If there are any issues, the status command will provide details that can help in troubleshooting.

After installing Apache, you need to start the service and enable it to start automatically on the system boot. Use the following commands:

To start Apache:

sudo systemctl start apache2

To enable Apache to start on boot:

sudo systemctl enable apache2

These commands ensure that Apache is running and will automatically start whenever your system boots up. You can verify that Apache is running by navigating to http://localhost in your web browser. You should see the default Apache2 Ubuntu Default Page, indicating that the server is up and running.

Install Apache on Linux Mint 22

Step 3. Configure Apache.

Apache’s configuration files are located in the /etc/apache2 directory. The main configuration file is apache2.conf, but you will also find additional configuration files and directories such as sites-available and sites-enabled.

  • Basic Configuration

To edit the main configuration file, use a text editor like nano:

sudo nano /etc/apache2/apache2.conf

Here, you can adjust various settings to optimize and secure your server. For example, you might want to disable directory listing for security reasons. Add or modify the following directive:

Options -Indexes
  • Setting Up Virtual Hosts

Virtual hosts allow you to host multiple websites on a single server. To create a new virtual host, navigate to the sites-available directory and create a new configuration file:

sudo nano /etc/apache2/sites-available/example.com.conf

Add the following configuration to the file:

<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file. Next, enable the new virtual host and reload Apache:

sudo a2ensite example.com.conf
sudo systemctl reload apache2

Ensure that the document root directory exists and has the correct permissions:

sudo mkdir -p /var/www/example.com
sudo chown -R $USER:$USER /var/www/example.com
sudo chmod -R 755 /var/www/example.com

Step 4. Verify Apache Installation.

To confirm that Apache is installed and running correctly, open a web browser and navigate to http://localhost. You should see the default Apache2 Ubuntu Default Page. This indicates that Apache is serving web pages correctly. If you have set up a virtual host, you can test it by adding an entry to your /etc/hosts file:

sudo nano /etc/hosts

Add the following line:

127.0.0.1 example.com

Save the file and exit the editor. Now, you can access your virtual host by navigating to http://example.com in your web browser.

Step 5. Configure Firewall Settings.

Linux Mint comes with a firewall called UFW (Uncomplicated Firewall). If you have UFW enabled, you’ll need to allow incoming connections to Apache. Apache registers itself with UFW upon installation, making the process simple:

sudo ufw allow 'Apache'

This command allows incoming HTTP (port 80) and HTTPS (port 443) traffic. To verify the changes, you can check the UFW status:

sudo ufw status

You should see Apache listed in the allowed applications.

Congratulations! You have successfully installed Apache. Thanks for using this tutorial to install the latest version of the Apache web server on the Linux Mint system. For additional help or useful information, we recommend you check the official Apache website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button