yukata

日々出会ったIT技術関連の所感やら紹介やら

XAMPPでApacheを起動して、http://localhost にアクセスしてからXAMPPのトップページが表示されるまで

WindowsでPHPをさわってみるためにXAMPPを入れてみました。http://localhostにアクセスするとまずXAMPPのページが表示されますが、これが表示されるまでの流れを書いておきます。Apacheをさわることがあまりないので、色々思い出すいい機会になりました。

もちろん、パスは違いますがLinuxもWindowsもMacも基本は同じです。ちなみにxamppは、Cドライブ直下にインストールしています。

まずはApacheの設定(C:\xampp\apache\conf\httpd.conf)で、

<IfModule dir_module>
	DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
               	default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
               	home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

となっているため、C:\xampp\htdocs\index.php が呼び出されます。

そして、C:\xampp\htdocs\index.php 内に書かれている、

header('Location: '.$uri.'/xampp/');

により、http://localhost/xampp/ にリダイレクトされます。

リダイレクト後は先ほどと同様の原理で、C:\xampp\htdocs\xampp\index.php が呼び出されます。

C:\xampp\htdocs\xampp\index.php 内ではbodyタグ内にはなにも記載されていませんが、headタグ内に、「frameset」というタグで、head.phpとnavi.php、start.phpが呼び出されて表示されます。これらphpで各コンテンツが表示されます。(framesetタグは、HTML5では廃止予定らしい。iframeとかに置き換えろと。)

C:\xampp\htdocs\xampp\index.php の内容は以下です。

<html>
<head>
<meta name="author" content="Kai Oswald Seidler">
<meta http-equiv="cache-control" content="no-cache">
<?php include("lang/".file_get_contents("lang.tmp").".php"); ?>
<title>XAMPP <?php include('.version');?></title>

<frameset rows="74,*" marginwidth="0" marginheight="0" frameborder="0" border="0" borderwidth="0">
	<frame name="head" src="head.php" scrolling=no>
<frameset cols="150,*" marginwidth="0" marginheight="0" frameborder="0" border="0" borderwidth="0">
	<frame name="navi" src="navi.php" scrolling=no>
	<frame name="content" src="start.php" marginwidth=20>
</frameset>
</frameset>
</head>
<body bgcolor=#ffffff>
</body>
</html>

この内容がXAMMPのトップページとなります。