s50
httpdのインストール.
httpd をインストールします。
[root@www ~]# 50_1dnf -y install httpd
s51ウェルカムページを削除します。
[root@www ~]# 51_1rm -f /etc/httpd/conf.d/welcome.conf
s52httpd を設定します。
[root@www ~]# 52_1vi /etc/httpd/conf/httpd.conf
s53100行目:行頭の「#」を削除してコメント解除し、サーバー名を指定します。
ServerName 53_1fedoraserver.jp:80
s54156行目:変更します。
AllowOverride 54_1All
s55169行目:ディレクトリ名のみでアクセスできるファイル名を追記します。
DirectoryIndex index.html 55_1index.cgi index.php index.rb index.py
s56321行目:行頭に「#」を追加して、コメントアウトして文字化け対応します。
56_1#AddDefaultCharset UTF-8
s57ドキュメントルート所有者を編集ユーザー(webmaster)に変更します。
[root@www ~]# 57_1chown webmaster. /var/www/html/
s58ドキュメントルート所有者を確認します。
[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
s59URLのwwwを設定します。
[root@www ~]# 59_1vi /etc/httpd/conf.d/virtualhost-00-fedoraserver.jp.conf
s60wwwなしに統一します。
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>
s61起動します。
[root@www ~]# 61_1systemctl start httpd
s62自動起動を設定します。
[root@www ~]# 62_1systemctl enable httpd
s63HTMLテストページを作成します。
[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>
s64Webブラウザを起動し、ページにアクセスし、動作確認をします。
http://fedoraserver.jp (http://192.168.1.3)
s65
TCP80番ポート開放.
ルーターの設定で、TCP80番ポートを開放します。(設定方法はご自身の環境に合わせて調べてください。)
ポート開放テスト.
開放確認サイトで「ホスト名(fedoraserver.jp)」、「ポート番号(80)」の開放確認をします。
開放確認サイトs66
Perlのインストール.
Perl をインストールします。
[root@www ~]# 66_1dnf -y install perl perl-CGI
s67「html」ディレクトリで CGI の実行を許可する設定をします。
[root@www ~]# 67_1vi /etc/httpd/conf.d/html.conf
s68拡張子 cgi、pl、rb、py を CGI として設定します。
68_1<Directory "/var/www/html">
Options +ExecCGI
AddHandler cgi-script .cgi .pl .rb .py
</Directory>
s69「/usr/local/bin/perl」で、Perlコマンドへアクセスできるようにします。
[root@www ~]# 69_1ln -s /usr/bin/perl /usr/local/bin/perl
s70Perlのパスを確認します。
[root@www ~]# 70_1whereis perl perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
s71再起動します。
[root@www ~]# 71_1systemctl restart httpd
s72CGIテストページを作成します。
[root@www ~]# 72_1vi /var/www/html/index.cgi 72_2#!/usr/bin/perl print "Content-type: text/html\n\n"; 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";
s73パーミッションを設定します。
[root@www ~]# 73_1chmod 705 /var/www/html/index.cgi
s74Webブラウザを起動し、ページにアクセスし、動作確認をします。
http://fedoraserver.jp/index.cgi (http://192.168.1.3/index.cgi)
s75
PHPのインストール.
PHP をインストールします。
[root@www ~]# 75_1dnf -y install php php-mbstring php-pear
s76PHP を設定します。
[root@www ~]# 76_1vi /etc/php.ini
s77927行目:行頭の「;」を削除してコメント解除し、自身のタイムゾーンを追記します。
date.timezone = 77_1"Asia/Tokyo"
s78再起動します。
[root@www ~]# 78_1systemctl restart httpd
s79PHPテストページを作成します。
[root@www ~]# 79_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>
s80Webブラウザを起動し、ページにアクセスし、動作確認をします。
http://fedoraserver.jp/index.php (http://192.168.1.3/index.php)
s81
Rubyのインストール.
Ruby をインストールします。
[root@www ~]# 81_1dnf -y install ruby
s82再起動します。
[root@www ~]# 82_1systemctl restart httpd
s83Rubyテストページを作成します。
[root@www ~]# 83_1vi /var/www/html/index.rb 83_2#!/usr/bin/ruby print "Content-type: text/html\n\n"; 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";
s84パーミッションを設定します。
[root@www ~]# 84_1chmod 705 /var/www/html/index.rb
s85Webブラウザを起動し、ページにアクセスし、動作確認をします。
http://fedoraserver.jp/index.rb (http://192.168.1.3/index.rb)
s91
Perlモジュールのインストール.
CPANを起動します。
[root@www ~]# 91_1perl -MCPAN -e shell
s92「y」を入力してEnterキー押下します。
Would you like to configure as much as possible automatically? [yes] 92_1y
s93チェックを入れて「OK」をクリックするとインストールログが表示されます。
s94モジュールをインストールします。
[root@www ~]# 94_1
s95
ImageMagikのインストール.
ImageMagickをインストールします。
[root@www ~]# 95_1dnf -y install ImageMagick
s96perl ImageMagickをインストールします。
[root@www ~]# 96_1dnf -y install ImageMagick-perl
s97
サーバー証明書の取得.
Certbotをインストールします。
[root@www ~]# 97_1dnf -y install certbot
s98証明書を取得します。
ドキュメントルート:/var/www/html/
メールアドレス:webmaster@fedoraserver.jp
Webサーバー名:fedoraserver.jp
[root@www ~]# 98_1certbot certonly --webroot -w /var/www/html/ -m webmaster@fedoraserver.jp -d fedoraserver.jp --agree-tos
s99証明書自動更新を設定します。
[root@www ~]# 99_1vi /etc/cron.d/letsencrypt
s100下記を追記します。
100_100 16 * * 2 root /usr/bin/certbot renew --post-hook "service httpd restart"
s101
SSLの設定.
SSLをインストールして、暗号化通信ができるように設定します。
[root@www ~]# 101_1dnf install mod_ssl
s102SSLを設定します。
[root@www ~]# 102_1vi /etc/httpd/conf.d/ssl.conf
s10359行目:行頭の「#」を削除してコメントを解除します。
DocumentRoot "/var/www/html"
s10475行目:行頭の「#」を削除してコメントを解除し、変更します。
SSLProtocol 104_1-All +TLSv1 +TLSv1.1 +TLSv1.2
s105101行目:取得した証明書を指定します。
SSLCertificateFile 105_1/etc/letsencrypt/live/fedoraserver.jp/cert.pem
s106109行目:取得した鍵ファイルを指定します。
SSLCertificateKeyFile 106_1/etc/letsencrypt/live/fedoraserver.jp/privkey.pem
s107118行目:行頭の「#」を削除してコメント解除し、取得した中間証明書を指定します。
SSLCertificateChainFile 107_1/etc/letsencrypt/live/fedoraserver.jp/chain.pem
s108再起動します。
[root@www ~]# 108_1systemctl restart httpd
s109下記のサイトで「https://fedoraserver.jp」の作動確認をします。
コメント