Deploying static websites using Apache services

Configure the website service program first

Step 1: Mount the system image in the CD-ROM device into the / media/cdrom directory.

[root@LinuxLehehe ~]# mkdir -p /media/cdrom
[root@LinuxLehehe ~]# mount /dev/cdrom /media/cdrom
mount: /dev/sr0 is write-protected, mounting read-only

Step 2: Create configuration files for Yum repository using Vim text editor

[root@LinuxLehehe ~]# vim /etc/yum.repos.d/rhel7.repo
[rhel7]
name=rhel7
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

Step 3: Start installing Apache service program. Note that when installing with the yum command, the package name of the Apache service following the command is httpd. If the yum install apache command is executed directly, the system will report an error.

[root@LinuxLehehe ~]# yum install httpd
Loaded plugins: langpacks, product-id, subscription-manager
..................Eliminate part of output information............
Dependencies Resolved
===============================================================================
 Package Arch Version Repository Size
===============================================================================
Installing:
 httpd x86_64 2.4.6-17.el7 rhel 1.2 M
Installing for dependencies:
 apr x86_64 1.4.8-3.el7 rhel 103 k
 apr-util x86_64 1.5.2-6.el7 rhel 92 k
 httpd-tools x86_64 2.4.6-17.el7 rhel 77 k
 mailcap noarch 2.1.41-2.el7 rhel 31 k
Transaction Summary
===============================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 1.5 M
Installed size: 4.3 M
Is this ok [y/d/N]: y
Downloading packages:
..................Eliminate part of output information............
Complete!

Step 4: Enable the httpd service program and add it to the boot startup item to enable it to run with the system boot, thus continuing to provide Web services for users:

[root@LinuxLehehe ~]# systemctl start httpd
[root@LinuxLehehe ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.
target.wants/httpd.service'


When everything is ready, you can start demonstrating static web pages.

After doing this, refresh the httpd service program in Firefox browser, and you can see that the content of the first page of the program has changed, as shown in Figure 10-5.

[root@LinuxLehehe ~]# echo "Welcome To LinuxProbe.Com" > /var/www/html/index.html
[root@LinuxLehehe ~]# firefox

Keywords: Operation & Maintenance yum RHEL Apache vim

Added by pleigh on Tue, 01 Oct 2019 02:46:49 +0300