Set up your own media-sharing site with MediaGoblin
YourTube
The same way that "ease of use" usually equates to less flexibility, "convenience" is nearly always synonymous with less privacy, and YouTube nowadays is very, very convenient. If you just want to share a video, and not your personal data, or you want to avoid rude users from commenting on your kids' videos, MediaGoblin is what you need.
MediaGoblin [1] has several things going for it, not least of which is that, in this post-PRISM world, you can set up and control you own personal media-sharing site without having to go through Google or Vimeo. MediaGoblin is also very versatile, because it can also act as a stand-in for Flickr, SoundCloud, and soon Blogger. Additionally, it can render 3D files in real time.
Install
As usual, I used a stock Debian Wheezy on VirtualBox with all updates applied on 28/09/2013 as my test machine. When installing Debian, I chose the server option (databases, web servers, etc.). MediaGoblin itself is still under heavy development and is not yet packaged into most distros.
Your best option is to grab the latest version from its Git repository, so first you'll need to get and install Git, then clone MediaGoblin and download all the necessary files:
# apt-get install git $ git clone git://gitorious.org/MediaGoblin/MediaGoblin.git
Because MediaGoblin is a rather complex piece of software, several dependencies need to be satisfied:
# apt-get install python python-devpython-lxml python-imaging python-virtualenv
Unless you plan to have a dedicated server running your site, the recommended approach is to run MediaGoblin in its own Python environment.
The next step is to set up the database back end. MediaGoblin supports both PostgreSQL and SQLite (the default), but the latter is not very scalable and only works for very small deployments. I'll go with the PostgreSQL deployment. To begin, install the PostgreSQL packages:
# apt-get install postgresql postgresql-client python-psycopg2 postgresql-server-dev
In Debian, PostgreSQL comes with a passwordless user called postgres, from which you can run PostgreSQL commands. You cannot access this user directly (e.g., with su postgres
), because no password will work, so you have to access root
and then move down into postgres
:
$ su # su postgres
Once you're logged in as postgres, you can start building the framework for MediaGoblin. First, create a MediaGoblin user for the database
$ createuser MediaGoblin
and answer no to the three questions PostgreSQL asks you about the user's privileges.
Next, you can create the database proper:
$ createdb -E UNICODE -O MediaGoblin MediaGoblin
This step creates the database MediaGoblin and assigns ownership to the user MediaGoblin.
The MediaGoblin documentation recommends creating an unprivileged, passwordless Linux user account to run the server, so I'll show how to do that, too. To start, exit from the postgres user to root:
$ exit
Next, create the Linux user using the --shell
, --no-create-home
, --system
, and --group
flags as follows:
# adduser --shell /bin/bash --no-create-home --system--group MediaGoblin
Copy the directory with the MediaGoblin files to your web server root directory
# cp -Rv MediaGoblin/ /var/www/
and change ownership to the MediaGoblin user:
# chown -hR MediaGoblin:MediaGoblin /var/www/MediaGoblin/
You can now su
into the MediaGoblin account and cd
into the MediaGoblin
server directory to continue with the installation:
# su MediaGoblin $ cd /var/www/MediaGoblin
I will assume that all the following steps are executed from within the /var/www/MediaGoblin directory.
Unless you are dedicating a whole machine to MediaGoblin, you are advised to run all its programs from within a Python virtual environment. You can set up the environment with
$ (virtualenv --system-site-packages . ||virtualenv .)&& ./bin/python setup.py develop
MediaGoblin requires FastCGI and needs flup (a "Random assortment of WSGI servers," according to the project page). You can install flup with
$ bin/easy_install flup
The final step is to create and modify the MediaGoblin_local.ini
file: Copy MediaGoblin.ini
to MediaGoblin_local.ini
, open the newly created file with a text editor, and uncomment the line
# sql_engine = postgresql:///MediaGoblin
Next, change the fake email address in the line
email_sender_address = "notice@MediaGoblin.example.org"
to an address from which you want warnings sent. You'll also need to edit MediaGoblin/config_spec.ini
, specifically the lines shown in Listing 1, to configure the setup for your email server.
Listing 1
Editing mediagoblin/config_spec.ini
email_debug_mode = boolean(default=True) email_smtp_use_ssl = boolean(default=False) email_sender_address = string(default="notice@mediagoblin.example.org") email_smtp_host = string(default='') email_smtp_port = integer(default=0) email_smtp_user = string(default=None) email_smtp_pass = string(default=None)
When you're done, you can save all the files and run:
$ bin/gmg dbupdate
By the way, gmg
is a MediaGoblin tool that comes with several utilities for updating databases and managing users; it even provides a Python shell to monitor and change MediaGoblin's behavior on the fly. In this case, I'll update the databases in MediaGoblin.
With that, installation is complete. You can test your site by running
$ ./lazyserver.sh --server-name=broadcast
and visiting http://localhost:6543 (Figure 1).
By using the --server-name=broadcast
option, you should also be able to access the server on your intranet at http://serverip:6453.
Setup
Although MediaGoblin comes with its own server embedded for testing purposes, this server is not adequate for production. To help serve all the static material, you should deploy MediaGoblin with a full-fledged web server, such as Apache or Nginx [2].
The MediaGoblin documentation project provides plenty of examples of scripts to optimize the execution of Celery (an asynchronous task queue that allows users to load media while visiting other parts of your site) and FastCGI (a framework that provides a way to improve the performance of server-side scripts) for various web servers. It also provides startup scripts for Linux so that the server runs every time the machine is powered up.
Apart from that, most administration of the site itself is done by editing the MediaGoblin_local.ini
and the paste_local.ini
files created earlier. One of the first things you must do is change the line
email_debug_mode = true
to
email_debug_mode = false
so that the system sends email to users (e.g., verification email). If you don't, the text of the email will show up on the lazyserver
output, but won't be sent over the Internet. As mentioned previously, you will also have to write in the correct configuration for your email service in MediaGoblin/config_spec.ini
.
Another thing you can do is turn off registration if you just want to set up a private website. You can do that by changing the line
allow_registration = true
to
allow_registration = false
With allow_registration
set to false
, only the server administrator can create user accounts, which can be done with gmg
:
$ bin/gmg adduser
The script will prompt you for a username and password and register the user with your instance of MediaGoblin.
To make a user a site administrator, you also use gmg
:
$ bin/gmg makeadmin <username>
Currently, the site admin's powers are limited to being able to monitor contents being processed.
Finally, there's the matter of getting types of media working on your server.
Media
By default, your MediaGoblin site will allow you to upload images. Try anything else, and you'll get the message, Sorry, I don't support that file type :( (Figure 2).
If you look under MediaGoblin/media_types/
, however, you will also see the ascii/
, audio/
, image/
, pdf/
, stl/
, and video/
directories. These contain the plugins for the different types of media. The MediaGoblin/media_types/audio
directory, for example, contains the configuration files and all the code necessary to allow MediaGoblin to understand OGG, MP3, and WAV files.
To add audio to your setup, open your MediaGoblin_local.ini
file in a text editor and add
[[MediaGoblin.media_types.audio]]
in the [plugins]
section.
Note, however, that you're not done yet. If you run gmg updatedb
(which is what you have to do every time you update MediaGoblin_local.ini
), it will choke on half a dozen failed dependencies. You have to install a bunch of XML and sound-related packages on your system,
# apt-get install libxml2-dev libxslt-dev python-gst0.10-devlibsndfile1-dev
along with several Python packages in your virtual environment,
$ bin/easy_install jinja2 $ bin/easy_install Pygments $ bin/easy_install lxml $ bin/easy_install psycopg2 $ bin/easy_install scikits.audiolab
before things start to look good.
Now you can run gmg updatedb
and the command
$ ./lazyserver.sh --server-name=broadcast
to start uploading audio files to MediaGoblin. The system even renders a graphic wave representation of your files (Figure 3).
The great thing is that, if you get audio files working on your site, you won't have to do much else if you want to upload videos (Figure 4). Just add the line
[[MediaGoblin.media_types.video]]
to the [plugins]
section of MediaGoblin_local.ini
, run gmg updatedb
and lazyserver.sh
again, and video support will be implemented into your setup.
MediaGoblin transforms all videos to the WebM format, the open video format developed by Google, and, in theory, supports a wide variety of upload formats. I tried MP4 and WebM, which worked fine, as well as OGV (Ogg Theora), which didn't. There's a bug in the thumbnail-creating code of the version I was using (nightly 0.6.0). I hope by the time you read this, that bug will have been squashed.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.
-
Plasma Desktop 6.1.4 Release Includes Improvements and Bug Fixes
The latest release from the KDE team improves the KWin window and composite managers and plenty of fixes.
-
Manjaro Team Tests Immutable Version of its Arch-Based Distribution
If you're a fan of immutable operating systems, you'll be thrilled to know that the Manjaro team is working on an immutable spin that is now available for testing.