Creating a Ubuntu File and Plex Media Server
In this article, I'm going to show you how I setup my home file and media server using Ubuntu Server 14.04 using Samba and Plex media server.
Adverts Blocked Please disable AdBlocking software and allow me to set cookies so that I can continue providing free content and services.
Firstly, head on over to the Ubuntu website and download the latest version of Ubuntu Server if you haven't done so already. You can burn the ISO to CD or DVD, or you can do what I did and use UNetbootin to make a bootable USB drive.
Installation was a little problematic for me, I had to use a 4GB USB stick formatted to FAT32. Larger drives would not boot properly and any other file system causes mounting problems.
Once booted from the USB stick, I selected the Install option from the menu. This launches the installation process which is pretty straight forward. Once installed, reboot the machine, log in and run a check for updates.
sudo apt-get update sudo apt-get install
If there were updates installed, you should reboot to ensure you are working on the latest modules.
Next I had to install OpenSSH so I can use Putty to remotely access the server. I forgot to check the option during the install, if you did as well you can install it using this command.
sudo apt-get install openssh-server
RAID is a method of using multiple hard drives to act as one. For details of different raid types, performance and data redundancy, please see my tutorial Visual Guide to RAID Levels.
Installing RAID in Ubuntu, issue these commands:
sudo apt-get update sudo apt-get install mdadm
Now, using fdisk delete any partitions on the disks that will become part of the array. This process will wipe data, so go carefully here.
Next, create the RAID array using the available hard drives
mdadm -v --create /dev/md0 --level=raid10 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
When that is complete, you can format the new array
And the finally mount for use
mount /dev/md0 /myraid
Check Status of the RAID array
To check the status and health of the array, use this command:
This will output something like this
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] md0 : active raid10 sdd sde sdb sdc 3906765824 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU]
Additional commands of use
To stop an array
sudo mdadm --stop /dev/md0
To remove a disk from an array
sudo mdadm --remove /dev/md0 /dev/sda1
Add a disk to an array
sudo mdadm --add /dev/md0 /dev/sda1
Start an Array, to reassemble (start) an array that was previously created
mdadm --assemble --scan
One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a File Server. This section covers setting up a Samba server to share files with Windows clients.
sudo apt-get update sudo apt-get install nfs-kernel-server
Configure Samba Shares
The main Samba configuration file is located in
/etc/samba/smb.conf. Edit this file and add in your shares information. Mine is shown below as an example.
[fileserver] guest only = yes guest account = root create mode = 777 public = yes directory mode = 777 path = /myraid/files writeable = yes force user = root force group = root
After making changes, use these commands to restart the services and apply changes.
sudo restart smbd sudo restart nmbd
Apache is one of the most popular web servers on the net, with MySql and PHP being the most popular database and web development languages in the open source / Linux environments.
To install Apache web server, run these commands:
sudo apt-get update sudo apt-get install apache2
That's all you have to do. Hit the server in a web browser and you should see a default page. We'll get back to the configuration in a sec, but first let's install MySql and PHP.
MySQL is a powerful database management system used for organizing and retrieving data. To install MySQL, use this command:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.
Once you have installed MySQL, we should activate it with this command:
Finish up by running the MySQL set up script:
The prompt will ask you for your current root password. Type it in.
Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps. It's easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
PHP is the final application in the LAMP stack, it is an open source web scripting language that is widely used to build dynamic web pages. To install PHP, enter in this command.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
After you answer yes to the prompt twice, PHP will install itself.
Check here for further details on Apache and PHP configuration.
PLEX is a home media server which organises your video, music, and photo collections and streams them to all of your screens. Installation is a breeze but requires a few extra steps as it's not in the main universe.
First, visit the PLEX website and note down the link to the Linux .deb download.
In the command line, download the file to your home folder and run the installer. At the time of writing, the latest version is:
wget https://downloads.plex.tv/plex-media-server/0.9.15.3.1674-f46e7e6/plexmediaserver_0.9.15.3.1674-f46e7e6_amd64.deb sudo dpkg -i plexmediaserver_0.9.15.3.1674-f46e7e6_amd64.deb
Once installed, you can access the web interface from the following URL
Change the IP address to match your server IP address or hostname. You can then configure your library collection from the settings menu.
Apache Subversion (often abbreviated SVN, after the command name svn) is a software versioning and revision control system.
To install, run the following command:
sudo apt-get install subversion
Create a folder to hold the repository files and set permissions
sudo svnadmin create /myraid/svn/projects sudo chown -R www-data:www-data projects sudo chmod -R g+rws projects
To access the SVN through HTTP (for applications like Tortoise) edit the configuration file to add the repository to Apache web server.
sudo pico /etc/apache2/mods-available/dav_svn.conf
<Location /svn/projects> DAV svn SVNPath /myraid/svn/projects AuthType Basic AuthName "Name of my repository" AuthUserFile /etc/subversion/passwd Require valid-user </Location>
Next, generate the password file specified in the AuthUserFile
sudo htpasswd -c /etc/subversion/passwd username
Restart Apache to make changes take effect
sudo /etc/init.d/apache2 restart
Finally, install Webmin. It makes configuration from here on a lot easier, with a web interface for configuration of most modules and applications. Again, Webmin isn't in the official universe, so you'll need to add a reference to it.
sudo pico /etc/apt/sources.list
Navigate to the bottom of the file and insert the following lines.
deb http://download.webmin.com/download/repository sarge contrib deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Save the file and return to the terminal. Next, you need to download the hash key and install it.
wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add -M
Now we're ready to install Webmin
sudo apt-get update sudo apt-get install webmin
You can now log into Webmin using the URL below. Change the IP address to your server IP or hostname.
Last updated on: Saturday 17th June 2017
There are no comments for this post. Be the first!