Fedora36: Web server settings

httpd installation.

Install httpd.

[root@www ~]# dnf -y install httpd

Remove the welcome page.

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

Configure httpd.

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

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

ServerName fedoraserver.jp:80

Line 156: Change.

AllowOverride All

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

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

Line 321: Comment out to deal with garbled characters.

#AddDefaultCharset UTF-8

Edit document root owner (webmaster).

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

Check document root owner.

[root@www ~]# ll /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

Set the www of the URL.

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

Unify without www.

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

start up.

[root@www ~]# systemctl start httpd

Set auto start.

[root@www ~]# systemctl enable httpd

Create an HTML test page.

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

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

http://fedoraserver.jp

Webブラウザを起動

Open TCP port 80.

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

Port open test

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

Release confirmation site

Install Perl.

Install Perl.

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

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

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

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

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

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

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

Check your Perl path.

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

Restart.

[root@www ~]# systemctl restart httpd

Create a CGI test page.

[root@www ~]# vi /var/www/html/index.cgi
#!/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";

Set permissions.

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

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

http://fedoraserver.jp/index.cgi

Webブラウザを起動

PHP installation.

Install PHP.

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

Configure PHP.

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

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

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

Restart.

[root@www ~]# systemctl restart httpd

Create a PHP test page.

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

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

http://fedoraserver.jp/index.php

Webブラウザを起動

Install Ruby.

Install Ruby.

[root@www ~]# dnf -y install ruby

Restart.

[root@www ~]# systemctl restart httpd

Create a Ruby test page.

[root@www ~]# vi /var/www/html/index.rb
#!/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";

Set permissions.

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

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

http://fedoraserver.jp/index.rb

Webブラウザを起動

Install Perl modules.

Launch CPAN.

root@www:~# perl -MCPAN -e shell

Enter “y” and press Enter.

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

Check 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

Install the module.

[root@www ~]# 

Install ImageMagik.

Install ImageMagick.

[root@www ~]# dnf -y install ImageMagick

Install perl ImageMagick.

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

Obtaining a server certificate.

Install Certbot.

[root@www ~]# dnf -y install certbot

Get a certificate.

Document root: /var/www/html/

email address: webmasterfedoraserver.jp

Web server name: fedoraserver.jp

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

Configure automatic certificate renewal.

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

Add the following.

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

SSL settings.

Install SSL to enable encrypted communication.

[root@www ~]# dnf install mod_ssl

Configure SSL.

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

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

DocumentRoot "/var/www/html"

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

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

Line 101: Specify the obtained certificate.

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

Line 109: Specify the obtained key file.

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

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

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

Restart.

[root@www ~]# systemctl restart httpd

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

Free Monitoring Test Tools

コメント

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