Contents
Apache2 installation and virtual host configuration
1.Apache2 Install
①httpd install
| 1 | # dnf -y install httpd | 
Version Check
| 1 2 3 | # httpd -v erver version: Apache/2.4.54 (Fedora Linux) Server built:   Jun 17 2022 00:00:00 | 
2.Apache Configuration
①Edit "httpd.conf" file
		| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_bak # vi /etc/httpd/conf/httpd.conf ●Line 91 : Specify administrator address ServerAdmin [Email Address] ●Per line 100: Change ServerName Add "ServerName <domain name>" under "#ServerName www.example.com:80" ●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" ●Add to last line ServerTokens Prod | 
②If Firewalld is enabled, HTTP service permission is required; HTTP uses [80/TCP]
		| 1 2 | # firewall-cmd --add-service=http --permanent # firewall-cmd --reload | 
⑤Apache Autostart Configuration
		| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # systemctl start httpd # systemctl enable httpd # systemctl status httpd ● httpd.service - The Apache HTTP Server      Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor pre>      Active: active (running) since Mon 2022-10-17 14:49:32 JST; 15s ago        Docs: man:httpd.service(8)    Main PID: 1814 (httpd)      Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes>       Tasks: 177 (limit: 2274)      Memory: 14.3M         CPU: 280ms      CGroup: /system.slice/httpd.service              tq 1814 /usr/sbin/httpd -DFOREGROUND              tq 1816 /usr/sbin/httpd -DFOREGROUND              tq 1817 /usr/sbin/httpd -DFOREGROUND              tq 1818 /usr/sbin/httpd -DFOREGROUND              mq 1819 /usr/sbin/httpd -DFOREGROUND Oct 17 14:49:31 Lepard systemd[1]: Starting httpd.service - The Apache HTTP Ser> Oct 17 14:49:32 Lepard httpd[1814]: Server configured, listening on: port 80 Oct 17 14:49:32 Lepard systemd[1]: Started httpd.service - The Apache HTTP Serv> | 
⑥operation check
If the Fedora Webserver Test Page is displayed as follows when accessing http://[server IP address], it is OK.
If the Fedora Webserver Test Page is displayed as follows when accessing http://[server IP address], it is OK.

Ads are being blocked.
⑦Hide the Fedora Welcome page, create a new index.html file as a Test Page, and check the operation of apache.
Rename the welcome page
| 1 | # mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org | 
| 1 2 3 4 5 6 7 8 | # vi /var/www/html/index.html <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 address] and the Test Page is displayed as shown below, it is OK.


3.Virtual Host Settings
Assign and configure the [FQDN] to be operated on the virtual host in the document root [/var/www/html/FQDN] directory
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 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> | 
| 1 | # mkdir /var/www/html/<FQDN> | 
| 1 | # systemctl restart httpd | 
Confirmation of CGI Script Usage
①CGI availability check
		
| 1 2 3 | # grep -n "^ *ScriptAlias" /etc/httpd/conf/httpd.conf 252:    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" The above is displayed and available under "/var/www/cgi-bin/". | 
| 1 2 3 4 5 | # vi /var/www/cgi-bin/index.cgi #!/usr/bin/python3 print("Content-type: text/html\n") print("CGI Script Test Page") | 
| 1 | # chmod 755 /var/www/cgi-bin/index.cgi | 
| 1 2 | # curl localhost/cgi-bin/index.cgi CGI Script Test Page | 
Ads are being blocked.
PHP installation and configuration
1.PHP Installation
①Install
		| 1 | # dnf -y install php php-mbstring php-pear | 
②Restart Apache
After PHP installation, restart Apache and PHP-FPM (FPM : FastCGI Process Manager) will be invoked by default, and php-fpm service will be started in conjunction with httpd startup.
		| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # systemctl restart httpd # systemctl status php-fpm ● php-fpm.service - The PHP FastCGI Process Manager      Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor >      Active: active (running) since Mon 2022-10-17 15:00:37 JST; 8s ago    Main PID: 2456 (php-fpm)      Status: "Ready to handle connections"       Tasks: 6 (limit: 2274)      Memory: 10.0M         CPU: 225ms      CGroup: /system.slice/php-fpm.service              tq 2456 "php-fpm: master process (/etc/php-fpm.conf)"              tq 2457 "php-fpm: pool www"              tq 2458 "php-fpm: pool www"              tq 2459 "php-fpm: pool www"              tq 2460 "php-fpm: pool www"              mq 2461 "php-fpm: pool www" Oct 17 15:00:37 Lepard systemd[1]: Starting php-fpm.service - The PHP FastCGI P> Oct 17 15:00:37 Lepard systemd[1]: Started php-fpm.service - The PHP FastCGI Pr> | 
③PHP operation check
Create the following files
		Create the following files
| 1 2 | # vi /var/www/html/<FQDN>/test.php <?php phpinfo(); ?> | 
Access http://[FQDN]/test.php in your browser and if you see the following screen, it is OK


Ads are being blocked.

