Fedora36: Web server settings

s50

httpd installation.

Install httpd.

[root@www ~]# 50_1dnf -y install httpd

s51Remove the welcome page.

[root@www ~]# 51_1rm -f /etc/httpd/conf.d/welcome.conf

s52Configure httpd.

[root@www ~]# 52_1vi /etc/httpd/conf/httpd.conf

s53Line 100: Remove the “#” at the beginning of the line to uncomment it and specify the server name.

ServerName 53_1fedoraserver.jp:80

s54Line 156: Change.

AllowOverride 54_1All

s55Line 169: Add a file name that can be accessed only with the directory name.

DirectoryIndex index.html 55_1index.cgi index.php index.rb index.py

s56Line 321: Comment out to deal with garbled characters.

56_1#AddDefaultCharset UTF-8

s57Edit document root owner (webmaster).

[root@www ~]# 57_1chown webmaster. /var/www/html/

s58Check document root owner.

[root@www ~]# 58_1ll /var/www/
合計 0
drwxr-xr-x 2 root root 6 4月 24 22:46 cgi-bin
drwxr-xr-x 2 webmaster webmaster 6 4月 24 22:46 html

s59Set the www of the URL.

[root@www ~]# 59_1vi /etc/httpd/conf.d/virtualhost-00-fedoraserver.jp.conf

s60Unify without www.

60_1<VirtualHost *:80>
    ServerName fedoraserver.jp
    DocumentRoot /var/www/html
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.fedoraserver.jp
    RewriteRule ^(.*)$ http://fedoraserver.jp/$1 [R=301,L]
</VirtualHost>

s61start up.

[root@www ~]# 61_1systemctl start httpd

s62Set auto start.

[root@www ~]# 62_1systemctl enable httpd

s63Create an HTML test page.

[root@www ~]# 63_1vi /var/www/html/index.html
63_2<html>
<body>
<div style="width: 100%; font-size: 20px; font-weight: bold; text-align: center;">
Test Page
</div>
</body>
</html>

s64Start the web browser, access the page, and check the operation.

http://fedoraserver.jp

Webブラウザを起動s65

Open TCP port 80.

Open TCP port 80 in your router settings. (Check the setting method according to your own environment.)s66

Port open test

“Host name(fedoraserver.jp)” and “Port number (80)” are open.

Release confirmation site

s67

Install Perl.

Install Perl.

[root@www ~]# 67_1dnf -y install perl perl-CGI

s68Set to allow CGI execution in the “html” directory.

[root@www ~]# 68_1vi /etc/httpd/conf.d/html.conf

s69Set extensions cgi, pl, rb, py as CGI.

69_1<Directory "/var/www/html">
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl .rb .py
</Directory>

s70Allow access to Perl commands in “/usr/local/bin/perl”.

[root@www ~]# 70_1ln -s /usr/bin/perl /usr/local/bin/perl

s71Check your Perl path.

[root@www ~]# 71_1whereis perl
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz

s72Restart.

[root@www ~]# 72_1systemctl restart httpd

s73Create a CGI test page.

[root@www ~]# 73_1vi /var/www/html/index.cgi
72_2#!/usr/bin/perl

print "Content-type: text/htmlnn";
print "<html>n<body>n";
print "<div style="width: 100%; font-size: 20px; font-weight: bold; text-align: center;">n";
print "CGI Test Page";
print "n</div>n";
print "</body>n</html>n";

s74Set permissions.

[root@www ~]# 74_1chmod 705 /var/www/html/index.cgi

s75Start the web browser, access the page, and check the operation.

http://fedoraserver.jp/index.cgi

Webブラウザを起動s76

PHP installation.

Install PHP.

[root@www ~]# 76_1dnf -y install php php-mbstring php-pear

s77Configure PHP.

[root@www ~]# 77_1vi /etc/php.ini

s78Line 927: Remove the “;” at the beginning of the line, uncomment it, and add your own time zone.

PHP timezone list
date.timezone = 78_1"Asia/Tokyo"

s79Restart.

[root@www ~]# 79_1systemctl restart httpd

s80Create a PHP test page.

[root@www ~]# 80_1vi /var/www/html/index.php
79_2<html>
<body>
<div style="width: 100%; font-size: 20px; font-weight: bold; text-align: center;">
<?php
print "PHP Test Page";
?>
</div>
</body>
</html>

s81Start the web browser, access the page, and check the operation.

http://fedoraserver.jp/index.php

Webブラウザを起動s82

Install Ruby.

Install Ruby.

[root@www ~]# 82_1dnf -y install ruby

s83Restart.

[root@www ~]# 83_1systemctl restart httpd

s84Create a Ruby test page.

[root@www ~]# 84_1vi /var/www/html/index.rb
83_2#!/usr/bin/ruby

print "Content-type: text/htmlnn";
print "<html>n<body>n";
print "<div style="width: 100%; font-size: 20px; font-weight: bold; text-align: center;">n";
print "Ruby Test Page";
print "n</div>n";
print "</body>n</html>n";

s85Set permissions.

[root@www ~]# 85_1chmod 705 /var/www/html/index.rb

s86Start the web browser, access the page, and check the operation.

http://fedoraserver.jp/index.rb

Webブラウザを起動

Install Perl modules.

Launch CPAN.

root@www:~# 91_1perl -MCPAN -e shell

s92Enter “y” and press Enter.

Would you like to configure as much as possible automatically? [yes] 92_1y

s93Check it and click “OK” to display the installation log.

Module name explanation
All
Jcode Japanese character code conversion
Getopt::Long Process options in command line arguments
Archive::Tar Extract and create tar file (v5.10 or later)
Cwd Get current directory path
File::Basename Get File Basename and Directory Name
File::Copy Move and copy files
File::Path Creating and Deleting Multilevel Directories
File::Spec Portable handling of file names
File::Temp Create temporary files
File::Find File search
FindBin Get the path of the directory where the script resides
Encode Properly handle multibyte strings such as Japanese
utf8 Convert string in source code to internal string
Carp raise an exception from the perspective of the module caller
lib Add module search path
Time::Piece Standard module for handling date and time (core module from v5.10)
Time::Local Reverse return of localtime,gmtime
base class inheritance
Data::Dumper print the contents of the variable
Benchmark Benchmark (performance comparison)
JSON Parsing JSON data
MIME::Base64 Encode to Base64 format
MIME::QuotedPrint Encoding to quoted-printable format
Digest::MD5 Find MD5 value
Digest::SHA Find various SHA values ​​(v5.10 or later)
Storable Data serialization
Scalar::Util Utilities for scalar values
List::Util Various operations on arrays
Hash::Uti hash key limit
Sys::Hostname Get host name
Net::FTP FTP client
Net::Ping Existence check of remote host
Exporter Function export
CPAN Install modules from CPAN
Pod::Usage POD document output
Errno Constant representing the system error number
POSIX Functions defined by POSIX
Math::BigInt Big number math
Math::BigFloat Big number math
Mojolicious Web framework
Mojolicious::Plugin::AutoRoute Automatically generate routes
MIME::Lite Send email easily
Class::Accessor::Fast Creating accessors
Object::Simple Creating accessors with default values
DDP Output data
DBIx::Custom Easy database operation
MySQL::Diff Show MySQL diff
DateTime Generic handling of dates
PDL Statistical analysis
Imager Image editing
Text::CSV::Encoded Handle CSV files containing Japanese
Text::Diff Text difference confirmation
XML::Simple Simple XML parser
Validator::Custom HTML form validation
Data::Page Assisting with paging
Data::Page::Navigation Create page navigation
Module::Starter Create a template for the module
Devel::NYTProf Easy-to-use profiler
perltidy Formatting the source code
Net::Ping::External Ping command execution
IO::ScalarArray Automatic testing of standard input
IO::Capture Automatic testing of standard output and standard error outpu
FFI::Raw Call a function in a dynamic library
Math::Trig Various trigonometric functions
FFI::Platypus Feature rich FFI module
Time::Moment Fast date/time processing
CGI CGI module
CGI::Carp Write error logs to HTTPD (or other)
DBI Access various databases
strict Strict grammar check
LWP::UserAgent Access data on the web
LWP::Protocol::https Access SSL with LWP::UserAgent
Net::SSLeay Access SSL with LWP::UserAgent
Net::SSL Access SSL with LWP::UserAgent
Crypt::SSLeay Access SSL with LWP::UserAgent
Encode::Guess Determine character code
Image::ExifTool Get Exif information
Archive::Tar tar extract, create, add file
Image::Magick ImageMagick command line tools
Archive::Zip zip extract, create, add files

s94Install the module.

[root@www ~]# 94_1

s95

Install ImageMagik.

Install ImageMagick.

[root@www ~]# 95_1dnf -y install ImageMagick

s96Install perl ImageMagick.

[root@www ~]# 96_1dnf -y install ImageMagick-perl

s97

Obtaining a server certificate.

Install Certbot.

[root@www ~]# 97_1dnf -y install certbot

s98Get a certificate.

Document root: /var/www/html/

email address: webmasterfedoraserver.jp

Web server name: fedoraserver.jp

[root@www ~]# 98_1certbot certonly --webroot -w /var/www/html/ -m webmaster@fedoraserver.jp  -d fedoraserver.jp --agree-tos

s99Configure automatic certificate renewal.

[root@www ~]# 99_1vi /etc/cron.d/letsencrypt

s100Add the following.

100_100 16 * * 2 root /usr/bin/certbot renew --post-hook "service httpd restart"

s101

SSL settings.

Install SSL to enable encrypted communication.

[root@www ~]# 101_1dnf install mod_ssl

s102Configure SSL.

[root@www ~]# 102_1vi /etc/httpd/conf.d/ssl.conf

s103Line 59: Remove the “#” at the beginning of the line to uncomment it.

DocumentRoot "/var/www/html"

s104Line 75: Remove the “#” at the beginning of the line to uncomment it and change it.

SSLProtocol 104_1-All +TLSv1 +TLSv1.1 +TLSv1.2

s105Line 101: Specify the obtained certificate.

SSLCertificateFile 105_1/etc/letsencrypt/live/fedoraserver.jp/cert.pem

s106Line 109: Specify the obtained key file.

SSLCertificateKeyFile 106_1/etc/letsencrypt/live/fedoraserver.jp/privkey.pem

s107Line 118: Remove the “#” at the beginning of the line to uncomment it and specify the obtained intermediate certificate.

SSLCertificateChainFile 107_1/etc/letsencrypt/live/fedoraserver.jp/chain.pem

s108Restart.

[root@www ~]# 108_1systemctl restart httpd

s109“「https://fedoraserver.jp” operation check.

Free Monitoring Test Tools

コメント

タイトルとURLをコピーしました