0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows版MAMPでPerlをとりあえず動かしてみる

0
Posted at

目的

ローカルでPerl/CGIを動かしたい。
XAMPPもあるけど、MacOSで慣れ親しできたMAMPをWindowsでも使いたい。

そんな自分への忘備録。

事前準備

  • MAMPのインストール・httpd-vhosts.confの設定など
  • hostsファイルの設定
  • .cgiの有効化

上記は
https://pc-karuma.net/mamp-settings-mac/
https://qiita.com/tsukishimaao/items/cab4caa065d901608856
https://www.be-webdesigner.com/technotes/server/httpd_conf/cgi.htm (CGIの実行許可を与える、まで設定)
この辺見てペペッと設定しちゃってください。

ちなみに、

httpd-vhosts.conf
<VirtualHost XX.XXX.XXX.XXX:80>
    DocumentRoot "C:\任意のサイトまでのディレクトリパス"
    ServerName test-tarochan.local # てきとう
    ErrorLog "C:\任意のディレクトリパス\log\error.log"
    <Directory "C:\任意のサイトまでのディレクトリパス">
        Options Indexes FollowSymLinks ExecCGI
    </Directory>
</VirtualHost>

IP(XX.XXX.XXX.XXX)は自分のローカルを指しておくと
同じネットワークに入っているひとに見せたり、スマホで確認できたりします。
細かいところは割愛します。

トラブル

そのまま、下記ファイルを作ってtest-tarochan.local/test.cgiにアクセスすると
500 internal server errorになります。#!/usr/local/bin/perlパスがあっていないっぽい。(コピペだし)

test.cgi
# !/usr/local/bin/perl

print "Content-type:text/plain\n\n";
print "Hello World";

MacOSの場合はusr/bin/perlにしてくださいね~と
リソース豊富ですが、WindowsMAMPPerlはなかなか見つからない。
MAMPの中でperlを検索すると実体は置いてあるっぽい...

やっと惜しいラインみつけたと思ったのが
https://documentation.mamp.info/en/MAMP-PRO-Windows/Languages/Perl/
MAMP Proの説明下部分。このパスに変えてみる。動かない。

解決

結局のところ下記のパスでいけました。

test.cgi
# !C:\MAMP\bin\perl\bin\perl.exe

print "Content-type:text/plain\n\n";
print "Hello World";

これが正しい書き方なのかは微妙ですが、
https://stackoverflow.com/questions/7860380/how-do-i-run-perl-files-over-xampp-on-windows/7860435
上記XAMPPへの質問からエキスもらって、試したらいけました。

おまけ

Active PerlなるものがWindowsにインストールできるって資料はあったので、そうしたらいいんじゃないかと思いつつ
Perl/がMAMPの中にあるのに使えないなんてことあるの!? と、あきらめない気持ち...... ( ・ิω・ิ)

さて、バックエンドの勉強をしますか。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?