前提条件
apache + mysql + php の環境が出来ていること。
いわゆるLAMP環境ですね。
今回の検証環境は以下のとおりです
# apachectl -v
Server version: Apache/2.2.6 (Unix)
Server built: Sep 18 2007 11:28:25
$ php -v
PHP 5.1.6 (cli) (built: Sep 18 2007 09:12:47)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33791 to server version: 5.0.27
Scuttleとは?
Scuttleとは「はてなブックマーク」や「del.icio.us」などでおなじみのソーシャルブックマーク機能を
オープンソースのアプリケーションです。
出先からでも自分のブックマーク(お気に入り)を参照できるようにしたくなったので
導入してみました。
Scuttleインストール
ダウンロード
パッケージははScuttle公式WebSiteから手に入れることができます。
(今回は2008/01/15日現在の最新バージョンである「scuttle.0.7.2.zip」を使って構築しました。)
私はwgetを使ってダウンロードをしましたが、windowsな環境でダウンロードしてから
FTPなどでサーバにアップロードとかでも問題ありません。
$ wget http://jaist.dl.sourceforge.net/sourceforge/scuttle/scuttle.0.7.2.zip
--01:47:24-- http://jaist.dl.sourceforge.net/sourceforge/scuttle/scuttle.0.7.2.zip
jaist.dl.sourceforge.net をDNSに問いあわせています... 150.65.7.130
jaist.dl.sourceforge.net|150.65.7.130|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 332586 (325K) [application/zip]
Saving to: `scuttle.0.7.2.zip'
100%[=======================================>] 332,586 1.15M/s in 0.3s
01:47:25 (1.15 MB/s) - `scuttle.0.7.2.zip' を保存しました [332586/332586]
解凍
ダウンロードしてきたファイルを解凍します。
$ unzip -d scuttle scuttle.0.7.2.zip
Archive: scuttle.0.7.2.zip
inflating: scuttle/.cvsignore
inflating: scuttle/.htaccess
inflating: scuttle/about.php
inflating: scuttle/ajaxDelete.php
inflating: scuttle/ajaxGetTitle.php
inflating: scuttle/ajaxIsAvailable.php
inflating: scuttle/alltags.php
######### 省略 #########
$ cd scuttle
※Windowsでダウンロードした場合は、Windowsの解凍ソフトで解凍しても良いでしょう。
mysqlでのユーザとデータベースの作成
今回は以下のとおりにユーザとデータベースを作成しました。
- データベース名: scuttle
- ユーザ名 : scuttle
- パスワード : passwd
ちなみに、phpMyAdminとかを使うと簡単に作成できます。
ですが、今回はphpMyAdminがインストールされていないサーバにインストールしたのでCLIで作成する手順を記述します。
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33581 to server version: 5.0.27
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE USER 'scuttle'@'localhost' IDENTIFIED BY 'passwd';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT USAGE ON * . * TO 'scuttle'@'localhost' IDENTIFIED BY 'passwd' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE DATABASE IF NOT EXISTS `scuttle` ;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON `scuttle` . * TO 'scuttle'@'localhost';
Query OK, 0 rows affected (0.00 sec)
ユーザの確認方法
念のためにmysqlにscuttleユーザが作成されているかの確認。
mysql> show grants for 'scuttle'@'localhost';
+---------------------------------------------------------------------------------------+
| Grants for scuttle@localhost |
+---------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'scuttle'@'localhost' IDENTIFIED BY PASSWORD '360bf4sf5dd1as99' |
| GRANT ALL PRIVILEGES ON `scuttle`.* TO 'scuttle'@'localhost' |
+---------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
データベースの確認方法
scuttleデータベースが作成されていかの確認。
mysql> show databases ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mt |
| mysql |
| scuttle |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql>quit
Bye
テーブル作成
解凍したディレクトリにtables.sqlファイルがあるので、これでテーブルを作成します。
$ mysql -p -u scuttle scuttle < tables.sql
Enter password:
テーブルの確認
作成されたテーブルを確認してみます。
$ mysql -p -u scuttle
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33609 to server version: 5.0.27
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show tables from scuttle;
+-------------------+
| Tables_in_scuttle |
+-------------------+
| sc_bookmarks |
| sc_tags |
| sc_users |
| sc_watched |
+-------------------+
4 rows in set (0.00 sec)
mysql> quit
Bye
設定ファイル(config.inc.php)作成
scuttleの設定ファイルであるconfig.inc.phpを作成していきます。
解凍したファイル内にサンプルのファイルがあるのでそれをコピーして使用します。
$ cp -p config.inc.php.example config.inc.php
$ vi config.inc.php
設定内容
$dbtype = 'mysql4'; # このままで良いです
$dbhost = '127.0.0.1'; # localhostにDBがあるのでこのままで良いです。
$dbport = '3306'; # mysql接続ポート
$dbuser = 'scuttle'; # DB接続ユーザ名
$dbpass = 'passwd'; # DB接続パスワード
$dbname = 'scuttle'; # 接続DB名
$locale = 'ja_JP'; # 日本語設定
$adminemail = 'tamohik@server-memo.net'; # 管理者メールアドレス
あとは、お好みで他の設定も変更してみてください。
例えばサイト名を変更するなら「$sitename」の値を編集したりと・・・
※windows上で解凍した場合は、設定ファイルの編集までwindows上で行い
解凍したファイル適当な名前(scuttle等)に変更して、フォルダごとFTPでアップロードしても
かまいません。
apacheからアクセスできるところに置く
ユーザのpublic_htmlディレクトリに置くなり、apacheのDcoumentRootに置くなりして
apacheで外部で公開できる場所にディレクトリを移動します。
私は、apacheのDocumentRootに設定してある/var/www/htmlディレクトリにscuttleディレクトリを
移動して、外部からウェブブラウザでアクセスできるようにしてみました。
$ cd ../
$ su
# mv scuttle /var/www/html/
動作確認
すべての設定が完了しましたら、実際にWebブラウザでアクセスしてみます。
ユーザ登録
「登録する」をクリックするとユーザ登録画面が表示されます。
「ユーザ名」「パスワード」「メールアドレス」を入力し「登録する」ボタンを押下します。
ブックマークの追加
ブックマーク追加をクリックすると「ブックマーク追加」画面が表示されるので
URLや題名などを入力し、「ブックマークを追加する」ボタンを押下します。
ブックマークを追加すると、追加したサイトに移動します。
こんなときは?
ブラウザに文字が表示されて画面が表示されない
e-mail address.'); // USERNAME AND E-MAIL } else {
とか、
isLoggedOn() && sizeof($_FILES)
とブラウザ上に文字が表示され、phpスクリプトが実行されない場合。
原因として考えれられること
scuttleのphpソースファイル一部に「<?php」で始まらなず、「<?」で始まるsourceが含まれているため、
phpスクリプトと認識されないことで起こっている場合があります。
対処方法
「php.ini」の「short_open_tag = On」が設定されているか確認してください。
設定がOffだったり記述がない場合は「short_open_tag = On」を変更/追加してください。
php.iniの反映方法
apacheの再起動で反映されるはずです。/etc/init.d/httpd restart