Saturday, November 18, 2006

How to Configure an $80 File Server in 45 Minutes

I use a modded Xbox and Xbox Media Center for playing media files across the network on my television and sound system.  I also download large files, such as Linux ISOs, via BitTorrent.  However, leaving my primary computer on all the time seemed like a waste of energy.  I wanted a cheap, small headless machine that I could use as a Samba server and BitTorrent client so I could leave my workstation off when I wasn't using it.

I was in luck; HCDI Trading had a great "Fall Extravaganza" deal - a Dell OptiPlex GX150 Desktop for $47.91 (around $30 s/h).  The specs:

  • Desktop Form Factor (it fits on a shelf in a media center)
  • Intel Celeron 700 MHz
  • 128MB RAM
  • 10GB HD
  • CD-Rom

Not cutting edge, but perfect for what I needed and priced very reasonably.  Instead of using X11 and remote clients, I felt that web interfaces would be optimal out of simplicity.  If I configured the server as a LAMP (Linux, Apache, MySQL, and PHP), then I could use web GUIs for configuration, administration, and file transfers.

Out of the popular Linux distributions, I'm most familiar with Gentoo and Ubuntu.  Gentoo didn't seem appropriate; it would take hours and hours to get everything set up, configured and updated (even from a Stage 3 install), and any performance gain from the optimization would be negligible.  Ubuntu has a history of reliability and ease of set up, so I used the Edgy Eft release as the basis my server.

The Applications

  • Remote Console - OpenSSH
    • The free version of the SSH connectivity tools.  Use it for secure access to the console.
  • Web Server - Apache
    • It's free, fast, well supported and documented
  • Network Fileshare - Samba
    • Creates file shares that can be easily accessed from Windows.  Notoriously obnoxious to configure by hand, the Samba Web Administration Tool (SWAT) simplifies the process immensely.
  • Database - MySQL
    • The popular free database server.  While I can use a command line to administrate MySQL, I prefer using phpMyAdmin.
  • P2P Client - BitTorrent

Directions

  1. Download and burn the Ubuntu Server 6.10 i386 install CD.
  2. Install Ubuntu Server
    1. When asked about Software Installation, choose LAMP.
    2. When the installation is finished, take out the CD (I flip it over and leave it in the drive for the next time I need it) and reboot.
  3. Logon as the regular user that you created during setup.
  4. Give root a password.
    sudo passwd root
  5. We're going to modify the file sources list to allow us access to all the required files.  Uncomment the edgy universe, edgy-security main restricted, edgy-security universe, edgy multiverse, edgy-backports main restricted universe multiverse, and edgy-commercial main.  In addition, Ubuntu leaves the install CD as one of the file sources after installation, so you'll need to remove the CD from the source list.  Comment out the CD from the list and save.
    sudo nano -w /etc/apt/sources.list
  6. Update apt-get to use the new sources.
    sudo apt-get update
  7. Install OpenSSH server
    sudo apt-get install openssh-server
  8. Turn off the computer.
    sudo shutdown -h now
  9. Disconnect the monitor, keyboard, and set the computer wherever it's going to lurk for the next couple years.
  10. Turn on the computer and wait about a minute for it to boot.
  11. Using your preferred SSH client, connect to the machine.  I prefer PuTTY for Windows.
  12. Install Samba and SWAT.
    sudo apt-get install samba smbfs swat xinetd
  13. Create a Samba user.
    sudo smbpasswd -a username
  14. Add SWAT to the xinet configuration and save.
    sudo nano -w /etc/xinetd.d/swat
    # description: SAMBA SWAT
    service swat
    {
    disable = no
    socket_type = stream
    protocol = tcp
    #should use a more limited user here
    user = root
    wait = no
    server = /usr/sbin/swat
    }
  15. Reload Xinetd with the new configuration.
    sudo dpkg-reconfigure xinetd
  16. Verify that SWAT is up and running.  If you don't get any response, start Googling.
    sudo netstat -tap | grep swat
  17. Make the shared directory for TorrentFlux.
    sudo mkdir /share
    sudo mkdir /share/incoming
    sudo chmod 777 /share/incoming/
  18. Create the Samba share.  Using a web browser, go to http://hostname:901/shares
    1. path /share/incoming
    2. valid users - username
    3. read only - no
    4. Commit Changes
  19. Install phpMyAdmin
    sudo apt-get install phpmyadmin
  20. Connect to phpMyadmin using a web browser - http://hostname/phpmyadmin
    1. Secure MySQL / phpMyAdmin
      1. login: root (no pass)
      2. Privileges
        1. Add a password to both root accounts
      1. Create a database for TorrentFlux
        1. Databases - Create New - torrentflux
  21. Install TorrentFlux
    sudo apt-get install torrentflux
    1. Ignore the libphp-adodb message.
    2. Configure database for torrentflux with dbconfig-common? - yes
    3. Password - blank (generates random)
    4. Restart Apache? - Yes
  22. Configure TorrentFlux using a web browser - http://hostname/torrentflux/
    1. Username / Password - root / root
    2. Configuration
      1. Path - /share/incoming/
      2. Save
    3. Click My Profile
      1. Update your password
    4. Create a user account
      1. Admin - New User
  23. Remove the Apache default documents from web root.
    sudo rm -Rf /var/www/apache2-default/
  24. Create a basic web launchpad for easy access your services.
  25. sudo nano -w /var/www/index.php

    <?php $hostname = $_SERVER['HTTP_HOST']; ?>
    <ul>
    <li><a href="http://<?php echo $hostname; ?>/torrentflux">Torrent Flux</a></li>
    <li><a href="http://<?php echo $hostname; ?>/phpmyadmin">phpMyAdmin</a></li>
    <li><a href="http://<?php echo $hostname; ?>:901/">SWAT</a></li>
    </ul>

Post Mortem

Overall, the installation and configuration took me about 45 minutes to go from zero to a fully functional system.  The Xbox can see the share, and I've got a new playground for web development.  I would suggest cleaning up and securing that home page a bit; research .htaccess files to lock it down.

I put my file server in my media center underneath my router, and it takes up about the same space as a VCR.  For $80, I feel that I've made an excellent investment.

Update - 11.19.2006 - I've been Dugg! Thank you all for your comments, compliments, corrections, criticisms, and suggestions!

125 comments:

Croesus said...

www.freenas.org

less than 10 min to set up and have running.


:-)

RexDixon said...

Very nice article, very complete. I sent it over to my bud who is having the fight of his life with XP crap the past few days. :)

Rex

Unknown said...

very well written document...

Munjal said...

Justin, I too use freenas, but it is only basic as a Samba and FTP share, it does not provide a complete webserver interface, you really should check out torrent flux. I infact have two servers, both a torrent flux and a freenas seperately, but was never able to get samba running on the torrentflux box until now thanks to this great guide!
However, I have a few questions, in your guide since the torrent flux directory is a samba share, any user can delete files?I would assume yes. Also, I was wondering, In my case my torrent flux server is only 15 gigs, and my NAS being 500, and I often download several large ISO's in one night and would like to be able to mount my NAS share on the unbuntu system so that torrentflux could use it as the default download directory. I do have the SMB share mounted under ubuntu, I just don't know what to put in the torrentflux directory specification box //freenas/dump? or what?I am quite confused
Thanks in advance =)

cjc0621 said...

I don't think this is the appropriate forum to ask a technical question.

Chris

Matt said...

Munjal - use the command smbmount:

#man smbmount

that will tell you how to mount a samba share so it looks like a directory so you don't have to mess with the \\computer/asdf stuff

Jon Peck said...

munjal - You can set certain Samba users to read only, or set read only as the default for all users. Under Shares - http://hostname:901/shares in the specific share configuration, there's the "read" and "write" list that you can specify users in. Utilize the man pages for additional information.

Munjal said...

Thanks a lot everyone, great guide! Will show everyone at my LUG

Anonymous said...

Beautiful job in explaining the process. Really. Well done.

Unknown said...

One quick question... any idea how to enter interactive mode during boot? I need to disable cpuspeed for my hardware.

pjrobar said...

ClarkConnect- GNU/Linux/Open Sourced based, free for home use.

"ClarkConnect is a powerful yet easy-to-use software solution that transforms off-the-shelf PC hardware into a dedicated Internet gateway and server. The software is a secure, reliable and cost effective solution.

Features

Our software offers a feature-rich server solution:

Internet Gateway
Firewall
VPN
E-mail
Bandwidth and P2P Manager
Multiwan
Intrusion Prevention
Web and FTP Servers
Antispam/Antivirus
Content Filtering
File and Print Services
Data backup
Groupware

Management and Monitoring

After deployment, our unique Gateway Services solution simplifies the management and maintenance of your system:

Mail Backup
Content Filter Updates
Remote System Monitoring
Security Audits and Updates
Automatic Software Updates
DNS and Domain Services"

Openfiler- GNU/Linux/Open Sourced based.

"Openfiler is a Storage Management Operating System. It is powered by the Linux 2.6 kernel and Open Source applications such as Apache, Samba, LVM2, ext3, Linux NFS and iSCSI Enterprise Target. Openfiler combines these ubiquitous technologies into a small, easy to manage solution fronted by a powerful web-based management interface. Openfiler allows you to build a Network Attached Storage (NAS) and/or Storage Area Network (SAN) appliance, using industry-standard hardware, in less than 10 minutes of installation time."

"Because life as a systems administrator is difficult enough as it is. Openfiler allows you to ease some of the pain by bringing together almost all storage networking protocols (CIFS, NFS, HTTP/DAV, FTP, iSCSI) into a single framework. So if your current pressure points arise from grappling with the task of providing secure and resilient storage to users, groups and computing resources in a multi-platform heterogeneous environment, Openfiler is the tool for you."

Chris Widmer said...

Hi, the command for SWAT should be as follows, yes?

sudo nano -w /etc/xinetd.d/swat

Greg said...

I had a problem using xinetd so i just used netkit-inet which seemed to work for me.

supermike said...

Although I'm an Ubuntu advocate, is this where I complain that Ubuntu Server STILL doesn't have any console, menu-based system administration tool (think like 'yast')? And oh, by the way, webmin sucks.

People with Ubuntu Server (and no GUI) would like to not have to type all these commands with switches to add and modify users and groups -- it gets tedious, especially if LDAP is involved. And admins would also like a tool where they can customize a standard Ubuntu desktop profile + Ubuntu Linux OS and deploy it all at once to hundreds of PCs currently running Windows, rebooting hopefully in 5 hours into Ubuntu desktop and having a standard, locked down profile customized by the admin.

supermike said...

Oh, and don't forget:

http://ebox-platform.com/

...it's Debian-based, designed in Spain, for an international audience, and has a super cool web admin interface. It's really well done, but is slightly beta here or there. Try it -- I think you'll be impressed. I would hope that Canonical would buy them out and merge this project in with Ubuntu Server.

Jon Peck said...

chris - Good catch, thanks. I fixed it.

AmyStephen said...

Not bad, Jon! Blogged it. Thanks for sharing. Tremendous!

Preston said...

I'm pretty linux dumb. What do I put for the hostname? I have tried the IP and username, as well as the name that I get when I type "hostname". What am I missing?

Unknown said...

Hostname should be the local address to the computer. If you're using a router, then get a static ip (google "Static ip, ubuntu) and your hostname will be whatever you made your static ip to be.

What is the best (easiest) way to access files on the server from windows?

Unknown said...

I made a mistake while configuring TorrentFlux with dbconfig-common , is there a way to restart the dbconfig-common from the beginning? I tried to apt-get remove torrentflux and then reinstall it but it doesn't let me restart the dbconfig-common. Thanks

stuboo said...

Mike,
While I dont have this exact setup, I do have Ubuntu running a Samba server and I access from windows as a network drive. I'm pretty sure I got my instructions on configuring windows from howtoforge.com

Hope this helps.
Ryan

Jon Peck said...

Mike - Samba creates network shares; from Windows, you can go to \\hostname to see what's shared, or specifically go to the incoming directory as created in this tutorial, \\hostname\incoming

mrharley said...

in the Using a web browser part is that used though windows?
if so i cant seem to connect to my server

Unknown said...

I am such a Noob...Followed your guide step for step, but I am unable to launch phpmyadmin or torrentflux. And the only way I got SWAT to work is using netkit-inetd. Any suggestions?

mrharley said...

under the web launchpad it look like some of the text on the end got cut off what is the missing text?

wesley said...

nice easy guide...but a quick question -

any reason to give root a password, if you are continuing to use sudo for the rest of the process?

thanks....

w

Croesus said...

Munjal, True. =) and I have used Torrent Flux in the past. Great stuff.

Jon Peck said...

wesley - It's needed for SWAT.

Unknown said...

One small pedantic comment...

Why do people use "sudo su"? I see people doing it where I work all the time and I've never understood it.

Don't people know of "sudo -s"?

tsuke said...

I tried to setup Ubuntu on a Pentium III 500MHz and 256 meg Ram - it took 8 mins to boot, and the mouse cursor refreshes its position at about 1 frame per second. Is there a way to strip Ubuntu down to bare essentials or speed it up?

Jon Peck said...

tsuke - use ubuntu server, not desktop

Luke said...

Isn't 10GB a little low for a file server?

Ethan Giffin said...

Why not just get the linksys router with the usb port in it? I did that, upgraded the firmware, then plugged in a 500 gig drive. Took about 15 minutes.

Unknown said...

Nobody mentioned getting a Linksys NSLU-2: with a USB disk, might work out slightly more expensive than the Dell, but lower power (4.5W), smaller, and completely silent. I use one of these to feed my XBox Media Centre, works like a charm.

Oh, don't forget to install Unslung on it first (http://www.nslu2-linux.org/wiki/Unslung/HomePage) so you have a fully-fledged Linux installation.

whammypower788 said...

After I install PHPMyAdmin, I can't get to it.

whammypower788 said...

nm, found what I did wrong.

Thomas Nybergh said...

as far as torrent clients are concerned, rtorrent is a nice, if not very intuitive (read the man page) alternative that can be run in screen to be controlled from anywhere with ssh access.

http://libtorrent.rakshasa.no/

Fairly recent versions are available in Ubuntu's own repositories.

we are borg said...

Cheers for the article!
Would be a great tutorial for the new tutorial site.
http://tutorialicio.us/

CT said...

For those folks having problems getting swat to run:

In my case, the issue was that in step 14, the second line is shown as service swat {. The { should be on the next line by itself. Otherwise when you reconfigure xinetd it throws an error on the second line and swat service never starts. Fix this and you should be good to go with swat in a matter of moments.

On another note, the initial instruction to give the root user a password should be accomplished as sudo passwd root. This will ensure you assign a root password. The instruction as given didn't work in my case. You'll need the root password set properly in order to log into swat!

Great post, very handy! Thanks for sharing.

Riker

Mike Hourahine said...

Great post! Thanks for sharing it.

Riker: You're a beaut! I spent a few hours trying to figure out what the heck was wrong with swat. Thanks for sharing that fix.

Jon Peck said...

Riker - Thanks for the tweaks; I've updated accordingly.

HMK said...

I have just set up a server as directed. Everything works fine except that when I run SWAT I don't seem to get (or can't find) the option to create a share as suggested.

markjd said...

I am stuck at step 20, unable to access phpmyadmin in both firefox and ie. Any suggestions?

david said...

I'm with markjd and can't get past step 20.

After some googling I'm left wondering if apache was installed at all? Yes I chose the lamp installation option.

From various howtos it looks as if apache can be restarted like this:
sudo /etc/init.d/apache2 restart

In my /etc/init.d/ no apache2 (or apache) can be found.

I'd love to know what I did wrong as everything was working so nicely up until this point.

Thanks in advance.

augmentedfourth said...

I'm with the people who mention that they can't access phpmyadmin on the server.

Oddly, I followed the instructions on this tutorial last Tuesday (12/5) and everything worked fine. I ended up screwing things up and starting over, and now phpmyadmin won't work the way it did the first time...

Social Drunk said...

i'm sorry, this is my first linux experience. i do not know how to 'uncomment' something. apologies, but a little help?

augmentedfourth said...

Curtis: You probably don't want to make your first Linux experience a Server Edition. I'd say install Ubuntu Desktop and monkey around with that a bit before trying this tutorial. Spend some time with this PDF book to get used to Unix/Linux command-line operation.

But to answer your specific question, the "commented" lines in the text file are those that begin with the '#' character. These lines are ignored when the file is accessed by APT. If you add a pound sign before the CD-referencing line at the top and remove the symbol from the other "deb" references in the file, the APT package manager will use all available Internet repositiories while ignoring the local CD drive.

This is called "commenting out" because the '#' lines are usually used to add comments to programming code, so that people reading it later can be told what the various segments of a program actually do. This feature has also been used to toggle whether certain aspects of a program or configuration file are active or not by switching between "in use" and "commented out."

augmentedfourth said...

Aha! I figured out what the problem was with phpmyadmin not working. It's in the installation... when you have the option of choosing DNS/LAMP packages, it's not enough to merely move the cursor to the LAMP box and hit "Enter." You have to hit the space bar while the cursor is on LAMP, so that the option actually gets selected for installation.

markjd said...

Thanks, Brad. That fixed the problem :)

Oh, and thanks to JP of course :D

Anonymous said...

i and a total noob when it comes to this stuff but i got it mostly working except for the samba server
it is running but i can figure out how to make confg it properly and make it avail on "my network places"
samba is installed and and seems to work and i got swat installed and works but step 18 has me confused. i must be missing something .
can anyone elaborate on that step

thankyou

Social Drunk said...

thanks a lot.i've been trying to break into linux for a few weeks or so. the problem is that every tutorial i've found makes assumptions about knowledge. this is the clearest one i've found so far. i've got the desktop edition, but i'm gonna try to sweat this out.

thanks so. sorry to be a nuisance, i've noticed that some linux guru's hate noob questions. i'll post back when i've figured it out.

augmentedfourth said...

richrmg: in step #18, you have to log in as "root." If you try with the normal user, there is no option to create a new share.

Also, after logging in to SWAT as root, I went to the Wizard button at the top and chose "enable home folders" and then hit "commit." This allows you to access the home folder via Samba, so you'll have another place to store files than just the torrentflux download directory.

david said...

Thank you Brad (and everyone else), I too, needed to hit that spacebar. I still can't believe I missed that.

I'm up and running and it's great.

Thanks Jon this was a great howto.

Social Drunk said...

thanks bro, you walked a noob thru it! i got that tutorial too, great stuff. thanks a whole lot!

Social Drunk said...

any idea what E: Couldn't find package torrentflux ' means? i make it to this step. thought maybe i'd chewed something up in the install so i did it again. i've updated, upgraded, etc. so i'm back begging for assistance.

augmentedfourth said...

After modifying the sources.list text file by changing the commenting status of the various lines, you need to run 'sudo apt-get update' so that your local copy of the package databases is synchronized with the list of software actually available on the servers.

'sudo apt-get upgrade' is a good idea, too: it makes sure everything you've got installed is up to the latest version. You should run this every so often to keep up with patches and bugfixes.

Social Drunk said...

great! sorry to be so high maintenance. i've pointed a bunch of my friend who are interested in linux to this page... great tutorial.

Tim Biden said...

Ok, I'm a complete noob; I admit this.

I thought I did everything right but I can't set up the samba share... There is an option to choose one but no option to create a share.

Did I do something wrong? Dumb question...

What did I do wrong and can it be fixed? Or do I need to start all over again? Better Questions...

Thanks! Tim

Tim Biden said...

Doh! I'm a noob. Yeah, I was logged in as me, not as root.

Thanks for the great guide. If I can get this going so quickly, that's proof that it rocks!

Tim

augmentedfourth said...

TT2C:

I haven't used XBMC with this setup (I'm not a console-gaming sort of guy), but I may have a solution for you.

First of all, there should be a colon between the username and password, not a semicolon:

smb://WORKGROUP;USERNAME:PASSWORD@SERVER/SHARE

If there's a semicolon, it marks a division between a workgroup name and a username. (The share should auto-mount just fine even if you skip the workgroup altogether.)

Also, try an alphanumeric password (i.e. without the question mark). That may help, if reformatting the URL doesn't fix the issue.

Jon Peck said...

TT2C - Don't use a semicolon. XBMC Manual - Bookmarks - smb://username:password@server.com/share/

nxd4n said...

I've a question about where to create a shared file-folder.
Do you create a folder "share" in root? Or would you create it in /home?
Under Windows, I would dedicate a partition with several folders (mp3, movies, pictures,...), but now with Linux I'm wondering what's the best way to organize my files and folders.
Do you create a folder (e.g."shared") in root, in /home?
What's your way of doing, and why?

Orion said...

all seemed to go smoothly (despite the fact that i'm largely clueless in this project), but now the same things that worked 30 minutes ago don't work. e.g. i could get into SWAT by
http://hostname:901/shares during the setup and do all the other things. the launchpad thing worked too. i don't think i changed anything, but now when i try
http://hostname:901/shares
i get an error saying
401 Authorization Required
You must be authenticated to use this service
i don't get any chance to supply authorization.
i can't get into phpMyAdmin or TorrentFlux either.
i'd appreciate any pointers.
thanks.

Anonymous said...

well its been a couple of weeks since my last post and while i like the concept. i cant get it to work and give up and going back to my windows xp azarus setup which i have on a different drive. problems i had
never able to get samba to work
(also tried to get ftp server on it and that didn't work either)
and the torrentflux the instructions installed where a older version 2.1beta and that had bugs and didn't & and may still not work well with multi gig files

Kingster said...

I'm stuck at step 20 I reinstalled everyting right with LAMB version... i can restart apache2 but when I try to openen the phpmyadmin side my browser wants me to download a file istead of opening a webpage

augmentedfourth said...

Michael:

see this comment. I had the exact same problem, and that is what fixed it.

Unknown said...

i am trying to get this working under my ubuntu-desktop version so i cannot exactly follow this tutorial.


so what i did was i use apt-get to install mysql5/php5/apache2


i have problem with logining into torrentflux.

when i type http://192.168.2.5/torrentflux/
in my browser

i get the following line
"Database error: Access denied for user 'torrentflux'@'localhost' to database 'torrentflux'

Always check your database variables in the config.php file."

i do not have the option of inputing my login username/password


Can someone tell me what am i doing wrong?

thanks a lot!!

Unknown said...

blah~~

i restarted my ubuntu,

and now when i open
http://192.168.2.5/phpmyadmin

it askes me to open a .phtml file....



i thought this is the reason of my not starting mysql

but i have tried running "/etc/init.d/mysql start"

and this did not fix the problem:(

immaage said...

First off thanks for the awesome guide. Thanks so much for putting the time into it.

After a couple installations, bit torrent and stuff works, but just not the shares. After setting it up however, I can see the share perfectly in Windows and Mac OSX, but when I select the share, it gives the following errors:

Windows:
"\\192.168.1.250\GeneralShare is not accessible. You might not have access to use this network resource. Contact the administrator of this server to find out if you have permission access.

The network path was not found."

Mac:
"The operation cannot be completed because one or more required items cannot be found. (Error code ~43)"


I'm not sure as to whether this is a permission problem, a port problem, or what?! I've checked many posts and it doesn't seem like any of their solutions have helped me.


Here is some other info

The folder:
drwxrwxrwx 5 root root 4096 2007-01-14 00:40 incoming


smb.conf file:

[global]
workgroup = WORKGROUP
netbios name = fileserver
server string = %h server (Samba, Ubuntu)
obey pam restrictions = Yes
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
panic action = /usr/share/samba/panic-action %d
invalid users = root

[General Share]
comment = General Share Directory
path = /incoming/share
valid users = immaage, aznfury684
admin users = immaage
read list = immaage, aznfury684
write list = immaage, aznfury684
browseable = yes
writable = yes
read only = No

Jiggyboo said...

Thank you Jon Peck for the writeup. As a newb i appreciate the help of setting up downloading box.

Because i'm a virgin to linux i too got stuck at step 20. Thank you Brad for pointing out the spacebar thing on the LAMP option. Maybe that should be noted in the guide *shifty eyes*

Anyway, and due to my un-linux skills, i couldn't figure out how to use the web interface on stop 18 in "Create the Samba share"....couldn't find any configure buttons/options.

So in case others are like me, here is the guide i used for step 18
http://doc.gwos.org/index.php/Share_files_using_Samba

nxd4n said...

Hi, at step 18, when connecting to swat (//...:901/shares), I was prompted to enter a user/passwd there. When using my ubuntu user, I can't create or modify any shares, but with root it worked, I didn't try with the samba user.
I found it easier to add a share by modifying (with sudo) the /etc/samba/smb.conf and add the following:
[share]
comment = shared folder
path = /share/
public = yes
writable = yes
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup

and restart the samba server
sudo /etc/init.d/samba restart

Dan

Erik said...

For immaage: When you map the drive with windows, use the 'connect using a different user name' option and use your linux user login and password, it should work fine.


I would also like to say this is an excellent tutorial, I have had my server up and running for a couple of weeks now and everything works great. Thank you for taking hte time to put this together.

Unknown said...

Hello, sorry to bother, but I am at step 19 and I've come to a dead end. I have re-installed Ubuntu at least four times now and I'm definitely running it with the LAMP installation. I have read all of the comments, and read though the guide many times, but nothing looks wrong. The machine says something about not being able to install it because it cant find it. Any help is appreciated!

Thank you in advance,
Tom

Unknown said...

How can I put in the share settings of torrentflux that it must go and check my shared disk on win2003?
My shared link is \\192.168.4.20\data

Thanks

augmentedfourth said...

Tom:

Sorry to take so long getting back to you. Are you sure you un-commented the lines in sources.list properly back in step 5? If APT isn't told how to access the right repositories it would cause a "Couldn't find package" error.

Unknown said...

Thank you for the help, it turned out I wasn't uncommenting how I was supposed to.

Thanks again!
-Tom

Unknown said...

Out of curiosity, does anyone know how to make this work on a machine with multiple HDs? I'd like to make use of all three HDs in the machine and make it visible in the sharing process. Does anyone know how to do this? I think I require some mounting n such...THANX!

augmentedfourth said...

Michael: I'm sure you'll just have to fiddle with the partitioning options during the install process...

Unknown said...

Eh? I've re-formatted all the drives to be et3 but I think I'm only seeing the drive that ubuntu is installed on. Is there a way for me to share the other 2 drives? I'll be making a folder for the drive. I think the following lines:

sudo mkdir /share
sudo mkdir /share/incoming
sudo chmod 777 /share/incoming/

is used to create the share/incoming directory and allowing the rights to read/write/and access on the drive Ubuntu exists on. But how do i access the other drives? Been trying to hunt around for it. THANX!!!

augmentedfourth said...

Ah, I see... you want to access all of the drives simultaneaously, not in separate partitions. In the install process, the best you could do is create a partition that spans one whole hard drive and mount it as the /share directory.

If you want the whole shebang to be accessed as one big conglomerate hard drive, you'll have to look into setting the drives up in a RAID array. I don't know anything about actually doing that, but I know the theory behind how it's supposed to work, and there are many types of RAID configurations available. The point is to harness the disk space available to all three drives and tie them together as one. Most RAID configurations include some data redundancy (to compensate for drive failure) so you might not be able to access the full capacity of all three drives in your array, but you can at least expand beyond the space afforded by a single drive.

Unknown said...

Wohoo, thanx for the clarification, you actually hit on what I was trying to ask. How do I mount the drives in the share directory? That's the part that's been driving me insane and for whatever, cannot locate on the 'net. Thanx!!!!!!

augmentedfourth said...

You can't mount multiple drives in the /share directory... a mount point can only connect to a single partition. You can choose one hard drive and create a single partition on it that can be mapped to /share. First you have to "mkdir /share", then "mount /dev/hdd1 /share" (replacing hdd1 with your drive's devicefile). Here' a tutorial that might help:
http://smorgasbord.net/book/export/html/195

You know, now that I think about it, you could create multiple torrentflux users and then make mount points out of the /share/incoming/user1 and /share/incoming/user2 directories. You could then mount your two extra drives to those points, and choose your torrentflux login based on which drive you want the files to end up in... then you could have access to two full hard drives from a single installation of torrentflux.

Unknown said...

Thanx for the link! I'll definitely try that out this weekend! Think this will serve what I'm looking for. Again, thanx for all the help.

miscblogger said...

I love your concept of a "drone machine" freeing some resources from the "main powerhouse PC." I was actually thinking of trying this with a feature similar to terminal services or remote desktop so that I don't have to buy another monitor as well. Since, I'm used to XP and the prices of XP are plummeting due to the new Vista OS, I might just use that instead. The only thing I don't like about this idea though is the electric bill. You say "leaving my computer on all the time seemed like a waste of energy." But, I would imagine that your Dell Optiplex GX150 would have spent about the same amount of energy as your powerhouse. Is there any way to minimize electricity usage? Perhaps just use an old laptop or what?

Allan
hacker not cracker

Giancarlo Furia said...

Thanks a lot! I have learned a lot from your page!

Unknown said...

Very interesting article - thank you.

Noob question for anyone. I want to try this as an experiment to learn more about Linux as a Server, but the Linux box (now running 6.10 Desktop) I want to try it on is networked with a Wifi G card. Will that cause any problems or change the steps needed significantly? Anyone else have one networked that way?

Thanks.

augmentedfourth said...

Jeff:

It really depends on which wireless card you're using (specifically, which wi-fi chipset it has).

Wireless networking has always been a difficult aspect of Linux configuration, though it's getting easier. If you're planing to use the box as a server, a wired connection is definitely preferable, but if you absolutely must use wi-fi check out these Google results to get you started.

Unknown said...

Thanks for the links Brad. I went through all that when I first installed Fedora on that machine, and finally got it working with NDISWrapper (had to use a 50' cable to start but finally got the wireless going). Then I switched to Ubuntu 6.10 Desktop and it ran the wireless right off, no problem. So I'm hoping 6.10 server will work as well. Assuming 6.10 server drives the wireless card OK, are there any other gotchas doing this server setup using wireless?

Stephen said...

Just wondering where would be a good place to go to for information on securing the server after its all set up? Should I just google the .htaccess files to find some info?

Thanks for the tutorial...it all works great for me. Amazing job.

augmentedfourth said...

Jeff:
If 6.10 Desktop supported your chipset "out of the box," it's probably safe to assume the Server edition will as well; however, there won't be a pretty graphical interface for you to enter the network details. Use "man iwconfig" to learn about bringing up a wireless network connection.

Stephen:
The easiest way to secure the server from outside intrusion is to keep it off the public Internet. Just don't set your router to forward any ports to it, except possibly port 22 for SSH access. I have 22 forwarded so I can log in via SSH or set up tunneling into my network, plus I installed ddclient on my server so that my *.dyndns.org account will always point to my dynamically-changing public IP address.

Unknown said...

This is great fun. I decided not to attempt to do it all with a wireless connection - went with wired instead. But, I'm stuck on step 18 - Create the Samba share. When I go to http://hostname:901/shares in Firefox, I get the Samba screen "Share Parameters" but the only share in the "choose share" list box is print$. If anyone can shed any light on this step, I'd greatly appreciate it. I verified that the share directories were created correctly. I'm going to read the Samba docs. Thanks in advance.

augmentedfourth said...

@Jeff:

That's exactly as it should be; you're going to need to enter a share name ("incoming," or whatever you want) in the text field next to the "Create Share" button.

Also, you have to make sure that you've logged into Samba/SWAT with your server's "root" account; you won't be able to create a share with your non-root admin user!

Unknown said...

Brad,

Thanks. Your answer was correct in two ways. When I logged in as "root" as you said, I got a different screen, and it had a "create share" option. If you're not logged in as root, you don't get that option.

Unknown said...

Got all the way to the last step, but of all things I couldn't get the web launchpad to work correctly. I went over the exact syntax jp provided (though to be honest it might as well be written in Swahili - I think it's supposed to generate a menu?), and it's correct; I replaced "hostname" with the ip address in each case. Error message is:
Parse error: syntax error, unexpected T_DNUMBER, expecting T_VARIABLE or '$' in /var/www/index.php on line 1.
When I google that, not much help except it's a php error message (duh!).

On the plus side, I added Brad's tip about sharing the Home directory with Samba, and that's working great. The windows machines see the directories. One final question: can someone tell me someplace I can read up on what all this is good for? I am guessing the Torrent stuff is mostly for sharing music and video? Sorry to be such a dope... Also, how can I make this secure? I am fairly used to firewalls and anti-virus and such on Windows, and I'm trying to learn Linux. Is this a security problem waiting to happen?

augmentedfourth said...

@Jeff:

When creating the index.php file in the last step, don't change anything from the text Jon provided.

The torrent client is used to download files from the BitTorrent peer-to-peer network. You'll have to find *.torrent files and upload them to the server via the Web interface, then you can activate the torrents over the Web as well.

In terms of security, just make sure your router doesn't forward any ports to the server from the Internet (save, perhaps, port 22 for remote SSH logins).

Unknown said...

Brad,

Thanks again - changing the IP address back to "hostname" made it all work perfectly. Thank you for your help. I will read up on all this and try to figure out what the heck I just did!

suwit said...

Thanks for the true article.
The emperor's clothes.
setup linux and rhce

Unknown said...

Follow-up questions: Can this server be accessed from off-site? It's attached to a home network via a wired connection to a router which has a cable modem attached to the WAN port. The Router (D-Link 624) has a “Virtual Server” feature which (I think) might be useful.

Assume I use this $80 server for all of my data: if it's possible, what application would be best to connect to that server from off-site and transfer files to an off-site computer - FTP?. I would want some reasonable level of security, meaning I would not want anyone not authorized to be able to transfer files. Thanks in advance.

augmentedfourth said...

Jeff:

Your router should be able to do what is called "port forwarding;" i.e., it can take incoming traffic from the Internet at large and send individual ports to specific computers on your network.

In my Ubuntu setup, the router forwards only port 22 to the server. Port 22 the SSH port, and it is the only privileged port I trust to be absolutely secure in a non-professionally-managed environment.

Now, SSH requests from the Internet to your home network's public IP address (go to whatismyip.com to find yours) will go through your router and directly to the server. Most FTP clients can also transfer files through SFTP, which is just FTP over SSH, so you can get data through the secure SSH port as well.

Unfortunately this is probably not everything you need. If you are like most residential broadband customers in the US, your IP address changes intermittently (aka Dynamic DNS). You can either pay for Internet provider extra for a static IP, or you can get a free account at dyndns.org and set up a computer on your local network with a client that updates DynDNS every time your IP changes. "ddclient" is a Linux client you can use from your Ubuntu box; you can find it in the apt repositories just like the other software you installed in the process of following Jon's tutorial.

augmentedfourth said...

Oh, and by the way: Don't access your server via your public IP, or your dyndns hostname, when you're on the same LAN. The main drawback is that speeds are dramatically decreased, since the client machine is going out to the Internet and back rather than directly into the next room. Additionally, why subject your traffic (secure or not) to public Internet scrutiny if you don't have to?

robump said...

i was doing fine until i tried to insatll phpmyadmin. It says
E: Couldn't find package phpmyadmin

So i figured i needed to deltle the spllication get lists, so i did and then went and got them again and it still says it.

Please could you help,

Rob

peaceful_nuke said...

Very good tutorial!! =)
I had this kind of system set up on debian(almost the same) for about a year or so...works great =) Since samba is slow and neither am i a fan of it I have used downloading from within torrentflux thru http... seem to work great unless there's many files then I would just download them as zip(if they are small) or use WinSCP....
Would have been nice to have it around instead of going thru it myself...also i like using b4rt-torrentflux...lots of hacks are installed and implemented well in it ;)
Good Luck! ;)

Josh Lindsay said...

I'm having trouble at step 20. When i browse to 192.168.1.100/phpmyadmin i am displayed a page of text (seems to be the phpmyadmin config file).
When installing I did press the spacebar on LAMP. Any ideas on what is wrong? Thanks for the tutorial

Unknown said...

I've had this set up for a while now and it's been working fine, but today when I tried to connect via PuTTY/SSH, I get a box coming up that says "PuTTY Fatal Error", and in the box is the message "Network error: connection refused". I re-booted the Server and got the same result. The web interface is working fine. Any idea what could be the problem or how to troubleshoot it? I no longer have a monitor and keyboard on the Server.

Unknown said...

Thought I'd post my solution to the above problem in the hope it might help someone else. My router is set up to use DHCP, and it gave the Server a new IP address. To figure this out, I went to the web configuration of my router, and it lists all the DHCP clients. It did not list a hostname for the Server though, and I am now going to figure out how to assign one, and also switch that machine to static IP on the internal network, so this won't happen again.

Anonymous said...

Thanks for this. Very useful and detailed article. Looking forward to more like this from you in the future.

Dell

foxie said...

hi, love the tut!! I also use xbmc to listen to music mainly and i wanted to put all my music onto the server aswell as have a full webserver to play around with so this was perfect but i am a little lost as how i go about putting files onto the server?? probably something very silly im sure!

Unknown said...

Erm...if you're using windows, you should be able to find the server in My Networks, expand that, expand entire network, expand Microsoft Windows Network, and you should find your server in there somewhere, pending on what you name it as and assuming everything else was setup properly.

shawn said...

Awesome tutorial. Thanks for writing it, it motivated me to setup one of these servers up. I am also adding BackupPC to it so I can have a central backup server.

I did this one with Ubuntu Server 7.04. Only major gotcha I had and thought I would pass along is that if you use the x64 version of Ubuntu, for some reason phpmyadmin will not work properly (login errors). You will need to upgrade your php5-mcrypt. Here is an article about it. Or if you just want to run the fix, here it is - 'sudo apt-get install php5-mcrypt'. Hope that helps anybody before they spend a hour like me to fix it :).

Dan S. said...

JP,

I know this is a bit of an older article, but I actually just got a free GX150 and was looking into making a file server when I came across your article.

First off, is this still a good way to set up a file server, or is there something better out there? It seems pretty decent to me.

Also, is there a way to set up a username and password to the Samba share? I'm guessing this could be done through SWAT, but I could be wrong. It doesn't have to be folder specific. This server is going to be connected to a campus network, so I only want those with the password to be able to access it.

I have Ubuntu installed on another computer, so I am quite familiar with the command prompt, but I'm not totally sure how to set something up like this.

Thanks for the help!

Dan

augmentedfourth said...

Dan:

Sure, this guide still works just fine with Ubuntu 7.04. All the packages have had new versions released since Jon wrote the guide, but the Ubuntu repositories are continually updated so you will be able to have a secure and up-to-date system. Make sure you run 'sudo apt-get update' and 'sudo apt-get upgrade' manually every now and then, though.

In swat, you can go to the "wizard" screen and set "expose home directories;" the home-directory shares will only be available if you log in with a user's credentials. If you want one samba share to have a single password for all users, though, I'm sure that's possible (though I haven't done it).

You might also try setting up a non-admin non-sudoer user and just have people access that user's home directory over SFTP; that's easy enough to set up.

Hope this helps!

Dan S. said...

Brad,

Thanks for the help! I'll definitely try it out with Feisty and post here with my experience.

Dan

Unknown said...

in response to what immaage said...

-----------
problem
-----------
Mac:
"The operation cannot be completed because one or more required items cannot be found. (Error code ~43)"
-----------

-----------
solution
-----------

I looked in my log file: /var/log/samba/log.clientcomputername

It said: "couldn't find service xyz"

So I went back to my Mac (client) and instead of connecting to "smb://192.168.1.102/xyz" I just connected to "smb://192.168.1.102",

It then proceeded to ask me what shared folder I wanted to connect to, so I selected "Public".

It turns out that "Public" is the label that I gave the samba shared folder "xyz" in my smb.conf file. except from smb.conf:

[public]
comment = Shared
path = /xyz

Dan S. said...

I figured out the problem as far as not being able to connect to the samba share.

The tutorial says this: "path /share/incoming"

But it should be this: "path share/incoming" WITHOUT the first backslash.

Hope that helps someone :)

Unknown said...

The part that got me stuck was after installing php and then installing Torrentflux. The instructions say
"Password - blank (generates random)"
but you have to put in your root password first or Torrentflux won't connect to the database.

charlie said...

very interesting article and my experiences in trying it are pretty well consistent will all of my linux experiences so far.

I was fairly adept in DOS (way back when) and can wrangle windows when I need to, but I'm a neophyte when it comes to linux. I'm in process of getting some skill in that OS on a non-mission critical PC to prepare for my eventual migration to the penguin side (when my XP machine can no longer cut the muster and to avoid the dark side of vista).

Anyway, I had worked through this setup a few months ago and then didn't know what to do with what I had. So I reformatted my server and installed the Dapper desktop version so I could keep my hand in. I've now got a Gutsy desktop machine to learn on so I thought I'd give the server another chance.

I used the gutsy server version and installation was smoother than the first time (don't ask - it took about 2 months the first time) and everything looked good until I got to install phpmyadmin.

phpmyadmin asked what kind of server I had so I picked apache (not apache2, which I think may be the better choice). Needless to say, I couldn't get to phpmyadmin from my browser.

No problem, sez I, I'll just reconfigure phpmyadmin. Well, a dozen google searches and several dozen pages later I decided that I should maybe just reinstall phpmyadmin and then figured I had to uninstall it first (after the install told me it was already installed). But it can't uninstall because invoke -rc.d can't find /etc/init.d/apache (a script?). And neither can I with a manual search of the whole drive.

A few more searches and web pages and I figure out that I should --reinstall to fix my installation. Nope. Same problem.

As near as I can figure it, phpmyadmin created a script or was looking for a script called apache to finish the installation, but it couldn't (wasn't there?) because I should have used apache2. I'm completely stumped.

I figure I have two choices. Delete every directory that refers to phpmyadmin and try a reinstall or go back to square one and reinstall the server package. I may do the first enroute to the second.

I mentioned my linux experience back at the start. Things go OK as long as things go OK. But once I'm off in the weeds or something fails to work as specified, I feel like a dog watching television. I google and read and try stuff but usually wind up reinstalling the OS after a few weeks and trying again.

The OS is great as long as I don't try to get clever (like try to install a dock on gnome or get my fancy ati card to show video when I play a movie) or stray off the path. But once the first thing fails or doesn't work as expected, I'm done - and goodbye productivity.

It's enough, sometimes, to make me consider a Mac (preferable, still, to Vista).

Juleus said...

Very nice article. I'm finally building a file server since my USB drive is getting full and getting another USB drive wil be a drag to keep tab on what files reside on which drive. So I got a "Green PC" from Everex http://www.walmart.com/catalog/product.do?product_id=7754614, its a bit higher priced than the $80 that John has but the low power is what I'm after since it will be on 24/7.
Im a novice Unix/Linux user and know a little bit of the basics.
Anyway, going thru the steps I'm stuck at step 20, when I access phpadmin, and tried to log-on as root I get the message "Error
#1045 - Access denied for user 'root'@'localhost' (using password: NO)" no other choices can be found. BTW, I already gave root a password. Is there something that I miss,(I'm using Ubunto 7.10 server)?? I have re-installed again and again made sure that LAMP has been chosen during the initial install but still get the same message. :(
Another future issue is can somebody point me (or link) on how to install a second drive using a sata port. Any help is appreciated.. TIA

The Addict said...

Just found this courtesy of lifehacker (I only just found it too.. god knows where I've been for the last three years). I would love to set this up for my newly modded xbox, but I have one small problem. I know absolutely nada about linux. I might have use the system I'm going to use for my server as a learning platform. Its not like I can brick the system by playing around with the OS is it? After all, I can just format the drive if I screw it up.

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

Thanks...

Caltel
Articles

Unknown said...

which mysql program do i download, do i download the commuinity server?

Unknown said...

For those who like me would take 5 days to install the server with this you can do it in 2 hours :-P

Noob guide


Hit space bar to active LAMP option durring install (thx Brad)
Do not set a password for Mysql (it will be done later) (thx my school network admin)
With the new Ubuntu version (ubuntu-8.04.1-server-i386) you have hardy not ergy
Connect as root to Samba (http://localhost:901/share)
Hit space bar to select apache, not apache2 durring myphpadmin install (thx school computer tech)
copy the directory /usr/share/myphpadmin to /var/www
(sudo cp --preserve -R /usr/share/myphpadmin /var/www) (thx school web admin)

Adam Stern said...

Nice! I'll have to try this.

Unknown said...

When I changed the parameters at the Samba site (http://hostename:901/shares)
I couldn't find a "Commit Changes" button

Also, it wouldn't log me in at http://hostname/phpmyadmin
i used "root" as username
and blank password but it keeps saying I can't have a blank password

Web Hosting Services said...

thats really a nice share, but what really torrentflux do?
is thier any hosting provider who can provide server like this for downloading my torrent?

Regards
Hussain,
Web Hosting Services