Server ≫ Linux Server ≫ Fedora Core 8 ≫ コミュニティサイト(XOOPS)その1

 
前提条件
WebサーバーSQLサーバーが稼働していることが前提条件になります。
XOOPSインストール
 

コミュニティサイトソフト XOOPS をダウンロード&インストールします。

まず、ダウンロードです。下記のように入力します。青文字が入力文字です。

   
 
[root@linux]# wget http://downloads.sourceforge.net/xoopscube/Package_Legacy_2_1_4_RC.zip    ← 入力
 
--00:15:33-- http://downloads.sourceforge.net/xoopscube/Package_Legacy_2_1_4_RC.zip
            => `Package_Legacy_2_1_4_RC.zip'
 downloads.sourceforge.net をDNSに問いあわせています... 66.35.250.203
 downloads.sourceforge.net|66.35.250.203|:80 に接続しています... 接続しました。
 HTTP による接続要求を送信しました、応答を待っています... 302 Found
 場所: http://jaist.dl.sourceforge.net/sourceforge/xoopscube/Package_Legacy_2_1_4_RC.zip [続く]
 --00:15:34-- http://jaist.dl.sourceforge.net/sourceforge/xoopscube/Package_Legacy_2_1_4_RC.zip
            => `Package_Legacy_2_1_4_RC.zip'
 jaist.dl.sourceforge.net をDNSに問いあわせています... 150.65.7.130
 jaist.dl.sourceforge.net|150.65.7.130|:80 に接続しています... 接続しました。
 HTTP による接続要求を送信しました、応答を待っています... 200 OK
 長さ: 9,097,789 (8.7M) [application/zip]

 100%[===============================================================>] 9,097,789 1.19M/s ETA 00:00

 00:15:46 (710.88 KB/s) - `Package_Legacy_2_1_4_RC.zip' を保存しました [9097789/9097789]
 
ダウンロードしたXOOPSを解凍します。下記のように入力します。青文字が入力文字です。
   
 [root@
linux]# unzip Package_Legacy_2_1_4_RC.zip    ← 入力
 extracting: Package_Legacy/html/modules/legacy/language/tw_big5/help/images/
                                                                      abc_2nd_blockinstall_modules.png
  inflating: Package_Legacy/html/modules/legacy/language/tw_big5/help/images/abc_2nd_blocklayout.png
  inflating: Package_Legacy/html/modules/legacy/language/tw_big5/help/images/abc_2nd_blockmanagement.png
  inflating: Package_Legacy/html/modules/legacy/language/tw_big5/help/images/

                                                                      abc_2nd_blockmanagement_weight.png
 extracting: Package_Legacy/html/modules/legacy/language/tw_big5/help/

                                                                 images/abc_2nd_clickaddcustomblock.png
        ↓↓
    ↓↓ 途中省略
    ↓↓

 extracting: Package_Legacy/html/uploads/smil3dbd4e398ff7b.gif
  inflating: Package_Legacy/html/uploads/smil3dbd4e4c2e742.gif
  inflating: Package_Legacy/html/uploads/smil3dbd4e5e7563a.gif
 extracting: Package_Legacy/html/uploads/smil3dbd4e7853679.gif
  inflating: Package_Legacy/html/user.php
  inflating: Package_Legacy/html/userinfo.php
  inflating: Package_Legacy/html/viewpmsg.php
  inflating: Package_Legacy/html/xoops.css

 
解凍したファイルをユーザーのホームページディレクトリに移動します。下記のように入力します。青文字が入力文字です。
   
 [root@
linux]# mv Package_Legacy/html/ /home/******/******/xoops    ← 入力
 
サーバーの文字コードがUTF8の場合はこのまま作業を続けるとホームページを表示した時に文字化けを起こしますでUTF8用のファイルを移動します。
   
 [root@
linux]# mv Package_Legacy/extras/extra_languages/ja_utf8/html/install/language/ja_utf8/ /home/******/******/xoops/install/language
 [root@
linux]# mv Package_Legacy/extras/extra_languages/ja_utf8/html/language/ja_utf8/ /home/******/******/xoops/language
 [root@
linux]# mv Package_Legacy/extras/extra_languages/ja_utf8/html/modules/legacy/language/ja_utf8/ /home/******/******/xoops/modules/legacy/language
 
 
php-mysqlインストール
 

XOOPSの動作で必要なphp-mysqlをインストールします。

下記のように入力します。青文字が入力文字です。

   
 
[root@linux]# yum install php-mysql   ← 入力
 Loading "installonlyn" plugin
 Setting up Install Process
 Setting up repositories
 extras                          100% |=========================| 1.1 kB 00:00
 updates                         100% |=========================| 1.2 kB 00:00
 core                            100% |=========================| 1.1 kB 00:00
 Reading repository metadata in from local files
 primary.xml.gz                  100% |=========================| 1.8 MB 03:13
 extras : ################################################## 5948/5948
 Added 27 new packages, deleted 32 old in 78.85 seconds
 Parsing package install arguments
 Resolving Dependencies
 --> Populating transaction set with selected packages. Please wait.
 ---> Downloading header for php-mysql to pack into transaction set.
 php-mysql-5.1.6-1.2.i386.       100% |=========================| 16 kB 00:00
 ---> Package php-mysql.i386 0:5.1.6-1.2 set to be updated
 --> Running transaction check
 --> Processing Dependency: php-pdo for package: php-mysql
 --> Processing Dependency: php-pdo-abi = %{pdoabi} for package: php-mysql
 --> Restarting Dependency Resolution with new changes.
 --> Populating transaction set with selected packages. Please wait.
 ---> Downloading header for php-pdo to pack into transaction set.
 php-pdo-5.1.6-1.2.i386.rp       100% |=========================| 15 kB 00:00
 ---> Package php-pdo.i386 0:5.1.6-1.2 set to be updated
 --> Running transaction check

 Dependencies Resolved

 =============================================================================
  Package                  Arch          Version         Repository      Size
 =============================================================================
 Installing:
  php-mysql                i386          5.1.6-1.2       updates         81 k
 Installing for dependencies:
  php-pdo                  i386          5.1.6-1.2       updates         60 k

 Transaction Summary
 =============================================================================
 Install   2 Package(s)
 Update    0 Package(s)
 Remove    0 Package(s)
 Total download size: 141 k
 Is this ok [y/N]:
y    ← y を入力
 Downloading Packages:
 (1/2): php-pdo-5.1.6-1.2.     100% |=========================| 60 kB 00:01
 (2/2): php-mysql-5.1.6-1.     100% |=========================| 81 kB 00:01
 Running Transaction Test
 Finished Transaction Test
 Transaction Test Succeeded
 Running Transaction
  Installing: php-pdo                       ######################### [1/2]
  Installing: php-mysql                     ######################### [2/2]

 Installed: php-mysql.i386 0:5.1.6-1.2
 Dependency Installed: php-pdo.i386 0:5.1.6-1.2
 Complete!
    ← Complete! と表示されればインストール完了

 
XOOPS用データベース作成
  XOOPS用のSQLサーバーデータベース と管理ユーザを作成します。

下記のように入力します。青文字が入力文字です。

   
 
[root@linux]# mysql -u root -p******    ← 入力(****** はパスワード)
 
 Welcome to the MySQL monitor. Commands end with ; or \g.
 Your MySQL connection id is 5 to server version: 5.0.27

 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

 mysql>
create database xoops;    ← 入力(データベース xoops の作成)
 Query OK, 0 rows affected (0.00 sec)


 mysql>
grant all privileges on xoops.* to xxxx@localhost identified by '******';    ← 入力
 Query OK, 0 rows affected (0.28 sec)
              (xxxx はユーザー名・****** はパスワード)

 mysql>
exit ← ログアウト
 Bye
 
文字化け対策
このままではインストール後のメニューが『???????』と表示されてしまうのでここで修正しておきます。

/class/database/mysqldatabase.php を下記のように修正します。

   
 
[root@linux]# vi /home/******/******/xoops/class/database/mysqldatabase.php  ← 入力
 <?php
 // $Id: mysqldatabase.php,v 1.1 2007/05/15 02:35:15 minahito Exp $
 // ------------------------------------------------------------------------  //
 //                XOOPS - PHP Content Management System                      //
 //                     Copyright (c) 2000 XOOPS.org                          //
 //                       <http://www.xoops.org/>                             //
 // ------------------------------------------------------------------------  //
 // This program is free software; you can redistribute it and/or modify      //
 // it under the terms of the GNU General Public License as published by      //
 // the Free Software Foundation; either version 2 of the License, or         //
 // (at your option) any later version.                                       //
 //                                                                           //
 // You may not change or alter any portion of this comment or credits        //
 // of supporting developers from this source code or any supporting          //
 // source code which is considered copyrighted (c) material of the           //
 // original comment or credit authors.                                       //
 //                                                                           //
 // This program is distributed in the hope that it will be useful,           //
 // but WITHOUT ANY WARRANTY; without even the implied warranty of            //
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the              //
 // GNU General Public License for more details.                              //
 //                                                                           //
 // You should have received a copy of the GNU General Public License         //
 // along with this program; if not, write to the Free Software               //
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA   //
 // ------------------------------------------------------------------------  //
 // Author: Kazumi Ono (AKA onokazu)                                          //
 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
 // Project: The XOOPS Project                                                //
 // ------------------------------------------------------------------------- //
 /**
  * @package kernel
  * @subpackage database
  *
  * @author Kazumi Ono <onokazu@xoops.org>
  * @copyright copyright (c) 2000-2003 XOOPS.org
  */

 /**
  * base class
  */
 include_once XOOPS_ROOT_PATH."/class/database/database.php";

 /**
  * connection to a mysql database
  *
  * @abstract
  *
  * @author Kazumi Ono <onokazu@xoops.org>
  * @copyright copyright (c) 2000-2003 XOOPS.org
  *
  * @package kernel
  * @subpackage database
  */
 class XoopsMySQLDatabase extends XoopsDatabase
 {
     /**
      * Database connection
      * @var resource
      */
     var $conn;

     /**
      * String for Emulation prepare
      * @var string
      */
     var $mPrepareQuery=null;

     /**
      * connect to the database
      *
      * @param bool $selectdb select the database now?
      * @return bool successful?
      */
     function connect($selectdb = true)
     {
         if (XOOPS_DB_PCONNECT == 1) {
             $this->conn = @mysql_pconnect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
         } else {
             $this->conn = @mysql_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
         }

         if (!$this->conn) {
             $this->logger->addQuery('', $this->error(), $this->errno());
             return false;
         }

         if($selectdb != false){
             if (!mysql_select_db(XOOPS_DB_NAME)) {
                 $this->logger->addQuery('', $this->error(), $this->errno());
                 return false;
             }
         }
         return true;
     }

     /**
      * generate an ID for a new row
      *
      * This is for compatibility only. Will always return 0, because MySQL supports
      * autoincrement for primary keys.
      *
      * @param string $sequence name of the sequence from which to get the next ID
      * @return int always 0, because mysql has support for autoincrement
      */
     function genId($sequence)
     {
         return 0; // will use auto_increment
     }

     /**
      * Get a result row as an enumerated array
      *
      * @param resource $result
      * @return array
      */
     function fetchRow($result)
     {
         return @mysql_fetch_row($result);
     }

     /**
      * Fetch a result row as an associative array
      *
      * @return array
      */
     function fetchArray($result)
     {
         return @mysql_fetch_assoc( $result );
     }

     /**
      * Fetch a result row as an associative array
      *
      * @return array
      */
     function fetchBoth($result)
     {
         return @mysql_fetch_array( $result, MYSQL_BOTH );
     }

     /**
      * Get the ID generated from the previous INSERT operation
      *
      * @return int
      */
     function getInsertId()
     {
         return mysql_insert_id($this->conn);
     }

     /**
      * Get number of rows in result
      *
      * @param resource query result
      * @return int
      */
     function getRowsNum($result)
     {
         return @mysql_num_rows($result);
     }

     /**
      * Get number of affected rows
      *
      * @return int
      */
     function getAffectedRows()
     {
         return mysql_affected_rows($this->conn);
     }

     /**
      * Close MySQL connection
      *
      */
     function close()
     {
         mysql_close($this->conn);
     }

     /**
      * will free all memory associated with the result identifier result.
      *
      * @param resource query result
      * @return bool TRUE on success or FALSE on failure.
      */
     function freeRecordSet($result)
     {
         return mysql_free_result($result);
     }

     /**
      * Returns the text of the error message from previous MySQL operation
      *
      * @return bool Returns the error text from the last MySQL function, or '' (the empty string) if no
        error occurred. 
      */
     function error()
     {
         return @mysql_error();
     }

     /**
      * Returns the numerical value of the error message from previous MySQL operation
      *
      * @return int Returns the error number from the last MySQL function, or 0 (zero) if no error
        occurred.
      */
     function errno()
     {
         return @mysql_errno();
     }

     /**
      * Returns escaped string text with single quotes around it to be safely stored in database
      *
      * @param string $str unescaped string text
      * @return string escaped string text with single quotes around
      */
     function quoteString($str)
     {
         $str = "'".str_replace('\\"', '"', addslashes($str))."'";
         return $str;
     }

     /**
      * perform a query on the database
      *
      * @param string $sql a valid MySQL query
      * @param int $limit number of records to return
      * @param int $start offset of first record to return
      * @return resource query result or FALSE if successful
      * or TRUE if successful and no result
      */
     function &queryF($sql, $limit=0, $start=0)
     {
         if ( !empty($limit) ) {
             if (empty($start)) {
                 $start = 0;
             }
             $sql = $sql. ' LIMIT '.(int)$start.', '.(int)$limit;
         }
        
mysql_query("SET CHARACTER SET ujis", $this->conn);   ← 追記
         $result = mysql_query($sql, $this->conn);
         if ( $result ) {
             $this->logger->addQuery($sql);
             return $result;
         } else {
             $this->logger->addQuery($sql, $this->error(), $this->errno());
             $ret = false;
             return $ret;
         }
     }

     /**
      * perform a query
      *
      * This method is empty and does nothing! It should therefore only be
      * used if nothing is exactly what you want done! ;-)
      *
      * @param string $sql a valid MySQL query
      * @param int $limit number of records to return
      * @param int $start offset of first record to return
      *
      * @abstract
      */
     function &query($sql, $limit=0, $start=0)
     {
    
     }

     /**
      * perform queries from SQL dump file in a batch
      *
      * @param string $file file path to an SQL dump file
      *
      * @return bool FALSE if failed reading SQL file or TRUE if the file has been read and queries
        executed
      */
     function queryFromFile($file){
         if (false !== ($fp = fopen($file, 'r'))) {
             include_once XOOPS_ROOT_PATH.'/class/database/sqlutility.php';
             $sql_queries = trim(fread($fp, filesize($file)));
             SqlUtility::splitMySqlFile($pieces, $sql_queries);
             foreach ($pieces as $query) {
                 // [0] contains the prefixed query
                 // [4] contains unprefixed table name
                 $prefixed_query = SqlUtility::prefixQuery(trim($query), $this->prefix());
                 if ($prefixed_query != false) {
                     $this->query($prefixed_query[0]);
                 }
             }
             return true;
         }
         return false;
     }

     /**
      * Get field name
      *
      * @param resource $result query result
      * @param int numerical field index
      * @return string
      */
     function getFieldName($result, $offset)
     {
         return mysql_field_name($result, $offset);
     }

     /**
      * Get field type
      *
      * @param resource $result query result
      * @param int $offset numerical field index
      * @return string
      */
     function getFieldType($result, $offset)
     {
         return mysql_field_type($result, $offset);
     }

     /**
      * Get number of fields in result
      *
      * @param resource $result query result
      * @return int
      */
     function getFieldsNum($result)
     {
         return mysql_num_fields($result);
     }
 }

 /**
  * Safe Connection to a MySQL database.
  *
  *
  * @author Kazumi Ono <onokazu@xoops.org>
  * @copyright copyright (c) 2000-2003 XOOPS.org
  *
  * @package kernel
  * @subpackage database
  */
 class XoopsMySQLDatabaseSafe extends XoopsMySQLDatabase
 {

     /**
      * perform a query on the database
      *
      * @param string $sql a valid MySQL query
      * @param int $limit number of records to return
      * @param int $start offset of first record to return
      * @return resource query result or FALSE if successful
      * or TRUE if successful and no result
      */
     function &query($sql, $limit=0, $start=0)
     {
         $ret =& $this->queryF($sql, $limit, $start);
         return $result;
     }
 }

 /**
  * Read-Only connection to a MySQL database.
  *
  * This class allows only SELECT queries to be performed through its
  * {@link query()} method for security reasons.
  *
  *
  * @author Kazumi Ono <onokazu@xoops.org>
  * @copyright copyright (c) 2000-2003 XOOPS.org
  *
  * @package kernel
  * @subpackage database
  */
 class XoopsMySQLDatabaseProxy extends XoopsMySQLDatabase
 {

     /**
      * perform a query on the database
      *
      * this method allows only SELECT queries for safety.
      *
      * @param string $sql a valid MySQL query
      * @param int $limit number of records to return
      * @param int $start offset of first record to return
      * @return resource query result or FALSE if unsuccessful
      */
     function &query($sql, $limit=0, $start=0)
     {
         $ret = false
         $sql = ltrim($sql);
         if (strtolower(substr($sql, 0, 6)) == 'select') {
         //if (preg_match("/^SELECT.*/i", $sql)) {
             $ret = $this->queryF($sql, $limit, $start);
         } else {
             $this->logger->addQuery($sql, 'Database update  not allowed during processing of a GET
             request', 0);
         }
         return $ret;
     }
 }
 
Apacheの設定
次に XOOPS 用の Apache 設定ファイルを作成します。下記のように入力します。青文字が入力文字です。
   
 [root@linux]#
echo "Alias /xoops /home/******/******/xoops" > /etc/httpd/conf.d/xoops.conf   ← 入力
 
Apacheの再読み込み
設定を反映するために apache を 再読み込みします。下記のように入力します。 青文字が入力文字です。
   
 [root@linux]#
/etc/rc.d/init.d/httpd reload   ← /etc/rc.d/init.d/httpd reloadt を入力(apache の再読込)
 httpd を再読み込み中
:                                  [ OK ]
 
XOOPSの設定
  インターネットブラウザを開き http://www.zzzzz.yy/xoops/index.php  へアクセスします。 (www.zzzzz.yy は自分のドメイン名)

下図のようなページが表示されます。 『japanese』 を選択して『次へ』をクリックします。

尚、サーバー文字コードがUTF8の場合は『ja_utf8』を選択して『次へ』をクリックします。

下図のようなページが表示されますので『次へ』をクリックします。

ファイルのアクセス権をチェックして幾つかのファイルのアクセス権の変更を求められます。

下記のようにアクセス権の変更をします。
   
 [root@linux]#
chmod 777 /home/******/******/xoops/uploads/   ← 入力
 [root@linux]#
chmod 777 /home/******/******/xoops/cache/   ← 入力
 [root@linux]#
chmod 777 /home/******/******/xoops/templates_c/   ← 入力
 [root@linux]#
chmod 666 /home/******/******/xoops/mainfile.php   ← 入力
 
変更後『再読込』をクリックします。

下図のようなページが表示されますので『次へ』をクリックします。

下図のようなページが表示されますので『データベースユーザ名』『データベースパスワード』『データベース名』にそれぞれ上記で作成した名称等を入力して『次へ』をクリックします。

設定内容を確認して間違いなければ『次へ』をクリックします。

『次へ』をクリックします。

パスとURLを確認して間違いなければ『次へ』をクリックします。

『次へ』をクリックします。

『次へ』をクリックします。

『次へ』をクリックします。

サイト管理者のユーザー名・メールアドレス・パスワードを入力して『次へ』をクリックします。

『次へ』をクリックします。

『次へ』をクリックします。

先程入力したサイト管理者のユーザー名とパスワードを入力して『ログイン』をクリックします。

『インストール』をクリックします。

不要なディレクトリの削除を求められます。

下記のように不要ディレクトリを削除します。
   
 [root@linux]#
rm -rf /home/******/******/xoops/install   ← 入力
 
ブラウザの更新ボタンをクリックします。

ファイルのアクセス権をチェックしてアクセス権の変更を求められます。

下記のようにアクセス権の変更をします。
   
 [root@linux]#
chmod 644 /home/******/******/xoops/mainfile.php   ← 入力
 
ブラウザの更新ボタンをクリックします。

戻る