Linux Tutorials - Herong's Tutorial Examples - v1.32, by Dr. Herong Yang
Verify Apache Web Server "httpd"
Provides a tutorial example on how to manage Apache Web Server 'httpd' on CentOS 8 systems, and how to publish HTML documents and PHP scripts..
The Apache Web server, httpd, is included as part of the CentOS 8 system by default. You don't need to install it yourself. But you need to follow this tutorial to learn how to manage it.
1. Check Apache Web server, httpd, package status. I see "httpd 2.4" installed.
herong$ dnf info httpd Installed Packages Name : httpd Version : 2.4.37 Release : 16.module_el8.1.0+256+ae790463 Architecture : x86_64 Size : 5.4 M Source : httpd-2.4.37-16.module_el8.1.0+256+ae790463.src.rpm Repository : @System From repo : AppStream Summary : Apache HTTP Server URL : https://httpd.apache.org/ License : ASL 2.0 Description : The Apache HTTP Server is a powerful, efficient, and : extensible web server.
2. Check Apache Web server, httpd, running status:
herong$ sudo systemctl status httpd - httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; ... Drop-In: /usr/lib/systemd/system/httpd.service.d |-php-fpm.conf Active: active (running) since Sat 2020-03-28 22:06:40 EDT; 3min ... Docs: man:httpd.service(8) Main PID: 19007 (httpd) Status: "Total requests: 8; Idle/Busy workers 100/0;Requests/sec: ... Tasks: 213 (limit: 26213) Memory: 44.2M CGroup: /system.slice/httpd.service ...
3. Check default Web page from the Web server:
herong$ curl http://localhost ... <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE HTML> <html lang="en"> ...
3. Check Web server access log:
herong$ sudo tail /var/log/httpd/access_log ... "GET / HTTP/1.1" 403 4006 "-" "curl/7.61.1" ... "GET / HTTP/1.1" 403 4288 "-" "Mozilla/5.0 (X11; Linux x86_64; ... ... "GET /noindex/common/css/bootstrap.min.css HTTP/1.1" 200 99548 ... ... "GET /noindex/common/css/styles.css HTTP/1.1" 200 71634 ... ... "GET /noindex/common/images/pb-centos.png HTTP/1.1" 200 13122 ... ... "GET /noindex/common/images/pb-apache.png HTTP/1.1" 200 103267 ... ... "GET /noindex/common/images/centos-header.png HTTP/1.1" 200 28888 ...
4. Publish an HTML document:
herong$ ls -l /var/www/html/test.html -rw-r--r--. 1 root root 50 Mar 26 22:21 /var/www/html/test.html herong$ cat /var/www/html/test.html <html> <body> <p>Hello world!</p> </body> </html> herong$ curl http://localhost/test.html <html> <body> <p>Hello world!</p> </body> </html>
Cool. I am able to publish HTML documents to the Apache Web server, "httpd". Here are some additional information about "httpd":
All Apache configuration files are located in the /etc/httpd directory. The main Apache configuration file is /etc/httpd/conf/httpd.conf. Configuration files ending with .conf located in the /etc/httpd/conf.d directory are included in main Apache configuration file. Configuration files that are responsible for loading various Apache modules are located in the /etc/httpd/conf.modules.d directory. Apache vhost files must end with .conf and be stored in /etc/httpd/conf.d directory. You can have as many vhosts as you need. Creating a separate configuration file (vhost) for each domain makes the server easier to maintain. Apache log files (access_log and error_log) are located in the /var/log/httpd/ directory. You can set your domain document root directory to any location you want. The most common locations for webroot include: /home/<user_name>/<site_name> /var/www/<site_name> /var/www/html/<site_name> /opt/<site_name>
Table of Contents