Build a file server
File servers are very useful for both home and business environments. For home, it’s a good way to have a more low-power, dedicated solution to storing your media and backing up your systems, without needing to specifically turn on your desktop machine to get the files – a desktop machine that may use more power idling than a dedicated file server.
For enterprise, it can not only be useful for backups, but also provides for off-machine networked storage for individual users that can be accessed from within and outside the network. So, let’s set a server up.
For a simple server type such as this, we’re going to go ahead and use Ubuntu Server to set up the system. This means that if you have any experience with Linux, it should be easy to maintain and install more software on if
you need to.
If you’re doing the initial setup for a home server then installing it with a monitor attached will be much easier. Burn the ISO to an installable medium or boot it over the network if you have the facilities set up, then hit return on ‘Install Ubuntu Server’ to continue.
Installation
The installation for the server edition is different from the usual graphical installer of Ubuntu – it’s a command line one, albeit with fairly straightforward options. After setting up your location, language and keyboard settings, it will try and detect your hardware for you. Give your server a name, set up your username and password, and then continue with the installation as directed.
Like the graphical Ubuntu, the server edition comes with options to automatically set up the partitions – by default, using the whole disc will create an install partition and a swap. If you want it to use a specific set of partitions, we recommend sorting them out with GParted before trying to install, and then assigning the partitions manually yourself.
During installation you’ll get some extra questions about whether you need a proxy or not; set that up as you wish and then it will ask about other services to install. As we’re using this as a file server, make sure OpenSSH is installed so you can dial in from another machine on the network and ensure that a Samba server is installed, to make sharing files and such over the network easier and compatible with any Windows machines.
Finally, it will prompt you to install GRUB. Assuming this is a dedicated file server, you can let it overwrite the master boot record. Once that’s done you will restart the system, so make sure you remove the live boot medium. After it loads up, you will be dumped into the command line to log in – as this is a server distro, there is
no desktop environment.
First steps
Now you’re into Ubuntu, we’ll first get set up to SSH into the machine. For something like a home server it’s best to set a static IP, and we can do that in /etc/network/interfaces. Open it up with:
$ sudo nano /etc/network/interfaces
… and change the primary network interface to be something like:
auto eth0
iface eth0 inet static
address [Desired IP]
netmask 255.255.255.0
gateway [Router address]
If you are using a wireless connection, make sure you switch it to wlan0 and then add in details for the SSID and password.
With the IP you’ve set, or using ifconfig to find out what the IP has been automatically set as, you can now SSH into your machine using the username and password that you set up. From a machine on the same network, type:
$ ssh [username]@[IP address of server]
Entering the password will grant you access to the same command line interface.
Shared folders
Now we can create a shared folder that the rest of the network can see and modify. First, let’s create the folder that we want to use and put it in the normal home directory, with a usual:
$ mkdir ~/networkshare
It’s best if you don’t use any spaces, to make the sharing simpler. Once done, you’ll need to create a password for Samba. Do this by entering:
$ sudo smbpasswd -a [username]
It will ask you to enter and then confirm the password. Once that’s done, and with the folder created, we can add it to the Samba server. Access the config file using:
$ sudo nano /etc/samba/smb.conf
It’s best if you don’t use any spaces, to make the sharing simpler. Once done, you’ll need to create a password for Samba. Do this by entering:
$ sudo smbpasswd -a [username]
It will ask you to enter and then confirm the password. Once that’s done, and with the folder created, we can add it to the Samba server. Access the config file using:
$ sudo nano /etc/samba/smb.conf
Go to the very end of the file and add something like the following to get the shared folder recognised by Samba:
[NetworkShare]
path = /home/[username]/networkshare
available = yes
valid users = [username]
read only = no
browseable = yes
public = yes
writable = yes
Save the file and exit, then restart Samba:
$ sudo service smbd restart
And finish by testing the setup with testparm to ensure everything runs okay.
Build a web server
Your own web server can be a useful addition to any system. If you don’t have massive loads to worry about you can install it to your own custom-built server, or if you have a lot of scalable server space then you can build it on there with a very similar software setup.
We are going to use Ubuntu Server again for this, so follow our advice on the previous pages on how to get it set up and get to a point where we can start adding Apache services. Feasibly, you could have the server be both a file and web server in this way.
1. Install Apache
Once you’ve got your server set up and can SSH in, it’s time to install the Apache web server . Do that using the following:
$ sudo apt-get install apache2
It will automatically set the domain address to the following: 127.0.0.1
2. Test server
If you have to install a GUI onto your server, you can test out that Apache is working by going to a browser in it and navigating to 127.0.0.1. Otherwise, from an external system, navigate to the IP address of your system in your browser and it should show the Apache confirmation page on-screen.
3. Install FTP
With a web server you can now use it to host a website or to access storage from the server remotely over the Internet. We can set up the latter using FTP, or in our case the secure VSFTP. Install it to the system using:
$ sudo apt-get install vsftpd
4. Configure FTP
We can access the configuration file for FTP by using nano to open /etc/vsftpd.conf (sudo nano /etc/vsftpd.conf). From here we can configure it to match our uses, but first it is necessary that we increase the security just slightly before using it properly as an FTP server, just to be on the safe side.
5. Secure your FTP
The main change to make the FTP secure is to turn off anonymous users. In the config file, look for the line with ‘anonymous_enable’. We want to change this to NO if it’s not already there, just to make sure that there is a bit more security for the FTP server and that all of your content is kept private.
6. Local use
While it will be great to access these files externally, we might as well have it so you can access the FTP internally too, just in case you prefer that to a shared folder. Find the line ‘local_enable’ and change it to YES to make sure it’s accessible elsewhere.
7. Edit files
As we are only letting people we want onto the server, we can make it so anyone logged in has write access. To do this, go back into the config file, look for the line with ‘write_enable’ and change it to YES. You may also need to uncomment it by removing the hash.
8. FTP Folder
If you didn’t create a shared folder for the previous server tutorial, now is a good time to create a dedicated directory for this. In the home folder, use mkdir to create a directory called whatever you wish for the FTP server to be able to access it.
9. Restart server
Once the config file has been fully edited and the folder is created, it is now time to start using it. Restart the FTP server using sudo service vsftpd restart and you will start to be able to access the folder. Any changes that you make to the configuration will require this restart to become active.
from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/200NGf1
via IFTTT
No comments:
Post a Comment