Apache web server is a free and open-source software for Unix based operating system. The Apache HTTPD is one of the most used webservers for the website.
Apache webserver has features like configurable error messages, content negotiation and DBMS-based authentication databases. The best part is that it supports a graphical user interface as well.
How to Install Apache on Linux
Prerequisites
Before we dive into the Apache webserver setup, first update the packages by running the following command:
For RHEL, run:
sudo yum check-update
sudo yum check-update | more
sudo yum check-update | grep bash
sudo yum check-update
You can install updates via yum command line:
sudo yum update
For Debian, Ubuntu:
sudo apt-get update && apt-get upgrade –y
Install Apache/Httpd service under Linux
To install the apache server in Fedora/RHEL/CentOS, run the following command.
up2date httpd
OR
yum install httpd
To start the Apache/httpd, run:
chkconfig httpd on
/etc/init.d/httpd start
To install apache server in Red Hat Enterprise Linux, you need to run the following command.
yum install httpd
To start the Apache/httpd, use the below-given command.
In the next step, we need to confirm whether the port 80 is open or not. To check that, run:
netstat -tulpn | grep :80
You can also install httpd from CDROM using rpm command:
rpm -ivh httpd*
Now we need to start the Apache web server, to do that, run:
chkconfig httpd on
/etc/init.d/httpd start
To install apache server in Debian Linux, Ubuntu Server, run the following command:
apt-get install apache2
/etc/init.d/apache2 start
Website Resources Location
The default location where you need to upload the files is under /var/www/html if you are using RHEL/CentOS/Fedora.
For Debian or Ubuntu, you need to upload files at /var/www/.
That’s it!
You’re done installing Apache Web Server on different Linux distributions using the command line.
I hope you will find this resource on how to install Apache Server in Linux useful.