LoginSignup
0

More than 3 years have passed since last update.

Apache2 の PHP で virtual を使う

Last updated at Posted at 2020-06-19

Apache2 の PHP で virtual を使う方法です。

参考情報
Apache 関数 > virtual

CGI スクリプトの場合、そのスクリプトは、有効な CGI ヘッダを
生成する 必要があることに注意してください。
最低でも、Content-Type ヘッダを生成する必要があります。 
test_virtual.php
<?php
// ------------------------------------------------------------------
//  test_virtual.php
// ------------------------------------------------------------------
echo '<!DOCTYPE html>';
echo '<html  lang="ja">';
echo "<head>";
echo '<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />';
echo "<title>virtual</title>";
echo "</head>";
echo "<body>";
echo "<h2>test_virtual.php</h2>";
echo "<blockquote>テスト</blockquote>";
virtual('./some_script.pl');
echo exec('whoami');
echo "<p></p>";
echo "<p>Mar/21/2021 AM 08:00</p>";
echo "</body>";
echo "</html>";
?>

some_script.pl
#! /usr/bin/perl
#
#   some_script.pl
#
print "Content-type: text/html; charset=utf-8\n\n";
print "Hello<br />\n";
print "おはようございます。<br />\n";
print "Good Morning<br />\n";
print "Jun/24/2020 AM 07:30<br />\n";
print "<p></p>\n";
#

ブラウザーで test_virtual.php にアクセスした結果
test_virtual_jun19.png

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