UbuntuでCGIを設定する方法は?

UbuntuでCGIを設定する方法は?

最近、UbuntuにApache2をインストールしてCGIを設定しようとしました。 apache2.conf ファイルに次の行を追加しました。

ScriptAlias  /cgi-bin/ /home/router/cgi-bin/

<Directory /home/router/cgi-bin/>
        Options ExecCGI
        AddHandler cgi-script cgi pl
</Directory>

apache2を保存して再起動しましたが、ブラウザに次のように入力すると次のようになります。

http://192.168.1.1/cgi-bin/file1.cgi 

次のエラーが発生します。

You don't have permission to access /cgi-bin/file1.cgi on this server.

ベストアンサー1

次のコマンドを使用してApache CGIサポートを有効にする必要があります。

sudo a2enmod cgi
sudo service apache2 restart

.cgi拡張子が.plファイルではないため、元のAddHandler行も必要ありません。

私はあなたも同じことを提案します:

ScriptAlias​/cgi-bin/ /home/router/cgi-bin/

<Directory /home/router/cgi-bin>
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

おすすめ記事