Set up a Debian-based home server

    Hey.

    I want to tell you about how I implemented the server solution at home :)
    Please do not judge strictly, because This is my first publication on Habrahabr, and Russian is not my native language.
    So all corrections are welcome.

    It will be about: An
    old VIA Ezra-based computer with 256 megabytes of RAM, running on the Debian Etch base, acting as a music player, torrent client, web + ftp + nfs server.

    Additional equipment: 2 laptops (Dell, Asus) based on Ubuntu, Fedora and Wi-Fi router / DSL-modem D-link DSL-2640u.


    One of my friends for the New Year gave me this creation of engineers of the last century:



    It was decided that the basin should not stand idle in vain. Debian because the distribution is stable and easy to configure / use.
    I will not describe the installation process of the OS - the task is understandable, and there is enough help on the Internet on this matter. Immediately proceed to the setting.

    Customization



    Because My laptops are connected via wi-fi, and I connected the server through a twisted pair cable - all computers are on the local network.
    First of all, I installed ssh and turned off the monitor, placing the car in a secluded place so as not to interfere.

    It is necessary to forward ports on the router to access the server from the outside.
    I made a DHCP reservation for MAC addresses, and my server will always have a local address of 192.168.1.2

    Screenshot from the router admin panel:



    You see that I opened the ports for web, ftp, shoutcast and ssh.
    It is important to know that external addresses for some (and in my privacy) router models will not work from the local network.
    Those. if I type on my laptop my_external_yp_address: 21 - then I won’t see anything.
    Now the server is visible from the network.

    Connect via ssh and configure.
    By default, Debian uses Gnome as a window manager, but it eats RAM, so we will disable it.
    This is done very easily:

    Option from gribozavr UPD: either so, suggested Greignar Save, reboot. Voila! Gnome is disabled. Thus, you can turn off services we do not need. It so happened that my home provider does not provide me with a static IP address, so I had to look for a solution. I settled on dyndns.com . A service that provides a third-level domain for free + the ability of server software to update the ip for a given domain when it changes.
    apt-get install sysv-rc-conf
    sysv-rc-conf



    update-rc.d -f gdm remove








    We register, add a new account, download inadyn, put it in autoload using update-rc.d Now we have a domain that will always be bound to our server!

    update-rc.d inadyn defaults




    Screen + rtorrent setup



    The solution fell on this bunch, because rtorrent is not of a demonic nature, but it needs to work in the background.
    If you still do not know what screen is, go to the GNU Project website .
    Install the packages we need: I created an autoload script: And I added it, again, through update-rc.d I will explain: when the server boots in the background, a screen starts up with rtorrent running inside. Let's tweak the config a bit: Now our torrent client adds the downloads to the / data / downloads / folder, and every 5 seconds checks the / data / torrents / folder for new torrent files.

    apt-get install screen rtorrent




    nano /etc/init.d/screen


    #!/bin/sh
    screen -d -m rtorrent
    echo "Started..."







    nano /home/username/.rtorrent.rc


    directory = /data/downloads/
    schedule = watch_directory,5,5,load_start=/data/torrents/*.torrent




    Configure apache, ftp, nfs



    To use mpd web clients, you need a web server. I choose apache. To work with the player’s web clients we still need php.
    Also, nfs for mounting network drives, and ftp for simply accessing files.
    Everything is very simple here: Excellent, all packages are installed, daemons start automatically. In the proftpd config, you need to add one line so that users of the local system can log in as ftp users: When you log in to the ftp server, the user enters the home directory. For the nfs server, I shared one folder / data: This indicates that users on the local network have the right to read and write the / data folder on the server. Reboot daemons: Everything, NetFileSystem and FTP are ready to work.

    apt-get install apache2 libapache2-mod-php5 php5-cli php5-common php5-cgi proftpd nfs-kernel-server





    nano /etc/proftpd/proftpd.conf


    DefaultRoot ~






    nano /etc/exports


    /data 192.168.1.1/24(rw,no_root_squash,async)





    /etc/init.d/proftpd restart
    /etc/init.d/nfs-kernel-server restart




    Configure client machines



    For convenient work with nfs, I made an entry in fstab: After just writing, And we will see a folder from the server file system!

    sudo nano /etc/fstab


    192.168.1.2:/data /server/data nfs rw,hard,intr 0 0




    sudo mkdir /server/data
    sudo mount /server/data




    Setting mpd + relaxxplayer + icecast



    Mpd is a great demon player for which there are many gui. Like Qt, GTK +, and web-based.
    Let's dwell on the web interface, as it seemed to me the best option.

    Install packages: To install the client for the player, you need to download the source from the home site and unzip them to / var / www Apache is already running, so by typing the address 192.168.1.2 we will see the player itself. A bit of mpd setup: I tell the player that my music files are in the / mnt directory of the server. And now the fun part! I decided to go by mounting on the server the nfs directory of the laptop, which contains the music.

    apt-get install mpd icecast2






    nano /etc/mpd.conf


    music_directory "/mnt"






    Having installed nfs-kernel-server on the laptop and shared the / home / romantik / music folder, I mounted it on the server in the / mnt / music directory.

    Now, having updated the mpd database, we will see music from the laptop in it :) When playing bytes of rial time data rush over the local network. It’s more convenient and you can’t imagine, now I’m practically independent of the wires :) And a little about icecast. In the mpd settings, uncommenting the shoutcast block, we get the broadcast to the stream network directly from the player. It is available at 192.168.1.2:8000

    mpd --create-db











    Conclusion



    For me, this was a serious step into the world of a fully functional console. I’ll tell you, I feel only the convenience of the procedures done :)
    And what do you advise you to implement on the server?

    Also popular now: