建造基于Ubuntu的NAS服务器(ftp samba Apache, PHP MySQL mp3在

HOWTO : Home made NAS server with Ubuntu 8.04.1
[HOWTO] 用Ubuntu 8.04.1搭建NAS服务器

There are many NAS for home users in the market, such as Synology, Qnap, LinkStation and etc. They are not in good performance and not cheap in price. However, they are good in less power consumption. It is because I owned not only one brand of such products at home now.
现在市场上有很多家用NAS产品,例如:Synology, Qnap, LinkStation等。它们性能并不好,而且价格不便宜。不过,在低能耗方面做得较好,因此,我家里有不止1个品牌的这类产品。

Recently, I bought a VIA PC-1 PC2500E motherboard, which has VIA C7-D 1.5GHz CPU on board. It is cheap in price and use less power too. The maximum amount of RAM is 2 GB.
最近,我买了1块VIA PC-1 PC2500E主板,板上带有VIA C7-D 1.5GHz CPU。价格便宜,也节能。最大可装2G内存。

Testing it with Ubuntu 8.04.1 Desktop version for a while, I am very satisfied with the performance of the CPU, although it is not quite fast indeed. I decided to build a home made NAS server with remote BitTorrent function.
用Ubuntu 8.04.1 Desktop测试一段时间,虽然不是足够快,我还是对CPU的性能相当满意。我决定在家组装NAS服务器,并带有远程BT功能。

Hardware
硬件
Motherboard – VIA PC-1 PC2500E with VIA C7-D 1.5GHz CPU
RAM – 2 X 1GB DDR2 667MHz (maximum)
Hard drive – 300GB Seagate SATA (The motherboard treats it as ATA drive)
Router – Planet WRT-401E (wired) (optional)

Software
软件
Operating system – Ubuntu 8.04.1 Server Edition
File server – Samba
FTP server – vsFTPd
Remote access – OpenSSH
Web Server – Apache, PHP and MySQL
Remote BitTorrent – TorrentFlux (front-end) and BitTornado (back-end)
Security software – Fail2Ban

The performance of the Samba is quite good and it can stream the video clips. You can remote control the server with OpenSSH and also can remote the BitTorrent anywhere.
Samba的性能相当好,而且支持视频流。你可以使用OpenSSH远程控制服务器和BT。

I do not choose the GUI interface for server maintenance as it is not required after the server has been set up. I use command line mode indeed. http://ubuntuone.cn
我没有为服务器的维护选择GUI界面,因为服务器安装完成后就没有用处了。我使用命令行。

The server needs some fine tune for better performance and I will tell you how. The installation of the softwares is in Part II.
我后面会介绍服务器需要调优提高性能的位置。第二部分是软件的安装。

HOWTO : Home made NAS server with Ubuntu 8.04.1 – Part II
[HOWTO] 用Ubuntu 8.04.1搭建NAS服务器 – Part II

Here comes the software installation. The first thing is to install the operating system – Ubuntu 8.04.1 Server Edition. The installation is quite straight forward and you should choose LAMP, OpenSSH and Samba (Print server is optional) during the installation. Use a more complicate but easy to remember password as the user password and MySQL password. I use same password for them. Please write it down and you will need it later and forever.
这里是软件的安装。首先是安装操作系统Ubuntu 8.04.1 Server Edition。安装过程中,选择LAMP, OpenSSH and Samba(Print服务可选)。为操作系统用户和MySQL用户设定足够复杂又容易记住的口令。我使用了相同的口令。请写下来,过一会儿就要使用,而且永远要使用。

Once installed, you can install vsFTPd and Fail2Ban. BitTorrent feature will be discuss later.
下一步,安装vsFTPd和Fail2Ban。BT后面再说。

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vsftpd fail2ban


Samba

The Samba is already installed and you are required to configure it to make it work. I will make the Samba working in this way : Every user has it owned home directory and every user can access to a public directory for sharing document and files.
Samba已经安装结束,你需要完成配置使它工作。我设计的Samba规则如下:每个用户有自己的私有目录,每个用户都可以访问共享文件的公共目录。

sudo nano /etc/samba/smb.conf

To add the following lines to the [global] section :
在[global]段,加入以下几行:

# If you need to access Big5 filename, it is required; otherwise it is optional.
#dos charset = cp950
dos charset = UTF-8
#dos charset = cp936

To add the following lines to the [global] section also :
在[global]段,再加入以下几行:

hosts allow = 127.0.0.1 192.168.0.0/24 192.168.10.0/24
hosts deny = 0.0.0.0/0

At Authentication part, uncomment the “# security = user” to read as “security = user”
在认证部分,去掉注释“# security = user”,变成“security = user”。

Go to [homes] section and add the following lines to it :
在[homes]段,加入以下几行:

[homes]
comment = Home Directories
path = /home/%S
browseable = yes
read only = no
create mask = 0664
directory mask = 0664
valid users = %S

Add the following lines to the end of the file :
文件最后加入以下几行:
[public]
comment = Share to all
path = /home/public
browseable = yes
read only = no
create mask = 0664
directory mask = 0664
valid users = samiux,john,mary
admin users = samiux

To reload the configuration of your Samba server :
重启Samba服务器。

sudo /etc/init.d/samba reload

where “admin users = samiux”may be different from you.
其中“admin users = samiux”部分,你自己的设置应该不一样的。

Then made a “public” directory at /home :
在/home下,创建“public”目录:

sudo mkdir /home/public
chgrp users /home/public
chmod 0777 -R /home/public

相关推荐