Debian11.2にPerl をインストールする方法

環境
OSバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/debian_version
11.2
# cat /etc/debian_version 11.2
# cat /etc/debian_version
11.2

apache2バージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# apache2 -v
Server version: Apache/2.4.53 (Debian)
Server built: 2022-03-14T16:28:35
# apache2 -v Server version: Apache/2.4.53 (Debian) Server built: 2022-03-14T16:28:35
# apache2 -v
Server version: Apache/2.4.53 (Debian)
Server built: 2022-03-14T16:28:35

Perlのインストール手順
1.Perl をインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# apt -y install perl libcgi-pm-perl
# apt -y install perl libcgi-pm-perl
# apt -y install perl libcgi-pm-perl

2.CGI モジュールを有効にします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# a2enmod cgid
Enabling module cgid.
To activate the new configuration, you need to run:
systemctl restart apache2
# a2enmod cgid Enabling module cgid. To activate the new configuration, you need to run: systemctl restart apache2
# a2enmod cgid
Enabling module cgid.
To activate the new configuration, you need to run:
  systemctl restart apache2

3.apache2を再起動します
# systemctl restart apache2

4.テストスクリプトを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat > /usr/lib/cgi-bin/test_script <<'EOF'
> #!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello CGI\n";
EOF
# cat > /usr/lib/cgi-bin/test_script <<'EOF' > #!/usr/bin/perl print "Content-type: text/html\n\n"; print "Hello CGI\n"; EOF
# cat > /usr/lib/cgi-bin/test_script <<'EOF'
> #!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello CGI\n";
EOF

5.スクリプトの権限を付与します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# chmod 705 /usr/lib/cgi-bin/test_script
# chmod 705 /usr/lib/cgi-bin/test_script
# chmod 705 /usr/lib/cgi-bin/test_script

動作確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# curl http://localhost/cgi-bin/test_script
Hello CGI
# curl http://localhost/cgi-bin/test_script Hello CGI
# curl http://localhost/cgi-bin/test_script
Hello CGI

 

Debian 11

Posted by arkgame