ServerId = webuser
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log
Binding {
Port = 80
Interface = 127.0.0.1
}
Binding {
BindingId = CGI
Port = 8080
Interface = 192.168.1.2xx
MaxRequestSize = 128
TimeForRequest = 3,20
}
Hostname = localhost
WebsiteRoot = /root/Web-Server
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
MimetypeConfig = /etc/mime.types
CGIhandler = /usr/bin/perl:pl,cgi
CGIhandler = /usr/bin/php-cgi:php,html
CGIextension = pl,bin,cgi
ExecuteCGI = yes
SecureURL = no
FastCGIserver {
FastCGIid = PHP7
ConnectTo = /run/php/php-fpm.sock
Extension = php
SessionTimeout = 30
}
Virtualhost{
RequiredBinding = CGI
Hostname= 192.168.1.2xx
WebsiteRoot= /var/www/hiawatha
StartFile = index.php
showIndex = no
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
UseFastCGI = PHP7
UseXSLT = yes
ExecuteCGI = yes
TimeForCGI = 10
}
/usr/bin/php-cgi というファイル(リンク)を作成するために ターミナルから 以下を実行
# ln -s /usr/bin/php-cgi7.4 /usr/bin/php-cgi
/run 配下に /php というディレクトリを作成し(/run/php)、そこに php7.4-fpm.sock という空のファイルを作成する。
ここで以下を実行してみる。
root# systemctl status php7.4-fpm.service php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.4-fpm.service, disabled) Active: inactive (dead) #・・・または Active: failed (failed)などとなって active にはならない。 そこで BootManager で php7.4-fpm のチェックを外す。(OSを再起動する) www-data というユーザーを加える。
root# adduser www-data passwd: /etc/shadow: bad record passwd: /etc/shadow: bad record passwd: /etc/shadow: bad record Changing password for www-data New password: #<-- ここにパスワード入力(www-data とか適当に)> Retype password: passwd: password for www-data changed by rootここでサービスを再起動するために、再度 以下を実行する。
root# systemctl restart php7.4-fpm.service root# systemctl status php7.4-fpm.service php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager Loaded: loaded (/lib/systemd/system/php7.4-fpm.service, disabled) Active: active (running) #<-- active(running) となった -->となれば、hiawathaサーバー上で phpが実行されているので、例えば 以下のような test.html を作成し
<!DOCTYPE html> <html> <head> <title>PHP test</title> </head> <body> <?php echo "Congraturations! PHP script running!"; ?> </body> </html>http://localhost/test.html にアクセスして Congraturations! PHP script running! と表示されれば htmlファイル中で phpスクリプトが実行されていることが分かる。
#!/usr/bin/perl -w print "Content-type: text/html\n\n"; print '<meta charset="UTF-8">'; print '<HTML><BODY bgcolor="dfdfff">'; print "<h2> Hello world</h2>"; print "<b>\これが表示されたら Perl は正常に実行されています</b><br>\n"; print "<p style='color: blue;font-weight: bold;'> file path: /root/Web-Server/cgi_check.pl</p>"; print "</BODY></HTML>"; exit;その上で http://localhost/cgi_check.pl にアクセスして
Access Counter: