PC関係のメモ
Booting Morphix from USB drives / 自宅サーバにPHPをインストール / htpasswd.php
Booting Morphix from USB drives
KNOPPIXから派生したCD bootable LinuxのMorphixをUSBメモリからブートさせる方法。「Booting Morphix from USB drives」より
Morphix 0.4-1c
This release has usb-booting included. Please note that this is for experimentation only.
MountUsb and copy the files in the cdrom image over to your usb stick:
- mount /dev/sda1 /mnt/auto/key1
- cp -a /cdrom /mnt/auto/key1/
For installing grub onto your usbkey: grub-install /dev/sda1
自宅サーバにPHPをインストール
debianにしてからPHPをインストールしてなかったので取り急ぎインストール
./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --enable-mbstring \ --enable-zend-multibyte \ --with-zlib \ --with-xml \ --with-gettext \ --enable-ftp \ --with-xmlrpc \ --with-gd \
マルチバイト正規表現の--enable-mbregexの指定はPHP4.3.4からmbstringと一緒に組み込まれるようになったので付けない。
いきなりエラー。
configure: error: cannot find output from lex; giving up
apt-get install flex して解決。
こんどは
configure: error: libpng.(a|so) not found.
とりあえず --with-gd を削除して対応。
またエラー
configure: error: XML-RPC support requires libexpat.
というわけで --with-xmlrpc も削除。
ここまででconfigureが通るようになった。次はmakeしてみると
make: *** [ext/mysql/php_mysql.lo] Error 1
と出たので --without-mysql でmysqlサポートをはずす。
最終的なconfigureオプションはこれ。
./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --enable-mbstring \ --enable-zend-multibyte \ --with-zlib \ --with-xml \ --with-gettext \ --enable-ftp \ --without-mysql
make;make install まで成功。
ついでなのでPEARをアップグレードしておく。pear upgrade-allは
requires package `Console_Getopt' >= 1.2 PEAR: Dependencies failed
と出て失敗。先にpear upgrade console_getoptしてからupgrade-allしたら成功。
教訓、debianではApacheもPHPもパッケージから入れたほうが良さそう
htpasswd.php
「PHP Dream - BASIC認証を行う」のスクリプトを参考に作成。シェルを使わないエンドユーザ用。
<html>
<head>
<title>htpasswd</title>
</head>
<body>
<form method="post" action="htpasswd.php">
Password:<input type="text" name="password"><br>
<input type="submit" name="submit">
<?php
if (isset($_POST['password'])) {
$password = $_POST['password'];
$salt = substr($password, 0, 2);
echo crypt($password, $salt);
}
?>
</form>
</body>
</html>
追記:
wakatonoさんとこで紹介されたのでちょっと補足。
.htpasswdを変更するのではなく、.htpasswdに書くための暗号化されたパスワードを作るためのスクリプトです。.htpasswdに
ユーザ:暗号化されたパスワード
の形式で書いてアップする必要あり。どっちかっていうとcrypt.phpだった。
ついでなのでほんとの(?)htpasswd.phpを作ってみた。20040304#p03


sds