In this tutorial, we will show you how to install Apache on Manjaro. In the vast realm of web hosting, Apache stands as a stalwart, serving millions of websites worldwide. If you’re a Manjaro Linux enthusiast, this guide is your roadmap to setting up an Apache web server, configuring a virtual host, managing your firewall, and fortifying your site with HTTPS using Certbot.
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 web server on a Manjaro Linux.
- A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- Ensure that your Manjaro system is connected to the internet. This is crucial as it allows you to download the required packages and the Apache installation.
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Apache on Manjaro
Step 1. Before diving into the Nmap installation, it’s crucial to make sure your Manjaro system is up to date. Open a terminal and execute the following commands:
sudo pacman -Syu sudo pacman -S base-devel
Step 2. Installing Apache on Manjaro.
Now, let’s install Apache:
sudo pacman -S apache
You’ll be prompted to confirm the installation. Type ‘
y‘ and press Enter.
After installation, verify that Apache is running:
sudo systemctl status httpd
You should see a message indicating that Apache is active and running. If not, start it with:
sudo systemctl start httpd
To ensure Apache starts automatically on system boot:
sudo systemctl enable httpd
Step 3. Creating a Virtual Host.
A virtual host allows you to host multiple websites on a single Apache server. Let’s create one:
First, create a directory for your website:
sudo mkdir -p /var/www/mywebsite
Set the permissions for your web directory:
sudo chown -R apache:apache /var/www/mywebsite
Now create a new virtual host configuration file:
sudo nano /etc/httpd/conf/extra/httpd-vhosts.conf
Add the following configuration for your virtual host, replacing ‘mywebsite’ and ‘example.com’ with your site’s details:
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/var/www/mywebsite" ServerName example.com ServerAlias www.example.com ErrorLog "/var/log/httpd/mywebsite-error_log" CustomLog "/var/log/httpd/mywebsite-access_log" common </VirtualHost>
Enable your virtual host:
sudo a2ensite mywebsite
Restart Apache for the changes to take effect:
sudo systemctl restart httpd
Step 4. Configuring the Firewall.
Manjaro uses the Uncomplicated Firewall (UFW) to manage firewall rules. Install UFW if it’s not already installed:
sudo pacman -S ufw
Start and enable UFW:
sudo ufw enable
Allow HTTP and HTTPS traffic:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp
You can check the status of UFW and the allowed rules:
sudo ufw status
Step 5. Securing the Website with HTTPS using Certbot.
Let’s Encrypt is a free, automated, and open certificate authority that provides SSL/TLS certificates. Certbot is a user-friendly tool that automates the process of obtaining and renewing these certificates.
Install Certbot for Apache using Pacman:
sudo pacman -S certbot-apache
To obtain SSL certificates for your virtual host, run:
sudo certbot --apache
Certbot will guide you through the process, including selecting the domains you want to secure.
The beauty of Let’s Encrypt is its automatic certificate renewal. However, it’s a good idea to test the renewal process. You can do this with a dry run:
sudo certbot renew --dry-run
To verify your SSL configuration, use an SSL checker tool such as Qualys SSL Labs. Enter your website’s URL, and it will perform an analysis, providing you with valuable insights into your SSL setup.
Step 7. Testing the HTTPS Setup.
Open your web browser and navigate to ‘
https://example.com.’ You should see a secure, green padlock icon in the address bar.
Step 8. Troubleshooting and Error Handling.
Common Apache Error Messages
- 500 Internal Server Error: A generic error that can result from various issues, such as misconfigurations, server overload, or faulty scripts.
- 403 Forbidden: This error occurs when the server denies access to a resource. Check file permissions and configuration.
- 404 Not Found: The server couldn’t locate the requested resource. Verify file paths and configuration.
- 502 Bad Gateway: Often seen when Apache acts as a proxy and can’t reach an upstream server. Check proxy settings and the health of the upstream server.
Diagnosing Apache Configuration Issues
apachectl utility to test your configuration:
sudo apachectl configtest
This command checks for syntax errors and reports any issues with your Apache configuration.
Congratulations! You have successfully installed Apache. Thanks for using this tutorial to install the latest version of the Apache web server on the Manjaro system. For additional help or useful information, we recommend you check the official Apache website.