During my time as a support engineer, as well as in the military, I saw several occasions where a system administrator was given the task of administering a system that they were unfamiliar with. It always went something like this: "The guy who used to own this system took another job and so they gave it to me until they find a replacement." I had this conversation more times than I could count when it came to storage systems, and unsurprisingly enough, web servers as well.
Imagine you are thrown into a situation like this. Your company's Apache admin takes another job, gets fired, etc. Your manager comes to you and says that he needs you to run the system until they can get a replacement. So what do you do? Where do you go for answers? What do you need to know for basic operation? These are all great questions that we will answer together.
For starters, we need to know what role Apache plays in the environment. Apache is an open-source web server that allows us to host content online. If we are visiting a site, it checks our information and then connects us to the web pages and content that we request. In my personal experience, the product that I supported used Apache to host web-based graphical interfaces so that our customers could manage their storage systems remotely. It allowed them to perform maintenance, upgrades, patches, etc. Now that we have a basic understanding of what Apache is and why we need it, let’s look at basic administration.
Turning services on and off
The most basic piece of information you would want to know as an administrator is whether or not the service is up and running. For all services, there are three basic commands that you need to get an accurate snapshot of that service's status. You also need to enable services (Apache is one of those). In this article, all commands are run in a Red Hat Enterprise Linux 8 environment.
To enable the Apache service we use the following command:
[root@rhel8dev ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Note: This must be done before you can start or configure the service.
Next, we will look at the status command:
[root@rhel8dev ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Active: inactive (dead)
Docs: man:httpd.service(8)
You can see from the output above that the service is down. To change that status, we need to run the service start command shown here:
[root@rhel8dev ~]# systemctl start httpd
Note: There is no output for start and stop commands.
Now, if we check the service's status with the command we saw previously, we can see that the service is up and running:
[root@rhel8dev ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Active: active (running) since Mon 2019-10-07 12:25:18 EDT; 1min 25s ago
Docs: man:httpd.service(8)
Main PID: 3349 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 18538)
Memory: 54.2M
CGroup: /system.slice/httpd.service
├─3349 /usr/sbin/httpd -DFOREGROUND
├─3350 /usr/sbin/httpd -DFOREGROUND
├─3351 /usr/sbin/httpd -DFOREGROUND
├─3352 /usr/sbin/httpd -DFOREGROUND
└─3353 /usr/sbin/httpd -DFOREGROUND
Oct 07 12:25:18 rhel8dev.test systemd[1]: Starting The Apache HTTP Server...
Oct 07 12:25:18 rhel8dev.test httpd[3349]: Server configured, listening on: port>
Oct 07 12:25:18 rhel8dev.test systemd[1]: Started The Apache HTTP Server.
To stop the service, use the following command:
[root@rhel8dev ~]# systemctl stop httpd
Again, you will see that there is no output associated with this command, so we need to use the status command to check that the "stop" was successful.
Open the firewall gates
As this is a web server, we need to make sure that the ports are open and listening for web traffic (HTTP and HTTPS). To enable these ports, we need to create a rule in the Linux firewall (as well as the company firewalls if applicable), as shown here:
[root@rhel8dev ~]# firewall-cmd --zone=public --permanent --add-service=http
success
[root@rhel8dev ~]# firewall-cmd --zone=public --permanent --add-service=https
success
[root@rhel8dev ~]# firewall-cmd --reload
success
Configuration and logs
Once you verify that everything is up and running, you may want (need) to change basic configuration settings. To do this, locate httpd.conf. By default, you will find it here:
[root@rhel8dev conf]# cd /etc/httpd/conf
[root@rhel8dev conf]# ls -lrt
total 28
-rw-r--r--. 1 root root 11899 Aug 29 11:15 httpd.conf
-rw-r--r--. 1 root root 13077 Aug 29 11:17 magic
Finally, when (not if) something goes wrong, you will want to know where to look to begin troubleshooting the issue. The two logs that you will want to view are error_log (which records all issues that occur and will sometimes generate a fix to be implemented) and access_log (which records all access request to the server and can also help in troubleshooting). By default, both of these files are found here:
[root@rhel8dev logs]# cd /etc/httpd/logs
[root@rhel8dev logs]# ls -lrt
total 4
-rw-r--r--. 1 root root 0 Oct 7 12:25 access_log
-rw-r--r--. 1 root root 1002 Oct 7 12:27 error_log
Additional resources
Hopefully, you will never find yourself in this situation. However, if you do, now you have the building blocks needed to get started with Apache administration. For more information (which you will need), please visit the official Apache documentation site here.
저자 소개
Tyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. Now that he has surfaced, he lives with his wife and son near Raleigh, where he worked as a data storage engineer before finding his way to the Red Hat team. He has written numerous technical documents, from military procedures to knowledgebase articles and even some training curricula. In his free time, he blends a passion for hiking, climbing, and bushcraft with video games and computer building. He is loves to read and enjoy a scotch or bourbon. Find him on Twitter or on LinkedIn.
유사한 검색 결과
Behind the scenes of RHEL 10, part 3
Alliander modernises its electricity grid with Red Hat for long-term reliability in balance with rapid innovation
The Overlooked Operating System | Compiler: Stack/Unstuck
Linux, Shadowman, And Open Source Spirit | Compiler
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래