How to install Apache Server in Linux
The Apache webserver is a open source HTTP Server for Linux and windows.
Debian and Ubuntu distributions refer to Apache as “Apache2” and the configuration file of Apache2 is /etc/apache2/apache2.conf
.
CentOS/RHEL refer to Apache as httpd
and configuration file of httpd is /etc/httpd/httpd.conf.
The default document root is
/var/www/html
in all distributions.
For Cent OS / RHEL
Apache Installation
Run the below command for installation
1 |
# yum install httpd |
Apache doesn’t start automatically. Run the below command for start the Apache Server.
1 |
# service httpd start |
To check the current running status of the Apache server, Run the below command
1 |
# service httpd status |
For Restart the Apache Server run the below command.
1 |
# service httpd restart |
For Stop the Apache Server run the below command.
1 |
# service httpd stop |
Ubuntu & Debian
Apache Installation
Run the below command for installation
1 |
# apt-get install apache2 |
Run the below command for start the Apache Process.
1 |
# /etc/init.d/apache2 start |
To check the current running status of the Apache server, Run the below command
1 |
# /etc/init.d/apache2 status |
For Restart the Apache Server run the below command.
1 |
# /etc/init.d/apache2 restart |
For Stop the Apache Server run the below command.
1 |
# /etc/init.d/apache2 stop |