1.Apache2
1.1 httpd Install
# dnf -y install httpd
Version Check
# httpd -v
Server version: Apache/2.4.63 (Oracle Linux Server)
Server built: Mar 6 2026 00:00:00
1.2 Apache Configuration
①Edit httpd.conf file
# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_org
# vi /etc/httpd/conf/httpd.conf
Line 91 : Specify administrator address
ServerAdmin <mail address>
Line 101 : Add
「#ServerName www.example.com:80」
ServerName <Domain>
Line 149 : Change (Indexes is deleted)
Options FollowSymLinks
Line 156 : Change
AllowOverride All
Line 169 : file name accessible only by directory name
Add "index.php index.cgi index.htm"
Add to the last line
ServerTokens Prod
②If Firewalld is enabled, HTTP service permission is required; HTTP uses [80/TCP]
# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload
➂Enabling and Starting Apache
# systemctl start httpd
# systemctl enable httpd
Startup Confirmation
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-07-17 12:31:59 JST; 57s ago
Invocation: 1bd7aa9b60b14e5b88787f7845fce1e0
Docs: man:httpd.service(8)
Main PID: 23280 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
Tasks: 177 (limit: 21555)
Memory: 13.8M (peak: 13.8M)
CPU: 139ms
CGroup: /system.slice/httpd.service
├─23280 /usr/sbin/httpd -DFOREGROUND
├─23281 /usr/sbin/httpd -DFOREGROUND
├─23282 /usr/sbin/httpd -DFOREGROUND
├─23283 /usr/sbin/httpd -DFOREGROUND
└─23284 /usr/sbin/httpd -DFOREGROUND
④operation check
If you access http://[server IP address] and you see the Oracle Apache2 Test Page as shown below, it is OK

⑤Hide the Oracle Welcome page, create a new index.html file as a Test Page, and check the operation of apache.
Rename the welcome page
# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org
Create HTML test page
# vi /var/www/html/index.html
Describe the following
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Apache Test Page
</div>
</body>
</html>
If you access http://[server IP] and the Test Page is displayed as shown below, it is OK.

1.3 Virtual Host Settings
Assign and configure the domain name [FQDN] to the document root [/var/www/html/[FQDN]] directory for virtual host operation
# vi /etc/httpd/conf.d/vhost.conf
Virtual Host Domain Settings
<VirtualHost *:80>
DocumentRoot /var/www/html/[FQDN]
ServerName [FQDN]
ServerAdmin <Email Address>
ErrorLog logs/[FQDN].error_log
CustomLog logs/[FQDN].access_log combined
</VirtualHost>
<Directory "/var/www/html/[FQDN]">
Options FollowSymLinks
AllowOverride All
</Directory>
Creating a Document Directory
# mkdir /var/www/html/[FQDN]
Restart Apache
# systemctl restart httpd
2. Confirmation of CGI Script Usage
①Confirmation of CGI availability
The following is displayed and available under “/var/www/cgi-bin/”.
# grep -n "^ *ScriptAlias" /etc/httpd/conf/httpd.conf
252: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
②Create test scripts and check operation
# vi /var/www/cgi-bin/index.cgi
Describe the following
#!/usr/bin/python3
print("Content-type: text/html\n")
print("CGI Script Test Page")
# chmod 755 /var/www/cgi-bin/index.cgi
# curl localhost/cgi-bin/index.cgi
CGI Script Test Page
3. PHP installation and configuration
①Install
# dnf -y install php php-mbstring php-pear
②Version Check
# php -v
PHP 8.3.29 (cli) (built: Dec 16 2025 14:32:42) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.3.29, Copyright (c) Zend Technologies
with Zend OPcache v8.3.29, Copyright (c), by Zend Technologies
Enable php-fpm
# systemctl enable php-fpm
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
③Restart Apache
After PHP installation, restarting Apache will invoke PHP-FPM (FPM : FastCGI Process Manager) by default, and php-fpm service will be started in conjunction with httpd startup.
# systemctl restart httpd
# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-07-17 12:42:46 JST; 6s ago
Invocation: ab690728a90c4999a17e56515208ed20
Main PID: 24868 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 21555)
Memory: 14.2M (peak: 14.5M)
CPU: 44ms
CGroup: /system.slice/php-fpm.service
├─24868 "php-fpm: master process (/etc/php-fpm.conf)"
├─24870 "php-fpm: pool www"
├─24871 "php-fpm: pool www"
├─24872 "php-fpm: pool www"
├─24873 "php-fpm: pool www"
└─24874 "php-fpm: pool www"
Jul 17 12:42:46 Lepard systemd[1]: Starting php-fpm.service - The PHP FastCGI Process Manager...
Jul 17 12:42:46 Lepard systemd[1]: Started php-fpm.service - The PHP FastCGI Process Manager.
④Confirmation of PHP operation
Create the following files
# vi /var/www/html/[FQDN]/test.php
Describe the following
<?php
phpinfo();
?>
Access http://[FQDN]/test.php in your browser and if you see the following screen, it is OK

4. Digest authentication with Apache2
Since Basic Authentication, a well-known authentication authorization method for http, sends authentication information in plain text, there is a risk of ID and password leakage if the packet is intercepted.
On the other hand, Digest Authentication encrypts and transmits authentication information, so there is almost no risk of information leakage.
4.1 Create password file for Digest authentication
Specify an authenticated area called realm. This realm allows the same directory to be accessed as authenticated.
For this example, the realm is "DigestAuth" and a user and password file named "secretuser" ".digestauth" is created.
# /usr/bin/htdigest -c /etc/httpd/.digestauth "DigestAuth" secretuser
New password:
Re-type new password:
Confirmation
# cat /etc/httpd/.digestauth
secretuser:DigestAuth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
As above, secretuser and encrypted password are created
4.2 Edit Apache configuration file
Specify the directory to which Digest authentication will be applied. (In this case, specify the "secret" directory.)
# vi /etc/httpd/conf/httpd.conf
Add the following at the end
<Directory "/var/www/html/[FQDN]/secret">
AuthType Digest
AuthName "DigestAuth"
AuthDigestDomain /[FQDN]/secret/
AuthUserFile "/etc/httpd/.digestauth"
Require valid-user
</Directory>
Create a directory for Digest authentication
# mkdir /var/www/html/[FQDN]/secret
Enable Digest authentication and reboot
# systemctl restart httpd.service
When accessing "http://[FQDN]/secret" with a browser, a screen appears asking for "user name" and "password".

