Click here for "Safe Air Conditioner Repair and Proper Freon Recovery".

Fedora35 : WEB Server

Apache2 installation and virtual host configuration

1.Apache2 installed

①Install httpd

# dnf -y install httpd

Version Check
# httpd -v
Server version: Apache/2.4.53 (Fedora Linux)
Server built: Mar 17 2022 00:00:00

2.Apache Configuration

①Edit "httpd.conf" file
# 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]
# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload
⑤Apache Autostart Configuration
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd
⑥operation check
If the Fedora Webserver Test Page is displayed as follows when accessing http://[server IP address], it is OK.
⑦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
# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org
Create HTML test page
# 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 domain name [fedora.korodes.com] to the document root [/var/www/html/fedora.korodes.com] directory for virtual host operation

# vi /etc/httpd/conf.d/vhost.conf
Virtual Host Domain Settings
<VirtualHost *:80>
DocumentRoot /var/www/html/fedora.korodes.com
ServerName fedora.korodes.com
ServerAdmin<Email Address>
ErrorLog logs/fedora.korodes.com-error_log
CustomLog logs/fedora.korodes.com-access_log combined
</VirtualHost>

<Directory "/var/www/html/fedora.korodes.com">
Options FollowSymLinks
AllowOverride All
</Directory>

Creating a Document Directory

# mkdir /var/www/html/fedora.korodes.com

Restart Apache

# systemctl restart httpd

Confirmation of CGI Script Usage

①CGI availability check

# 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/".

②Create test scripts and check operation

# vi /var/www/cgi-bin/index.cgi
#!/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

PHP installation and configuration

1.PHP Installation

①Install
# 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.
# 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 Sun 2022-05-15 09:48:09 JST; 7s ago
Main PID: 3386 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 4614)
Memory: 9.8M
CPU: 28ms
CGroup: /system.slice/php-fpm.service
tq3386 "php-fpm: master process (/etc/php-fpm.conf)"
tq3387 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" >
tq3388 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" >
tq3389 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" >
tq3390 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" >
mq3391 "php-fpm: pool www" "" "" "" "" "" "" "" "" "" "" "" "" "" >May 15 09:48:09 fedora systemd[1]: Starting The PHP FastCGI Process Manager...
May 15 09:48:09 fedora systemd[1]: Started The PHP FastCGI Process Manager.er.

③PHP operation check
Create the following files
# vi /var/www/html/<domain name>/test.php
<?php phpinfo(); ?>
Access http://<domain name>/test.php in your browser and if you see the following screen, it is OK
タイトルとURLをコピーしました