服务器简单搭建匿名讨论版的方法

A岛看多了觉得匿名版是个好东西。。最近发现 jinke.la 似乎惨遭 GFWed,想了想决定自己弄个匿名版玩玩。google上搜索加上配置服务器和域名等等一共花了大概30分钟,按这篇教程配置起来应该只需要10分钟吧。。。教程如下。

这个教程适用于 Debian / Ubuntu 及其它 Debian 系的系统,当然,CentOS 配置起来也差不多。

  • Software 选择

如果你只是需要快速地 Set up an Imageboard 的话,你可以跳过这一部分。

世界上有很多可以搭建匿名版的软件,大部分是日本的。首先是很有名的 2chan 挂在官网上的 futaba.php,这个软件最后的版本是 051031 版本,也就是十年前的样子。不过它实在是太古老了。。。我试了一下速度令人感动。配置的话官网上有写,不用数据库也能配置(当然,这样做会变得更慢)。官网在这(日语)

http://jun.2chan.net/script/

从他们官网上下载的文件是奇葩的 Shift-JIS 编码,在英文 OS X 下完全无法阅读注释。如果有人需要用这个搭建 Image Board 的话,我这里有一份已经转成 utf-8 编码的 futaba.php (051031)。 文件已过期

 

另一个有名的软件是传说中的(现在已经只存在于传说中了的样子)futallaby。当然,也是已经基本上停止维护了。最后版本是 040103 。这里是他们的官网(英语或日语)

http://www.1chan.net/futallaby/

这是一个很棒的软件,但是还是太老而且已经停止维护了。

 

futallaby 的作者推荐了另一款软件 Wakaba ,官网在

http://wakaba.c3.cx

这个软件甚至比 futallaby 功能还要全面一些,在它的官网上介绍了另一款软件 Kareha。Wakaba 和 Kareha 都是用 Perl 写成,功能非常强大,相对来说配置比较复杂,懒癌发作不想写了。。有想知道的可以看一看官方提供的 wiki 文档,已经十分全面。

http://wakaba.c3.cx/docs/docs.html

当然,还有非常受欢迎的 Kusaba X,关于 Kusaba X 的教程我会在另一篇文章里给出。

除了上面的这些软件以外,还有很多可以选择的软件,不过我没一个个试,改天有空再试好了。比如说 Danbooru ,这是一个和 2chan 风格完全不一样的 Image Board,可能不太算是讨论版(我脑内的讨论版基本上就是 2chan 2ch.net 这样的,嗯,捂脸)

 

 

当然,我个人的想法只是随便搭建一个简洁轻量的匿名版。所以以上软件我都没有选择。

我们这里选择的是一款叫做 TinyIB 的 Image Board 程序。目前它是开源程序,使用 PHP 写成,在 Github 上可以找到代码:

https://github.com/tslocum/TinyIB

至于为什么选这个。。。(〃∀〃)当然是因为受到这货的影响了| ω・´)

http://6zx6cxigcq7tjtue.onion/  ……<— 好人是不会点这个链接的哦,别点。。(2016年更新:这货也已经挂了。。在 The Uncensored Wiki 的 Hard Candy 页面上还在,但是已经变成了一个谜之新闻页面(我搞科研去的这几个月发生了什么。。?))

 

 

  • 基本的环境设置

首先当然是把环境设置好。我们这里使用最简单的 LAMP,写给完全没有经验的人看的,配置过 LAMP 或者 LNMP 的请跳过。

 

1. 安装 Apache

以下命令基于假设服务器运行着一个全新装好的 Debian 8.0 系统。

第一件事

sudo apt-get update

更新源之后我们需要安装 apache2

sudo apt-get install apache2

安装完后,直接用浏览器访问你的服务器 ip 地址(假设你用IPv4)

http://your.server.ip.address

如果安装成功,应该会出现这样的东西

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

 

2. 安装 MySQL

sudo apt-get install mysql-server php5-mysql

以上命令会安装 MySQL。安装中会要求新建一个 MySQL root 用户的密码,尽量不要与 Linux root 用户密码相同。

接下来让 MySQL 创建它的数据库目录结构

sudo mysql_install_db

应该很快能运行完。这之后,我们可以把一些安装中产生的影响安全的设置删除。MySQL 很人性化地提供了这个

sudo mysql_secure_installation

运行之后第一步会要求更改 MySQL root 用户密码,之前我们已经设好了,可以不用改,选 no。之后的选项全选 Yes,这样就会移除临时用户和远程登录,避免安全问题。

这样 MySQL 就差不多安装好了。

 

3. 创建和设置 MySQL 数据库

首先登入 MySQL root 用户

mysql -u root -p

这里需要刚才设置的 MySQL root 用户密码。

接下来,创建一个数据库用来存放我们讨论版的数据,我这里就叫 IBDB 了,你可以随便取名字,比如 Doge 啊 Hentai 啊什么的都行。直接替换 IBDB 即可

CREATE DATABASE IBDB;

记得打分号,嗯。忘了的话在第二行开头打一个分号也是一样的啦。

接下来创建一个 MySQL 用户,用来操作这个数据库

CREATE USER IBU@localhost;
SET PASSWORD FOR IBU@localhost= PASSWORD("IBUsPassword");

这样的话会创建一个叫做 IBU 的用户,密码是 IBUsPassword。同样,用你自己的东西替换这两个选项,记得密码不要与 root 的相同。

接下来,把之前创建的数据库交给 IBU

GRANT ALL PRIVILEGES ON IBDB.* TO IBU@localhost IDENTIFIED BY 'IBUsPassword';

让权限设置立即生效

FLUSH PRIVILEGES;

然后就可以退出了。

exit

 

4. 安装 PHP

当然,我们需要安装一下宇宙最好的语言 PHP 。一条命令完事。

sudo apt-get install php5 php5-mcrypt php5-gd libapache2-mod-php5

安装完成后,测试一下。注意这一步根据你的安装情况,目录可能有所不同。

sudo vim /var/www/html/info.php
(感谢网友指正,很久不用 apache 不知道默认的目录改了)

然后编辑内容如下

<?php
phpinfo();
?>

保存退出。用浏览器访问

http://your.server.ip.address/info.php

如果看见 PHP 的 info 界面,那么说明安装基本成功了。然后记得删掉刚才创建的页面

sudo rm /var/www/html/info.php

 

到这里,LAMP 基本设置完成。

  • 安装 Git

只需要一条命令而已。

sudo apt-get install git
  • Clone 软件到服务器

以下步骤假设你有根权限。

1. 首先确定安装的目录。如果你的目录下没有其他网站,那么可以直接用文件目录代替网站目录。例如,如果希望访问 http://example.com/ib/ 时访问到匿名版,那就

cd /var/www/html
mkdir ib
cd ./ib

如果希望访问 example.com 直接打开讨论版,那就

cd /var/www/html

如果你有更复杂的需求,可以到 /etc/apache2/apache2.conf 中调整位置

2. 从 Github 上复制源程序

git clone git://github.com/tslocum/TinyIB.git ./

3. 做一些基础设置

修改默认设置

cp settings.default.php settings.php
vim settings.php

这是修改前的 settings.php

<?php
# TinyIB
#
# https://github.com/tslocum/TinyIB
#
# Contact the author via [email protected] if you need support.
# See README for instructions on configuring, moderating and upgrading your board.
#
# Set TINYIB_DBMODE to a MySQL-related mode if it's available.  By default it's set to flatfile, which can be very slow.

// Administrator/moderator credentials
define('TINYIB_ADMINPASS', "");       // Administrators have full access to the board
define('TINYIB_MODPASS', "");         // Moderators only have access to delete (and moderate if TINYIB_REQMOD is set) posts  ["" to disable]

// Board description and behavior
define('TINYIB_BOARD', "b");          // Unique identifier for this board using only letters and numbers
define('TINYIB_BOARDDESC', "TinyIB"); // Displayed at the top of every page
define('TINYIB_CAPTCHA', false);      // Reduce spam by requiring users to pass a CAPTCHA when posting  (click Rebuild All in the management panel after enabling)
define('TINYIB_REQMOD', "disable");   // Require moderation before displaying posts: disable / files / all  (see README for instructions, only MySQL is supported)

// Board appearance
define('TINYIB_LOGO', "");            // Logo HTML
define('TINYIB_THREADSPERPAGE', 10);  // Amount of threads shown per index page
define('TINYIB_PREVIEWREPLIES', 3);   // Amount of replies previewed on index pages
define('TINYIB_TRUNCATE', 15);        // Messages are truncated to this many lines on board index pages  [0 to disable]

// Post control
define('TINYIB_DELAY', 30);           // Delay (in seconds) between posts from the same IP address to help control flooding  [0 to disable]
define('TINYIB_MAXTHREADS', 100);     // Oldest threads are discarded when the thread count passes this limit  [0 to disable]
define('TINYIB_MAXREPLIES', 0);       // Maximum replies before a thread stops bumping  [0 to disable]

// Upload types
define('TINYIB_PIC', true);           // Enable .jpg, .png and .gif image file upload
define('TINYIB_SWF', false);          // Enable .swf Flash file upload
define('TINYIB_WEBM', false);         // Enable .weba and .webm audio/video file upload  (see README for instructions)
define('TINYIB_EMBED', false);        // Enable embedding  (e.g. YouTube, Vimeo, SoundCloud)

// File control
define('TINYIB_MAXKB', 2048);         // Maximum file size in kilobytes  [0 to disable]
define('TINYIB_MAXKBDESC', "2 MB");   // Human-readable representation of the maximum file size
define('TINYIB_THUMBNAIL', 'gd');     // Thumbnail method to use: gd / imagemagick  (see README for instructions)
define('TINYIB_NOFILEOK', false);     // Allow the creation of new threads without uploading a file

// Thumbnail size - new thread
define('TINYIB_MAXWOP', 250);         // Width
define('TINYIB_MAXHOP', 250);         // Height

// Thumbnail size - reply
define('TINYIB_MAXW', 250);           // Width
define('TINYIB_MAXH', 250);           // Height

// Tripcode seed - Must not change once set!
define('TINYIB_TRIPSEED', "");        // Enter some random text  (used when generating secure tripcodes)

// Database
//   Recommended database modes from best to worst:
//     pdo, mysqli, mysql, sqlite, flatfile  (flatfile is only useful if you need portability or lack any kind of database)
define('TINYIB_DBMODE', "flatfile");  // Mode
define('TINYIB_DBMIGRATE', false);    // Enable database migration tool  (see README for instructions)
define('TINYIB_DBBANS', "bans");      // Bans table name (use the same bans table across boards for global bans)
define('TINYIB_DBPOSTS', TINYIB_BOARD . "_posts"); // Posts table name

// Database configuration - MySQL
//   The following only apply when TINYIB_DBMODE is set to mysql, mysqli or pdo with default (blank) TINYIB_DBDSN
define('TINYIB_DBHOST', "localhost"); // Hostname
define('TINYIB_DBPORT', 3306);        // Port  (set to 0 if you are using a UNIX socket as the host)
define('TINYIB_DBUSERNAME', "");      // Username
define('TINYIB_DBPASSWORD', "");      // Password
define('TINYIB_DBNAME', "");          // Database

// Database configuration - PDO
//   The following only apply when TINYIB_DBMODE is set to pdo  (see README for instructions)
define('TINYIB_DBDRIVER', "mysql");   // PDO driver to use (mysql / sqlite / pgsql / etc.)
define('TINYIB_DBDSN', "");           // Enter a custom DSN to override all of the connection/driver settings above  (see README for instructions)
//                                         When changing this, you should still set TINYIB_DBDRIVER appropriately.
//                                         If you're using PDO with a MySQL database, you should leave this blank.

改成

<?php
# TinyIB
#
# https://github.com/tslocum/TinyIB
#
# Contact the author via [email protected] if you need support.
# See README for instructions on configuring, moderating and upgrading your board.
#
# Set TINYIB_DBMODE to a MySQL-related mode if it's available.  By default it's set to flatfile, which can be very slow.

// Administrator/moderator credentials
define('TINYIB_ADMINPASS', "AdministratorsPassword");       // Administrators have full access to the board
define('TINYIB_MODPASS', "ModeratorsPassword");         // Moderators only have access to delete (and moderate if TINYIB_REQMOD is set) posts  ["" to disable]

// Board description and behavior
define('TINYIB_BOARD', "b");          // Unique identifier for this board using only letters and numbers
define('TINYIB_BOARDDESC', "Your Board Name"); // Displayed at the top of every page
define('TINYIB_CAPTCHA', false);      // Reduce spam by requiring users to pass a CAPTCHA when posting  (click Rebuild All in the management panel after enabling)
define('TINYIB_REQMOD', "disable");   // Require moderation before displaying posts: disable / files / all  (see README for instructions, only MySQL is supported)

// Board appearance
define('TINYIB_LOGO', "Your Logo, if you have one");            // Logo HTML
define('TINYIB_THREADSPERPAGE', 10);  // Amount of threads shown per index page
define('TINYIB_PREVIEWREPLIES', 3);   // Amount of replies previewed on index pages
define('TINYIB_TRUNCATE', 15);        // Messages are truncated to this many lines on board index pages  [0 to disable]

// Post control
define('TINYIB_DELAY', 30);           // Delay (in seconds) between posts from the same IP address to help control flooding  [0 to disable]
define('TINYIB_MAXTHREADS', 100);     // Oldest threads are discarded when the thread count passes this limit  [0 to disable]
define('TINYIB_MAXREPLIES', 0);       // Maximum replies before a thread stops bumping  [0 to disable]

// Upload types
define('TINYIB_PIC', true);           // Enable .jpg, .png and .gif image file upload
define('TINYIB_SWF', false);          // Enable .swf Flash file upload
define('TINYIB_WEBM', false);         // Enable .weba and .webm audio/video file upload  (see README for instructions)
define('TINYIB_EMBED', false);        // Enable embedding  (e.g. YouTube, Vimeo, SoundCloud)

// File control
define('TINYIB_MAXKB', 8192);         // Maximum file size in kilobytes  [0 to disable]
define('TINYIB_MAXKBDESC', "8 MB");   // Human-readable representation of the maximum file size
define('TINYIB_THUMBNAIL', 'gd');     // Thumbnail method to use: gd / imagemagick  (see README for instructions)
define('TINYIB_NOFILEOK', true);     // Allow the creation of new threads without uploading a file

// Thumbnail size - new thread
define('TINYIB_MAXWOP', 250);         // Width
define('TINYIB_MAXHOP', 250);         // Height

// Thumbnail size - reply
define('TINYIB_MAXW', 250);           // Width
define('TINYIB_MAXH', 250);           // Height

// Tripcode seed - Must not change once set!
define('TINYIB_TRIPSEED', "Some Random Text, Must Not Change Once Set");        // Enter some random text  (used when generating secure tripcodes)

// Database
//   Recommended database modes from best to worst:
//     pdo, mysqli, mysql, sqlite, flatfile  (flatfile is only useful if you need portability or lack any kind of database)
define('TINYIB_DBMODE', "mysqli");  // Mode
define('TINYIB_DBMIGRATE', false);    // Enable database migration tool  (see README for instructions)
define('TINYIB_DBBANS', "bans");      // Bans table name (use the same bans table across boards for global bans)
define('TINYIB_DBPOSTS', TINYIB_BOARD . "_posts"); // Posts table name

// Database configuration - MySQL
//   The following only apply when TINYIB_DBMODE is set to mysql, mysqli or pdo with default (blank) TINYIB_DBDSN
define('TINYIB_DBHOST', "localhost"); // Hostname
define('TINYIB_DBPORT', 3306);        // Port  (set to 0 if you are using a UNIX socket as the host)
define('TINYIB_DBUSERNAME', "IBU");      // Username
define('TINYIB_DBPASSWORD', "IBUsPassword");      // Password
define('TINYIB_DBNAME', "IBDB");          // Database

// Database configuration - PDO
//   The following only apply when TINYIB_DBMODE is set to pdo  (see README for instructions)
define('TINYIB_DBDRIVER', "mysql");   // PDO driver to use (mysql / sqlite / pgsql / etc.)
define('TINYIB_DBDSN', "");           // Enter a custom DSN to override all of the connection/driver settings above  (see README for instructions)
//                                         When changing this, you should still set TINYIB_DBDRIVER appropriately.
//                                         If you're using PDO with a MySQL database, you should leave this blank.
  • 更改目录权限

chmod g+w ./ ./src/ ./thumb/ ./res/
  • 初始化网站

用浏览器访问

http://your.server.ip.address/imgboard.php

程序应该会自动初始化并生成 index.html

之后,重启 apache2 服务以避免一些问题

/etc/init.d/apache2 restart

域名解析生效后,一个基本的匿名讨论版就差不多建好了。以后访问时,直接输入域名就能访问。

 

嗯,这个是我刚刚建的匿名版。完全匿名,不会显示 ID。(2016年4月1日更新,因为我发了太多车怕被查水表,已经下线)

loli.cafe

7 thoughts on “服务器简单搭建匿名讨论版的方法”

        1. … Apache 安装完检查的时候是否能出现默认页面?您可以把具体的错误信息和您的安装步骤记录一下,写一封邮件给我。

  1. sudo vim /var/www/info.php
    无法在http://your.server.ip.address/info.php看到info
    应该是
    sudo vim/var/www/html/info.php

Leave a Reply to Zhi Zi Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.