httpd installation.
Install httpd.
[root@www ~]# dnf -y install httpd
[root@www ~]# rm -f /etc/httpd/conf.d/welcome.conf
[root@www ~]# vi /etc/httpd/conf/httpd.conf
ServerName fedoraserver.jp:80
AllowOverride All
DirectoryIndex index.html index.cgi index.php index.rb index.py
#AddDefaultCharset UTF-8
[root@www ~]# chown webmaster. /var/www/html/
[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
[root@www ~]# vi /etc/httpd/conf.d/virtualhost-00-fedoraserver.jp.conf
<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>
[root@www ~]# systemctl start httpd
[root@www ~]# systemctl enable httpd
[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>
http://fedoraserver.jp
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.
Install Perl.
Install Perl.
[root@www ~]# dnf -y install perl perl-CGI
[root@www ~]# vi /etc/httpd/conf.d/html.conf
<Directory "/var/www/html">
Options +ExecCGI
AddHandler cgi-script .cgi .pl .rb .py
</Directory>
[root@www ~]# ln -s /usr/bin/perl /usr/local/bin/perl
[root@www ~]# whereis perl perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
[root@www ~]# systemctl restart httpd
[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";
[root@www ~]# chmod 705 /var/www/html/index.cgi
http://fedoraserver.jp/index.cgi
PHP installation.
Install PHP.
[root@www ~]# dnf -y install php php-mbstring php-pear
[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"
[root@www ~]# systemctl restart httpd
[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>
http://fedoraserver.jp/index.php
Install Ruby.
Install Ruby.
[root@www ~]# dnf -y install ruby
[root@www ~]# systemctl restart httpd
[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";
[root@www ~]# chmod 705 /var/www/html/index.rb
http://fedoraserver.jp/index.rb
Install Perl modules.
Launch CPAN.
root@www:~# perl -MCPAN -e shell
Would you like to configure as much as possible automatically? [yes] y
[root@www ~]#
Install ImageMagik.
Install ImageMagick.
[root@www ~]# dnf -y install ImageMagick
[root@www ~]# dnf -y install ImageMagick-perl
Obtaining a server certificate.
Install Certbot.
[root@www ~]# dnf -y install certbot
Document root: /var/www/html/
email address: webmaster@fedoraserver.jp
Web server name: fedoraserver.jp
[root@www ~]# certbot certonly --webroot -w /var/www/html/ -m webmaster@fedoraserver.jp -d fedoraserver.jp --agree-tos
[root@www ~]# vi /etc/cron.d/letsencrypt
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
[root@www ~]# vi /etc/httpd/conf.d/ssl.conf
DocumentRoot "/var/www/html"
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
SSLCertificateFile /etc/letsencrypt/live/fedoraserver.jp/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/fedoraserver.jp/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/fedoraserver.jp/chain.pem
[root@www ~]# systemctl restart httpd
コメント