Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
In this tutorial, we will learn how to install the Apache web server on a Linux system. We will cover installation steps for Ubuntu/Debian-based and CentOS/RHEL-based distributions.
sudo apt-get update
sudo apt-get install apache2
sudo systemctl status apache2
If Apache is running correctly, the output should show "active (running)".
sudo systemctl enable apache2
http://localhost
or http://your-server-ip
. You should see the Apache default welcome page, confirming that the installation is successful.sudo yum install epel-release
sudo yum update
sudo yum install httpd
sudo systemctl status httpd
If Apache is running correctly, the output should show "active (running)".
sudo systemctl enable httpd
http://localhost
or http://your-server-ip
. You should see the Apache default welcome page, confirming that the installation is successful.To allow incoming traffic to your web server on CentOS/RHEL-based systems, configure the firewall rules with the following commands:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Now your Apache web server should be accessible from external networks.
By following these steps, you can install and configure the Apache web server on your Linux system. You can then start building and deploying your web applications.
Setting up Apache on Ubuntu/Linux:
sudo apt-get update sudo apt-get install apache2
Installing Apache HTTP Server on CentOS:
yum
package manager to install Apache on CentOS.sudo yum install httpd
Apache installation steps on Debian/Linux:
apt
package manager to install Apache on Debian.sudo apt-get update sudo apt-get install apache2
Configuring Apache on Red Hat Linux:
/etc/httpd/
on Red Hat.sudo nano /etc/httpd/conf/httpd.conf
Apache web server installation commands for Linux:
apt
, yum
, etc.) for installation.sudo apt-get install apache2 # Ubuntu/Debian sudo yum install httpd # CentOS
Securing Apache server on Linux:
sudo ufw allow 80 # Allow HTTP traffic sudo ufw allow 443 # Allow HTTPS traffic
Starting, stopping, and restarting Apache in Linux:
sudo systemctl start apache2 # Start Apache sudo systemctl stop apache2 # Stop Apache sudo systemctl restart apache2 # Restart Apache
Apache virtual host setup on Linux:
sudo nano /etc/apache2/sites-available/example.com.conf
Enabling and disabling Apache modules in Linux:
a2enmod
and a2dismod
commands to manage Apache modules.sudo a2enmod ssl # Enable SSL module sudo a2dismod php7.4 # Disable PHP module
Checking Apache version on Linux:
apache2 -v
or httpd -v
command to check the Apache version.apache2 -v
Apache configuration files in Linux:
/etc/apache2/
or /etc/httpd/
.sudo nano /etc/apache2/apache2.conf
Common issues during Apache installation on Linux:
tail -f /var/log/apache2/error.log