Last Modifide Thursday, 17-Feb-2005 10:17:33 JST

����/HG(KURO-BOX/HG) - MySQL / PHP4 / perl5.6

MySQL / PHP4 / perl5.6 �̓���

MySQL

�p�b�P�[�W�̃C���X�g�[��

  • apt-get�ŃC���X�g�[��
    # apt-get install mysql-server mysql-client mysql-doc
  • �C���X�g�[�����̎���ɑ΂���
    Remove all databases sfter "purging" the mysql-server package? ��No(default)
    Should MySQL start on boot? ��Yes(not default)

�ݒ�

  • �f�t�H���g�̃��[�U
    UserNamePasswdHostGrant�p�r
    root@localhost-localhost�S���Ǘ����[�U�[
    @localhost-localhosttest*�ɑ΂��đS�Ă̑���localhost�̓������[�U�[
    debian.....-localhost�cDebian����̃R���g���[��
���̉��c�o��ł̃��������ł��B�B�B(^-^;

���[�U�[�̓o�^�ƌ���

mysql�R�}���h��root�����Ŏg�p���āA�V�������[�U�[���쐬����B���[�J���z�X�g����ڑ����郆�[�U�[�ŁA�����͗^���Ȃ�(USAGE)�Ōォ��DB���x���ATABLE���x���̌�����^����悤�ɂ���B
mysql> grant USAGE on *.* to user@localhost;
mysql> grant ALL on user_db.* TO 'user'@'localhost'; �� user �ɑ΂�user_db �ւ̌�����^����
MySQL�̃��[�U�[��linux���[�U�Ƃ͕ʂɓo�^����Blinux�̃��[�U�Ƃ͊��S�ɐ؂藣���čl���Ă悢�i�������O�ɂ��邱�Ƃ͂����Ă��j�B�o�^���ꂽ���[�U�ɑ΂��Ă͓K���Ȍ�����^����B�f�[�^�x�[�X�������Ă��f�[�^�x�[�X���x���̌�����ݒ�ł���̂ŁA�f�[�^�x�[�X�o�^�ƌ����̐ݒ�͂ǂ��炪��ł��ǂ�

�f�[�^�x�[�X�̓o�^�ƌ���

�V�K�̃f�[�^�x�[�X��mysqladmin�R�}���h�ō쐬����B�����̂��郆�[�U�[�ȊO�̓f�[�^�x�[�X���쐬�ł��Ȃ��Bmysql�R�}���h�ł� create database...
mysql> create database user_db;
�f�[�^�x�[�X���͑啶���Ə���������ʂ����

���̑��i���[�U�[�f�[�^�x�[�X�̍l�����j

�����^���X�y�[�X�Ȃǂł̃f�[�^�x�[�X�g�p�́A���[�U���ɗB��̃f�[�^�x�[�X���쐬���ĕ����̃e�[�u�����e���[�U�[���쐬���Ďg�p����B���̏ꍇ�A�f�[�^�x�[�X�̃T�C�Y��e�[�u�����Ȃǂ̐�����������B���̃f�[�^�x�[�X�͂��̃T�[�o�[(localhost)���烆�[�U�[��MySQL�ł�ID(user)�ƃp�X���[�h(password)�ł̃A�N�Z�X���s���B�K�͂̑傫�ȃf�[�^�x�[�X�A�v���P�[�V�����̓e�[�u���̐ړ�������߂�Ȃǂ��āA��‚̃f�[�^�x�[�X���Ńe�[�u���ŋ�ʂ���B�A�N�Z�X���Ƃ�host�́A�f�[�^�x�[�X�ɑ΂���SQL���s�Ȃǂ𔭍s����N���C�A���g�̓��삷��host�c�V�F���ł�mysql�R�}���h��PHP�Ȃǂ�web�A�v���P�[�V�����ŁA���̃N���C�A���g�����삵�Ă���T�[�o�̂��ƁBweb�T�[�o��DB�T�[�o�������Ȃ�host��localhost�ƂȂ�H

�m�F

�����PHP�X�N���v�g�Ŏ����Ă݂܂��B
�����͈̔͂Ȃ牽�ł��o���Ă��܂��܂��̂Œ��ӁI
sql.php

<?php
    $user = "user";             // ���[�U�[��
    $pswd = "passwd";           // �p�X���[�h
    $host = "localhost";        // �T�[�o�[��
    $db   = "database";         // �f�[�^�x�[�X��
    $tabl = "table";            // �e�[�u����
?>

<html>
<form action='sql.php' method='post'>
    ���s����SQL�������
    <input type=text name=sql size=40 maxlengh=40>
    <input type=submit value="���s"><input type=reset value="���">
</input><br>

<?php
    // $HTTP_POST_VARS�ɂ��t�B�[���h�̓��e�����o���i�[
    $sql = $HTTP_POST_VARS["sql"];
    if( $sql ){
        print( "[".$sql."]<hr>\n" );
        //DB�֐ڑ�
        $dbHandle = mysql_connect( $host, $user, $pswd );
        if( $dbHandle == False) { print ( "DB�ɐڑ��ł��܂���\n" ); exit; }
        if( !mysql_select_db( $db ) ){ print( "DB�����݂��܂���\n" ); exit; }
        //SQL�������s����
        $result = mysql_query( $sql );
        if( $result == False ){ print( "SQL�̎��s�Ɏ��s���܂���<br>\n" ); exit; }

        // �񐔂��擾����
        $fields = mysql_num_fields( $result );
        // �w�b�_�[�̎擾�E�\��
        print ("<table width='100%' border=1 cellspacing=0>\n<tr>");
        for ( $i=0; $i < $fields; $i++ ){
            print("<td>".mysql_field_name( $result, $i )."</td>");
        }
        print("</tr>\n");
        // �e�s�̃f�[�^���擾�E�\��
        while( $row = mysql_fetch_array( $result ) ){
            print("<tr>");
            for( $j=0; $j < $fields; $j++ ){
                print("<td>".$row[$j]."</td>");
            }
            print("</tr>\n");
        }
        print("</table>\n");

        mysql_free_result( $result );   //���ʃ��R�[�h���J��
        mysql_close( $dbHandle );       //DB����̐ؒf
    }
?>
</html>

PHP4

�p�b�P�[�W�̃C���X�g�[��

  1. apt-get�ŃC���X�g�[��
    # apt-get install php4 php4-mysql
  2. �C���X�g�[�����̎���ɑ΂���
    Do you want me to run the apacheconfig script now[y/N]? ��No(default)
    >Do you want me to add it now [Y/n]? ��Yes(default) MySQL

�ݒ�

/etc/apache/httpd.conf

  • PHP4���W���[���̑g�ݍ��ݎw��
    LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
  • �f�t�H���g�h�L�������g��index.php���w��
    DirectoryIndex index.html index.htm index.shtml index.cgi index.php
  • �h�L�������g�^�C�v�̒lj�
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

/etc/php4/apache/php.ini

  • MBSTR�̐ݒ�
    [mbstring] mbstring.internal_encoding = EUC-JP mbstring.http_input = auto mbstring.http_output = EUC-JP mbstring.detect_order = auto mbstring.substitute_character = none;

�m�F

�ȉ��̃t�@�C���� test.php ���̃t�@�C�����ō쐬���u���E�U�Ŋm�F����B
�S�Ă̐ݒ肪�\������܂��̂Ŋm�F������A�����Ă����܂��傤
  <?php
      phpinfo();
  ?>

perl5.6�i�����Aperl�͓����ς݁j

�p�b�P�[�W�̃C���X�g�[��

  1. �p�b�P�[�W�̃C���X�g�[��
    # apt-get install perl-5.6 apache-perl

webmin�p��MySQL���W���[���̃C���X�g�[��

�p�b�P�[�W�̃C���X�g�[��

  1. �p�b�P�[�W�̃C���X�g�[��
    # apt-get install webmin-mysql
  2. webmin�̍ċN��
    # /etc/init.d/webmin restart

�Q�l�����N

MySQL / PHP4 / perl5.6

�����S��

Debian GNU/Linux �����T�C�g

[an error occurred while processing this directive]
(C)2005 �ŽR�� (Aoi AoYama) / Blue Hibiscus Web Pages

�m�@����T�[�o�[WebRing ���O �bID=265 �O��5�\�� �b�� �����ړ� �b�T�C�g�ꗗ�@�n