Tuesday, June 30, 2015

Internal Server Error on ownCloud Ubuntu Server 14.04

I have followed the automatic installation tutorial for ownCloud,[1] from software.opensuse.org,[2]. Needless to say, it didn't go as smooth as apt-get install and enjoy. After installing, enabling SSL with a self-signed certificate and using the absolute default settings I was greeted with a not so nice message below.
Internal server error message when trying to access mydomain.com/owncloud

Solution

After quite a bit of searching the solution was to add he following lines to the config file /etc/apache2/apache2.conf,[3].
<Directory /var/www/>
   Options Indexes FollowSymLinks
   AllowOverride All
   Require all granted
</Directory>
Simple edit the file by
sudo nano /etc/apache2/apache2.conf
and add the mentioned lines to the end of the file.

Save changes with CTRL+O, exit with CTRL+X. Then restart apache2 with
sudo service apache2 restart
Or in case you are running Ubuntu 12.04
sudo /etc/init.d/apache2 restart
Your error should be fixed and ownCloud ready to be used.

Sources

[1] - ownCloud.org
[2] - https://software.opensuse.org/download.html?project=isv:ownCloud:community&package=owncloud
[3] - http://sharadchhetri.com/2014/01/16/how-to-install-owncloud-6-in-ubuntu-13-10-server/

Saturday, June 27, 2015

Install & Configure Mumble Server (Murmur) on Ubuntu

"Mumble is a voice chat application for groups. While it can be used for any kind of activity, it is primarily intended for gaming. It can be compared to programs like Ventrilo or TeamSpeak. People tend to simplify things, so when they talk about Mumble they either talk about "Mumble" the client application or about "Mumble & Murmur" the whole voice chat application suite." [1]

Recently my Raspberry Pi broke down at home that was serving a small Mumble server (this is called Murmur). Since I am away from home I cannot fix it so I have decided to buy a VPS sever and run it off from there. I have found an amazing VPS provider that sells VPS plans starting from 9.99€/year with decent configuration (Affiliate link). This guide is for all those who want to easily set up and configure a server "ready to go" as fast as possible.

Installation

Installing Murmur (mumble server) is straightforward in Ubuntu, it can be done via the pat repository through apt-get commands.
Update your repository and packages that might be out of date
sudo apt-get update
sudo apt-get upgrade
Install and do an initial configuration on mumble-server
sudo apt-get install mumble-server
sudo dpkg-reconfigure mumble-server
The images below show what you will be prompted when running the dpkg-reconfigure command.
Select yes if you want mumble-server to start upon boot. This is a useful feature just in case the server or your OS crashes and otherwise you would forget to start your services.
Generally set this to "yes" as well to increase performance and audio quality of your server.
Finally, set a SuperUser password. This will be only used for logging in with the root account called "SuperUser" and administering channel properties.


The mumble server is now up and running, however it is not fully configured. Next is to set server password, audio quality, port and so on. Proceed to the next step.

Configure your Server

Mumble server has a single configuration file for interest for us located in /etc/mumble-server.ini. This file has to be edited with any kind of text editor of your liking.The configuration file is self-explanatory and there is also a complete documentation on it [2].
sudo nano /etc/mumble-server.ini
There are many settings here that you can tweak, however the  most important ones (for a quick setup at least) are the following.

welcometext

This is the welcome message that will be displayed to clients when joining the server. The mumble client shows this message in the standard message window on the left side of the client.
welcometext="your welcome message comes here"
You can use standard html syntaxin the message to display something more than a plain text. Some examples:
<b>bold</b> - makes enclosed text bold
<i>italic</i>  - makes enclosed text italic
<br /> - inserts a line break

port

The port where users have to connect to the server. If you change the default port, make sure to let your users know.
port=64738

serverpassword

Quite obviously, this is the server password users need to connect. Set it to something strong as the client is able to remember it, so users will not be promoted to enter this on every connection.
serverpassword=superstrongpasswordyeah

bandwidth

This is the audio bandwidth per user. The default is 70'000 bits/s and the higher you set this, the better the audio quality. Setting it higher to 130'000 has no effect, I usually go with 128'000 bits/s.
bandwidth=128000

users

Defines the maximum number of users allowed on the server. If you are running a small server for a handful of people, this probably isn't so important for you, although setting it to 20-50 wouldn't hurt anyway. It becomes important when you are running a larger server and your bandwidth is limited.
users=50

Apply Changes

In order for the changes to take effect you have to restart the mumble server
sudo service mumble-server restart
There are of course a lot more settings, but these initial points are probably the most important. Feel free to play around.

Managing Channels

Once everything has been set up on the server side it is time to log in with a client and start configuring the channels. For starters, there will only be 1 root channel on the server.By default only the SuperUser (the mumble servers "root" user) has the right to add, delete and edit channels. So it is useful to give your account (the one you will personally use on your server) administrator rights. This saves the hassle of logging in all the time with the root account. To do this, follow these steps, which are also nicely explained in the wiki [3].

  1. Open a mumble client, navigate to Configure/Settings and check the "Advanced" checkbox at the bottom left corner.
    Configure/Settings window after enabling Advanced view by checking the checkbox at the bottom left corner of the window.
  2. Pick a username and connect to your server at the server's IP address, with the specified port and server password. 
  3. Click on Self/Register, which will lock your username on the server.
  4. Disconnect from the server.
  5. Reconnect to the server, however use the following username & password,
    username:SuperUser
    password:<the one you set in dpkg-reconfigure mumble-server>

    In case you forgot the SuperUser password, don't worry. Log in to your server and re-run sudo dpkg-reconfigure mumble-server

    At this point you should be logged in as SuperUser and you have the right to create and edit channels. Simply right-click a channel and see what options you have.
  6. To give administrator rights to your user account select the root channel, right-click and select Edit.
  7. Go to the Groups tab and select admin from the dropdown menu. Then at the bottom of the window type your username into the field and click Add. See the image below.
    Root>Edit>Group window showing my user account added to the admin group. Afterwards, I can edit channels with my everyday user account.  
  8. Save changes by clicking OK. Now you can simply log out and log back in with you user account.
Editing channels is simply done by right-click/edit. You can also add new channel and sub-channels by selecting Add from the menu. Configure a server and channel structure of your liking!

But wait! There's more!

If you want to learn more about channel settings, groups and administration I strongly suggest watching the video below (10 minutes and you learn a lot). Groups and permissions are nicely explained and you can configure your server pretty good if you follow what is shown in the video.


If you have any questions, leave a comment below and I'll get back to you as soon as possible.

Sources

[1] - http://wiki.mumble.info/wiki/FAQ
[2] - http://wiki.mumble.info/wiki/Murmur.ini
[3] - http://wiki.mumble.info/wiki/Murmurguide#Becoming_Administrator_and_Registering_a_User

Friday, June 26, 2015

Installing nodejs from Source

I needed to install a software using nodejs. Unlucky for me from the apt repository I could only get nodejs version 6.something, however the latest one is 12.5 asof this moment. Hence I decided to go ahead and build it for myself from source.

The steps were the usual required for compiling any software in general.

wget  https://nodejs.org/dist/v0.12.5/node-v0.12.5.tar.gz
tar -xzvf node-v0.12.5.tar.gz
cd node-v0.12.5
./configure
make
sudo make install

However, after installing it I had no npm, which should be part of and installed along with nodejs. Seemed like node was not in my PATH so this had to be adjusted quickly.

The solution was to add /usr/local/bin/node to my PATH in ~/.profile
nano ~/.profile

And add either a new line like this:
PATH=$PATH:/usr/local/bin/node

or if you altready have a PATH defined, add this to the end
/usr/local/bin/node

Press CTRL+O to write the file and CTRL+X to close nano. Finally,
source ~/.profile

npm worked just fine after this.

Wednesday, June 10, 2015

Repair Filesystem Errors in Ubuntu with fsck

I have an ATA 80GB HDD in my laptop now, which is, well yes, old and has some issues. I wanted to test it with fsck and tell it to repair any file system errors. So I looked into the topic a bit.

Important about fsck

The most important thing you need to know about fsck is that it can only fix filesystems if they are not mounted. Hence when your computer is running, you can (if you really want to) run fsck on your /home directory, however not on root. So in general there are 2 main approaches that you can implement to check your entire hard drive,
  1. Run a live CD version
  2. Run fsck during boot
Here I will only explain how to run fsck on boot as I think this is much less of a hassle than creating a live CD, booting from it etc. Furthermore, the benefit of running fsck at boot (as you will see) is that you can schedule it at intervals of your liking. Sort of a "set it and forget it" approach.

Let fsck attempt to fix errors automatically

Firstly tell fsck to automatically repair filesystem inconsistencies during boot. This can be set in the following steps. First, open /etc/default/rcS with a text editor, e.g. nano
sudo nano /etc/default/rcS 
 And find the line at the end where it says,
# automatically repair filesystems with inconsistencies during boot
FSCKFIX=no
and change the tunable "no" to "Yes".

Schedule fsck run interval on boot

Scheduling an fsck check can be based on 2 main parameters, invoked by 2 command parameters,
  • -c = sets interval based on how many times the filesystem was mounted
  • -i  = sets interval based on how much time has passed since the last check
The next step is to schedule fsck running in specific intervals. I have set mine for every 10 days initially, however later on I moved it to once per month to save some time at boot. Of course, next to this a mount-dependent check can be scheduled too.

Determine filesystem mount points

First of all, quickly check on which filesystem your root and home directory are mounted. I like to do this quickly and easily with
df -h
Example output of df -h command, showing mount points of different directories
From this you can see that my root directory is on /dev/sda2, while my /home is on /dev/sda3, hence I will tell fsck to check these filesystems.

Schedule fsck based on time interval

To tell fsck to check my root filesystem I have to issue the following command,
sudo tune2fs -i 1m /dev/sda2

Which will then return,
Information returned when executing above command.
This tells Ubuntu to run filesystem check at boot every month on the root directory. You can also use different intervals, below are some examples.
-i 10d = interval of 10 days
-i 1m = interval of 1 month
-i 2w = interval of 2 weeks

Schedule fsck based on number of mounts

Additionally, or instead of, time-based fileysystem checks you can also tell fsck to run after, say every filesystem 30 mounts. To do this use the -c parameter,
sudo tune2fs -c 30 /dev/sda2
Tip: If you wish to set any other interval, check out man tune2fs for more information!

Confirmation

Also, you can check if the effects really took place with,
sudo tune2fs -l /dev/sda2
This will give an output similar to the one below. The lines we are interested in are towards the bottom, highlighted in red.
tune2fs 1.42 (29-Nov-2011)
Filesystem volume name:   <none>
Last mounted on:          /
Filesystem UUID:          9f344424-1e1c-47db-a2b6-13104e5c754c
Filesystem magic number:  0xEE12
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              1120112
Block count:              4461312
Reserved block count:     223065
Free blocks:              1219061
Free inodes:              467223
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      893
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8176
Inode blocks per group:   511
RAID stride:              32603
Flex block group size:    16
Filesystem created:       Wed Oct 26 15:27:33 2011
Last mount time:          Wed Jun 10 08:06:25 2015
Last write time:          Wed Jun 10 09:53:37 2015
Mount count:              16
Maximum mount count:      27
Last checked:             Fri May 29 20:57:05 2015
Check interval:           2592000 (1 month)
Next check after:         Sun Jun 28 20:57:05 2015

Lifetime writes:          357 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:              256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       48
Default directory hash:   half_md4
Directory Hash Seed:      8dc55d5d-db7c-4717-ab06-6fad98d89896
Journal backup:           inode blocks
After this you are done, the above output will tell you when the previous and next checks were and will be. However, if you wish to run a one-off check at boot, you can do it as well.

Turning off periodic fsck check on boot

 Quoting from the tune2fs manual,
"It  is  strongly  recommended that either -c (mount-count-dependent) or -i (time-dependent) checking be enabled to force  periodic  full  e2fsck(8) checking of the filesystem.  Failure to do so may lead to filesystem corruption (due to bad disks,  cables, memory, or kernel bugs) going unnoticed, ultimately resulting in data loss or corruption."
However, if you really want to switch it off completely,
sudo tune2fs -c -1 -i 0
Which will turn off both time and max-mount-count dependent  checks.

Force check on next boot

If you want to do a check on the next boot execute the following command,
sudo touch /forcefsck
This will create a temporary file in / that tells fsck to execute a filesystem check on the next boot.