業務用エアコン関連の技術情報、エラーコード、環境問題対策に関する別サイト「エアコンの安全な修理・適切なフロン回収」

RockyLinux9.7 : WEB Server(Apache2) & Virtual Hosts

1.Apache2 Install , Virtual Host Configuration

1.1 Apache2 Install

httpd Install

1.2 Apache Configuration

Edit httpd.conf file

Edited content

●Line 91: Administrator Address Specification
ServerAdmin [Email Address]
●Change the ServerName around line 100
Add "ServerName domain name" below "#ServerName www.example.com:80"
●Line 149: Change (Indexes removed)
Options FollowSymLinks
●Line 156: Change
AllowOverride All
●Line 169: File names 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]

Apache Auto-Start Configuration

Indicates content

httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-12-26 14:38:21 JST; 19s ago
Docs: man:httpd.service(8)
Main PID: 82057 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
Tasks: 177 (limit: 16855)
Memory: 14.1M (peak: 14.3M)
CPU: 53ms
CGroup: /system.slice/httpd.service
├─82057 /usr/sbin/httpd -DFOREGROUND
├─82058 /usr/sbin/httpd -DFOREGROUND
├─82059 /usr/sbin/httpd -DFOREGROUND
├─82060 /usr/sbin/httpd -DFOREGROUND
└─82061 /usr/sbin/httpd -DFOREGROUND

Dec 26 14:38:21 Lepard systemd[1]: Starting The Apache HTTP Server…
Dec 26 14:38:21 Lepard httpd[82057]: Server configured, listening on: port 80
Dec 26 14:38:21 Lepard systemd[1]: Started The Apache HTTP Server.

operation check
If you access http://[server IP address] and see the RockyLinux Test Page as shown below, it is OK.

⑤Hide the Welcome page, create a new index.html file as a Test Page, and check apache operation

Rename the welcome page

Create an HTML test page

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

Creating a Document Directory

Restart Apache

2. Use of CGI Scripts

①CGI availability check

②Create test scripts and check operation

3. PHP installation and configuration

3.1.PHP8 Install

①Install

Version Check

If you are installing Php8.4, you will need the Remi repository, so install it if you have not already done so.

Stop PHP once

PHP 8.4 Install

php-fpm configuration

Apache Restart
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.

Confirmation of PHP operation
Create the following files

If you access http://[FQDN]/test.php in your browser and 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.

Confirmation

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.)

Add the following at the end

Create a directory for Digest authentication

Enable Digest authentication and reboot

When accessing http://[FQDN]/secret with a browser, a screen appears asking for "user name" and "password".

Copied title and URL