How to install and configure Apache Web Server in CentOS 7
To Install and configure Apache Web Server in Cent OS 7
Introduction
Apache is open-source software that is responsible for accepting directory (HTTP) requests from internet users and delivering their aspired information in the form of files and Web pages. There is a package named httpd. Installing command of apache web server
[root@linuxhelp ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Installed:
httpd.x86_64 0:2.4.6-97.el7.centos
Dependency Installed:
httpd-tools.x86_64 0:2.4.6-97.el7.centos
Complete!
Changing directory Command
[root@linuxhelp ~]# cd /etc/httpd
Listing Command
[root@linuxhelp httpd]# ls
conf conf.d conf.modules.d logs modules run
move to the conf directory
[root@linuxhelp httpd]# cd conf
[root@linuxhelp conf]# ls
httpd.conf httpd.conf.bkp magic
Opening the configuration file
[root@linuxhelp conf]# vi httpd.conf
[root@linuxhelp conf]# cd /var/www/html
[root@linuxhelp html]# vi index.html
[root@linuxhelp html]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.6.117 netmask 255.255.255.0 broadcast 192.168.6.255
inet6 fe80::20c:29ff:fe34:1bfa prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:34:1b:fa txqueuelen 1000 (Ethernet)
RX packets 4339 bytes 4780242 (4.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2357 bytes 187111 (182.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
checking firewall’s status
[root@linuxhelp html]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-08-31 04:03:53 EDT; 18min ago
Docs: man:firewalld(1)
Main PID: 6680 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─6680 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Aug 31 04:03:51 linuxhelp.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Aug 31 04:03:53 linuxhelp.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Stoping firewall and then check status
[root@linuxhelp html]# systemctl stop firewalld
[root@linuxhelp html]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Tue 2021-08-31 04:22:32 EDT; 3s ago
Docs: man:firewalld(1)
Process: 6680 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 6680 (code=exited, status=0/SUCCESS)
Aug 31 04:03:51 linuxhelp.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Aug 31 04:03:53 linuxhelp.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Aug 31 04:22:31 linuxhelp.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
Aug 31 04:22:32 linuxhelp.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
Checking httpd status
[root@linuxhelp html]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
starting and enabling the service
[root@linuxhelp html]# systemctl start httpd
[root@linuxhelp html]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
open the index.html file after chnges
[root@linuxhelp html]# vi index.html
with this, the installation of apache web server on centos comes to end.
Q
What do you understand by “DirectoryIndex”?
A
DirectoryIndex is the name of first file which Apache looks for when a request comes from a domain.
Q
Can we have two Apache Web servers on a single machine?
A
Yes, we can run two different Apache servers at one time on a Linux machine, but the condition for that is they should listen on different ports
Q
Where you can find all configuration directories of Apache Web Server?
A
By default Apache configuration directories installed under /etc/httpd/ on (RHEL/CentOS/Fedora) and /etc/apache2 on (Debian/Ubuntu).
Q
How would i change apache port number ?
A
You can change default to any other port in httpd.conf file of apache.
Q
What is apache by default port number?
A
Apachce uses port 80 as the default port number.