Build from Source

From MythTV Official Wiki
Jump to: navigation, search

Software-update-available.png This page is up-to-date as of MythTV version 34, the current release is 34.0

Introduction

For most people, it will be far easier to install a pre-built package for MythTV rather than building from source. Reasons for building from source include:

  • There is no pre-built package for your Linux distribution.
  • The pre-built package for your distribution is out of date.
  • You want to run a pre-release version of the software.
  • Users choose to test/write patches.

If you have already installed a pre-built package and you have a need to try out a source code change, it would be preferable to use your distribution's build process to build a version that is compatible with the already installed version. There are differences in the placement of files between the downloaded packages and the code you build yourself.

This guide shows how to build from source code downloaded from github.

Raspberry Pi

Starting from version 0.28 It is possible to build and run MythTV frontend on a Raspberry Pi 2 or Raspberry Pi 3. Since the Raspberry Pi has limited resources there are some steps you can take to ensure a successful build.

I strongly recommend using Raspbian rather than Ubuntu for building and running MythTV. Raspbian is optimized for multimedia and provides a more stable environment and better performance for applications that use OpenMAX and OpenGL ES.

Setting up a Raspberry Pi for building MythTV
Before attempting to build you should take these steps.


Install the operating system on an external USB hard drive.

Use a hard drive that has its own power supply. If you have an old hard drive around that you no longer use you can buy a USB enclosure for it. You need a hard drive of 50 GB or more.

These steps can be done on the Raspberry Pi itself but are easier if done from an desktop computer running Linux.

  • Install your Raspberry Pi operating system on an SD card as normal. If you are going to use the Raspberry Pi to prepare the hard drive you will need to prepare a second SD card. Make sure your SD cards boot correctly into the operating system.
  • Partition your hard drive. Create an ext4 partition of at least 50 GB for your operating system. I recommend using gparted. Format it as ext4 (gparted can do that for you).
  • Copy your SD card contents to the new hard drive partition. If you are using the Raspberry Pi to do this do not copy the SD card from which you are booted. You will need an SD card reader plugged into a USB port to read the SD card that you are copying from. Use lsblk to determine the device names. If you are running a Graphical environment it may automatically mount the devices. Otherwise mount them in an appropriate place. On the SD card you are copying from use the second partition (e.g. /dev/sda2).
sudo cp -av /source/directory/* /dest/directory/
  • Edit the /boot/cmdline.txt file on the SD card you are copying from. Change the parameter root=/dev/mmcblk0p2 to root=/dev/sda1. If you are not using the first partition on the hard drive change sda1 to the correct partition.
  • Edit the /etc/fstab file on the hard drive. Find the line for the root mount. Change the device name at the beginning of the line from /dev/mmcblk0p2 to /dev/sda1, or the correct hard drive partition.
  • Shut down your Raspberry Pi, insert the SD card you were copying from, and plug in the external hard drive. Make sure you do not have another drive or USB Card reader plugged in. The Raspberry Pi will now boot with the hard drive as root partition.


Swap space

I had previously recommended creating a large swap area. However it is far better to avoid swapping altogether, by limiting the build to 3 processes. Once the system starts swapping, performance becomes ridiculously poor.

Reduce GPU memory

Edit /boot/config.txt and comment out the gpu memory line when building

#gpu_mem=256


Setup ccache

After installing the prerequisites make sure there is enough ccache as follows

ccache -M 5G -F 0

With all of these steps in place, the first build of MythTV will take around 2 hours on a Raspberry Pi 2. Subsequent builds can take as little as 2 minutes. With ccache, even a full rebuild can complete in 10 minutes, because it caches the compiler results and if the source does not change it re-uses them.

Dependencies

One of the most difficult parts of building the code is getting the correct dependencies installed first. The syntax for installing these will vary from one distribution to another, and package names may also vary between distributions.

Installing Build Dependencies with Ansible

Mythtv now has Ansible playbooks to set up build dependencies. These support many Linux variants and will easily install your build dependencies. Follow the following steps to install build dependencies.

Installing Build Dependencies without Ansible

It is recommended to use Ansible, because that will be kept up to date. Alternatively, to install the dependencies manually, follow these instructions.

Build Dependencies for version 0.27
All Environments build-essential ccache yasm libqt4-dev libqtwebkit-dev libqt4-opengl-dev po-debconf texi2html linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev default-libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev uuid-dev libxml-xpath-perl libtool-bin
i386/amd64 Add this: libcrystalhd-dev
debian-wheezy

ubuntu-precise

replace libtiff5-dev with libtiff4-dev (avoids conflict in libimlib2-dev).
Notes

If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages: debhelper quilt dh-python dh-systemd

On debian-jessie and debian-wheezy replace default-libmysqlclient-dev with libmysqlclient-dev.

On debian-wheezy and ubuntu-precise replace dh-python with python-central (avoids backports).

Build Dependencies for version 0.28 and 29
All Environments build-essential ccache yasm help2man qtdeclarative5-dev libqt5webkit5-dev libqt5opengl5-dev qtscript5-dev qt5-qmake po-debconf linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev libexiv2-dev uuid-dev libxml-xpath-perl git hello libtool-bin libsamplerate0-dev libxnvctrl-dev liblzo2-dev
i386/amd64 Add this: libcrystalhd-dev
debian-wheezy replace libtiff5-dev with libtiff4-dev (avoids conflict in libimlib2-dev).

wheezy will require wheezy-backports repository to then automatically pull in qt5

debian stretch or raspbian stretch remove libcec-dev. Add libcec4-dev and libxcb-shm0-dev.

replace libmysqlclient-dev with default-libmysqlclient-dev.

Raspberry Pi Add this: libraspberrypi-dev
Notes If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:

debhelper quilt dh-python dh-systemd

On debian-wheezy replace dh-python with python-central (avoids backports).

Build Dependencies for version 30
All Environments build-essential ccache yasm help2man qtdeclarative5-dev libqt5webkit5-dev libqt5opengl5-dev qtscript5-dev qt5-qmake po-debconf linux-kernel-headers libdvdnav-dev libfreetype6-dev libavc1394-dev libiec61883-dev liblircclient-dev libxinerama-dev libxxf86vm-dev libxvmc-dev libxext-dev libimlib2-dev libasound2-dev libmp3lame-dev libvorbis-dev libdts-dev lsb-release libpulse-dev libxrandr-dev libfftw3-dev libva-dev libvdpau-dev libudev-dev libclass-dbi-perl libnet-upnp-perl libio-socket-inet6-perl libdbd-mysql-perl libjson-perl libwww-perl python python-oauth python-lxml python-mysqldb python-pycurl python-urlgrabber libgl1-mesa-dev libdvdread-dev fftw-dev libvorbis-dev libflac-dev libmad0-dev libcdaudio-dev libcdio-dev libcdparanoia-dev libsdl1.2-dev libfaad-dev libexif-dev libtiff5-dev libxv-dev libtag1-dev libvisual-0.4-dev libmysqlclient-dev libdate-manip-perl libxml-simple-perl libimage-size-perl libdatetime-format-iso8601-perl libsoap-lite-perl libx264-dev libvpx-dev libavahi-compat-libdnssd-dev libssl-dev libcdio-cdda-dev libcdio-paranoia-dev libxml2-dev libass-dev libcec-dev libexiv2-dev uuid-dev libxml-xpath-perl git hello libtool-bin libsamplerate0-dev libbluray-dev libxnvctrl-dev liblzo2-dev libxcb-shm0-dev
i386/amd64 Add this: libcrystalhd-dev
debian stretch or raspbian stretch remove libcec-dev. Add libcec4-dev
Raspberry Pi Add this: libraspberrypi-dev
Notes If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:

debhelper quilt dh-python dh-systemd

Build Dependencies for version 31
All Environments automake build-essential ccache git libasound2-dev libass-dev libavahi-compat-libdnssd-dev libavc1394-dev libbluray-bdj libbluray-dev libcdio-dev libcdio-paranoia-dev libcec-dev libdate-manip-perl libdatetime-format-iso8601-perl libdbd-mysql-perl libdbi-perl libdrm-dev libegl1-mesa-dev libexiv2-dev libfftw3-dev libflac++-dev libflac-dev libfreetype6-dev libgnutls28-dev libhdhomerun-dev libiec61883-dev libimage-size-perl libio-socket-inet6-perl libjson-perl liblzo2-dev libminizip-dev libmp3lame-dev libnet-upnp-perl libpulse-dev libqt5core5a libqt5opengl5-dev libqt5sql5-mysql libqt5webkit5-dev libsamplerate0-dev libsoap-lite-perl libssl-dev libsystemd-dev libtag1-dev libtool-bin libva-dev libvdpau-dev libvorbis-dev libvpx-dev libwww-perl libx264-dev libx265-dev libxinerama-dev libxml2-dev libxml-simple-perl libxml-xpath-perl libxnvctrl-dev libxrandr-dev libxv-dev libxvidcore-dev libxxf86vm-dev nasm pkg-config python3-future python3-lxml python3-mysqldb python3-oauth python3-pycurl python3-requests python3-requests-cache python3-simplejson qt5-qmake qtscript5-dev uuid-dev libmysqlclient-dev
i386/amd64 Add this: libcrystalhd-dev
Debian-9-Stretch or raspbian stretch remove libcec-dev. Add libcec4-dev
Raspberry Pi Add this: libraspberrypi-dev
Notes If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:

debhelper quilt dh-python dh-systemd

Build Dependencies for version 32
All Environments build-essential ccache default-libmysqlclient-dev git libasound2-dev libass-dev libavahi-compat-libdnssd-dev libavc1394-dev libbluray-bdj libbluray-dev libcdio-dev libcdio-paranoia-dev libcec-dev libdate-manip-perl libdatetime-format-iso8601-perl libdbd-mysql-perl libdbi-perl libdrm-dev libegl1-mesa-dev libexiv2-dev libfftw3-dev libflac++-dev libflac-dev libfreetype6-dev libgnutls28-dev libhdhomerun-dev libiec61883-dev libimage-size-perl libio-socket-inet6-perl libjson-perl liblzo2-dev libminizip-dev libmp3lame-dev libnet-upnp-perl libpulse-dev libqt5core5a libqt5opengl5-dev libqt5sql5-mysql libqt5webkit5-dev libsamplerate0-dev libsoap-lite-perl libsoundtouch-dev libssl-dev libsystemd-dev libtag1-dev libtool-bin libva-dev libvdpau-dev libvorbis-dev libvpx-dev libwww-perl libx264-dev libx265-dev libxinerama-dev libxml2-dev libxml-simple-perl libxml-xpath-perl libxnvctrl-dev libxrandr-dev libxv-dev libxvidcore-dev libxxf86vm-dev libzip-dev nasm pkg-config python3-future python3-lxml python3-mysqldb python3-oauthlib python3-pycurl python3-requests python3-requests-cache python3-setuptools python3-simplejson qt5-qmake qtscript5-dev uuid-dev
Debian-9-Stretch or raspbian stretch remove libcec-dev. Add libcec4-dev
Raspberry Pi Add this: libraspberrypi-dev
Notes If you are building a Debian or Ubuntu package using dpkg-buildpackage you will need these additional packages:

debhelper quilt dh-python

Run Time Dependencies

If you are installing on a different computer from where you built, you will need the run time dependencies. You do not need the full list of build dependencies. Here is a list of runtime dependencies.

Run Time Dependencies for version 0.27
mysql-server ntp libicu48 libqt4-sql-mysql
Run Time Dependencies for version 0.28, 29 and 30
libavahi-compat-libdnssd1 libqt5widgets5 libqt5script5 libqt5sql5-mysql libqt5xml5 libqt5network5 libqt5webkit5 libexiv2-14 pciutils libva-x11-1 libva-glx1 libqt5opengl5 libdbi-perl libdbd-mysql-perl libnet-upnp-perl python-lxml python-mysqldb python-urlgrabber libcec4 libfftw3-double3 libfftw3-single3 libass5 libfftw3-3 libraw1394-11 libiec61883-0 libavc1394-0 fonts-liberation libva-drm1 libtag1v5 python-future python-requests python-requests-cache

On jessie or Ubuntu prior to 16.04, the last 3 python packages may not be available. Leaving them out will only affect metadata lookup.

On systems where libcec4 is not available use libcec3 instead (code needs to have been build with libcec-dev in that case).

Run Time Dependencies for version 31
libtag1v5 libexiv2-27 python3-future python3-requests python3-requests-cache libavahi-compat-libdnssd1 libqt5widgets5 libqt5script5 libqt5sql5-mysql libqt5xml5 libqt5network5 libqt5webkit5 pciutils libva-x11-2 libva-glx2 libqt5opengl5 libdbi-perl libdbd-mysql-perl libnet-upnp-perl python3-lxml python3-mysqldb libcec4 libfftw3-double3 libfftw3-single3 libass9 libfftw3-3 libraw1394-11 libiec61883-0 libavc1394-0 fonts-liberation libva-drm2 libmp3lame0 libxv1 libpulse0 libhdhomerun4 libxnvctrl0 libsamplerate0 libbluray2 liblzo2-2 libio-socket-inet6-perl libxml-simple-perl python3-lxml python3-mysqldb
Run Time Dependencies for version 32
libtag1v5 libexiv2-27 python3-future python3-requests python3-requests-cache libavahi-compat-libdnssd1 libqt5widgets5 libqt5script5 libqt5sql5-mysql libqt5xml5 libqt5network5 libqt5webkit5 pciutils libva-x11-2 libva-glx2 libqt5opengl5 libdbi-perl libdbd-mysql-perl libnet-upnp-perl python3-lxml python3-mysqldb libcec4 libfftw3-double3 libfftw3-single3 libass9 libfftw3-3 libraw1394-11 libiec61883-0 libavc1394-0 fonts-liberation libva-drm2 libmp3lame0 libxv1 libpulse0 libhdhomerun4 libxnvctrl0 libsamplerate0 libbluray2 liblzo2-2 libio-socket-inet6-perl libxml-simple-perl libzip python3-lxml python3-mysqldb
Run Time Dependencies for MythWeb
All Environments apache2 php5 php5-mysql libhttp-date-perl
Ubuntu Xenial or where php5 is not available apache2 php7 php7-mysql libhttp-date-perl

SQL server

The package mysql-server only needs to be installed on one backend, normally the master backend, or it can be installed on a separate database server, although this would be unusual.

On systems that do not have mysql-server (e.g. remote frontends, slave backends), you need to install mysql-client instead.

Installing Dependencies

Install the build dependencies on your build machine. Install the Run Time dependencies on your MythTV machine (which may be the same as the build machine). If you plan to use MythWeb, install those dependencies on your master backend system.

Distribution Install Command Additional packages
Ubuntu, Debian, MythBuntu, other Debian based distributions. sudo apt-get install Dependency List
build-essential

Depending on your distribution, run the install command with the list of packages.

Getting and compiling the source code

Step Command to run
create a directory cd
mkdir ~/build
clone cd ~/build
git clone https://github.com/MythTV/mythtv.git mythtv
cd mythtv
Check versions available git branch -a
Choose your version. The current stable released version is 33-fixes. We recommend using that version. git checkout fixes/33
If you have previously done a build in this directory, run this if you need a complete rebuild git clean -xfd

In general, you should probably choose the stable version. If you don't mind if your MythTV system is non-functional or has serious bugs that may prevent proper operation/result in lost recordings or inability to play back recordings, you may try using the unstable, development code. If using unstable, development code, you should follow the mythtv-commits and mythtv-dev mailing lists.

Build and Install MythTV

In the ~/build/mythtv/mythtv directory, run the ./configure script. You can see available options by using the --help parameter with configure:

./configure --help

By default the build will install mythtv in a directory structure under /usr/local/. Executables will be in /usr/local/bin. You can modify this behavior with the --prefix= parameter. The default prefix is /usr/local.

Normally you will not need to supply any options to configure, although 0.27 users should add --disable-mythlogserver (mythlogserver). Run it as follows:

Distribution Command to run
Raspbian ./configure --enable-openmax --disable-vdpau --disable-opengl-video --enable-opengl --disable-opengl-themepainter --disable-vaapi
Raspberry Pi Ubuntu (not recommended) ./configure --enable-openmax --disable-vdpau --disable-opengl-video --disable-opengl --disable-vaapi
Others ./configure

Raspberry Pi is only supported with version 0.28 or later.

For building version Master or version 30 for Raspberry Pi, change --enable-openmax to --enable-omx-rpi.

If you want to build with limited debugging info, use --compile-type=profile. When using --compile-type=debug there is more debug info but your code might run a bit slower. That is usually not an issue on Intel/AMD but it could be on Raspberry Pi.

The configure step may identify dependencies that are missing. If so you will need to find them and install them before continuing. Please let us know via an update to this page or make a comment in the discussion page.

If the configure was successful, run the build as follows

make -j 5

The -j option is optional but can speed up the make by running multiple processes at the same time. Set the number to 1 higher than the number of cores in your system.
For raspberry pi set the number to 3. Since the raspberry pi has limited memory, setting it to 5 can cause swapping and that will slow down the build considerably. The build may identify missing dependencies. Install them and notify us via a comment in the discussion.
When the build is successful, install this way

sudo make install

This will install both backend and frontend software. Install this on all machines, backend or frontend. You will only start the backend on the backend machines. On frontend machines the backend software will exist but will not be used.

Build and Install Plugins

Building and installing the plugins is optional. I recommend that new users skip this step. Plugins are not needed for any of the main functionality of MythTV, including watching Videos and watching DVDs. Plugins are for Music, Weather, YouTube, Games, etc.

Plugins are only used on the frontend, so if you have a separate backend you need not install them on the backend.

The plugins build requires that you have first completed a build of mythtv and installed it. It makes use of some of the items set up in the mythtv configure step, and some of the items installed in the install step, so if you have cleaned your mythtv build, the plugins build will not work.

In the ~/build/mythtv/mythplugins directory, run the same commands as above for building and installing MythTV. If you only want to build certain plugins, you can disable the others in the ./configure command (check the --help for the syntax for that).

./configure
make -j 5
sudo make install

Shared-Library requirements for MythTV

The runtime manager for shared libraries, /lib/ld.so, gets information about the locations and contents of shared libraries from /etc/ld.so.cache, a file created by ldconfig from information in /etc/ld.so.conf. Because MythTV installs shared libraries in /usr/local/lib, that directory needs to be added to the list of directories for ld.so to search when doing runtime linking of programs, if it is not already there. You do this, as root, by editing /etc/ld.so.conf, then running ldconfig. There are many ways to do this; to determine the way that your distribution is configured, type:

cat /etc/ld.so.conf
cat /etc/ld.so.conf.d/*

Check if /usr/local/lib is included in the list displayed. If so then no action is needed.

If /usr/local/lib is not already included, then create as root a file under /etc/ld.so.conf.d that contains a line containing

/usr/local/lib

Make sure that /etc/ld.so.conf contains a line as follows

include /etc/ld.so.conf.d/*.conf

To ensure the cache has been updated, run this command:

sudo /sbin/ldconfig

Test Setup

Instead of setting up the shared library cache as described above, if you have customized the location of the libraries using for example ./configure --prefix=/home/peter/work/mythtv, you can install and run the backend and frontend in your home directory by setting the path of the lib files as follows:

export LD_LIBRARY_PATH=/home/peter/work/mythtv/lib
export PATH="$PATH:/home/peter/work/mythtv/bin"

Install MythWeb

Starting in MytTV Version 34, there is a web app at port 6544, which provides most of what is in mythweb. It is recommended to use the web app instead of mythweb.

If you plan to run MythWeb, install it on your master backend server. Install the dependencies, listed above. Check out Mythweb from git:

Step Command to run
clone cd ~/build
git clone https://github.com/MythTV/mythweb.git mythweb
cd mythweb
Check versions available git branch -a
Choose your version. The current stable released version is 33-fixes. We recommend using that version. git checkout fixes/32

Install packages apache2, php and php-mysql.

Set up mythweb as follows:

cd ~/build/mythweb/
sudo cp -r ~/build/mythweb /usr/local/share/mythtv/mythweb
sudo ln -s /usr/local/share/mythtv/mythweb/ /var/www/html/
sudo cp -v /usr/local/share/mythtv/mythweb/mythweb.conf.apache /etc/apache2/sites-available/mythweb.conf

Edit file /etc/apache2/sites-available/mythweb.conf using gedit or vi, for example:

sudo vi /etc/apache2/sites-available/mythweb.conf

Change the lines containing <Directory "/var/www/html/data"> and <Directory "/var/www/html" > so that they read <Directory "/var/www/html/mythweb/data"> and <Directory "/var/www/html/mythweb" >, i.e. add the mythweb subdirectory.

update the lines setenv db_server, setenv db_name, setenv db_login, setenv db_password to contain the correct database info. If you plan to use the default settings, leave as is, otherwise choose new settings, to match what you will use when setting up the database. See MythTV Database Setup below.

Run the following commands

sudo a2enmod rewrite
sudo a2enmod cgi
sudo a2enmod php$(php -r 'echo PHP_MAJOR_VERSION, ".", PHP_MINOR_VERSION;')
sudo a2ensite mythweb.conf
sudo chown -R www-data:www-data /usr/local/share/mythtv/mythweb/data/
sudo chmod -R g+w /usr/local/share/mythtv/mythweb/data/

Restart your apache server using one of these commands as appropriate for your setup:

sudo /etc/init.d/apache2 restart
sudo systemctl restart apache2.service

the database and backend must be running for MythWeb to work. At this point you have not yet set up the database or the backend so you cannot try MythWeb. Once those things have been set up and are running, test MythWeb by navigating to http://servername/mythweb where servername is your master backend server on which mythweb is running. If running from a different system you may have to add servername plus its ip address to your /etc/hosts file.

For more advanced and detailed instructions on MythWeb see the file mythweb/INSTALL in the download from github.

Post-install tasks

After installing the software there are a number of steps that must be taken before you have a working environment. If you installed from a pre-built package these would be done automatically.

Creating the mythtv user

MythTV backend needs to run as its own user. This should be a system account. Create a user as follows:

sudo useradd --system mythtv

Users might want to add --groups cdrom,audio,video to the above.

MythTV Database Setup

MythTV Version prior to V34

Run these commands from the command line. The mysql daemon must be running.

sudo mysql -u root
create database mythconverg;
create user 'mythtv'@'%' identified by 'mythtv';
create user 'mythtv'@'localhost' identified by 'mythtv';
set password for 'mythtv'@'%' = password('mythtv');
set password for 'mythtv'@'localhost' = password('mythtv');
connect mythconverg;
grant all privileges on *.* to 'mythtv'@'%' with grant option;
grant all privileges on *.* to 'mythtv'@'localhost' with grant option;
flush privileges;
exit;

Run the following command to set up time zone tables:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Ignore warnings like "Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.".

Run mythtv-setup as user mythtv. This will automatically create your database or upgrade your previous mythconverg database schema to the latest version:

mythtv-setup

If config.xml has not been created, setup will prompt for database info. You can then continue with setting up your system in mythtv-setup.

If there are problems with the database, see the article Database Setup.

Before you can get the backend to start up and stay running, you have to configure at least one capture card correctly, plus one video source and connect these with an input. See Configuring_MythTV or, more up-to-date, Channel_Scanning. Note that if you had installed the Ubuntu pre-built package there would not be this restriction, the backend can run without any configuration being done.

Starting in MythTV V34, start mythbackend and use a browser to open http://backend:6544, where backend is the backend IP address or DNS name. You are prompted for your preferred database settings. The page will display the mysql or mariadb commands to run to set up the database. You can copy and paste them into a command prompt. The mysql daemon must be running to support these commands. They will be the same commands as shown in the prior to V34 section, with adjustments for your preferred database name and user, if it is different from the default.

Once you have run the commands, save the page with the Save button and click the Restart Backend button. This restarts the backend, and if the database setup was successful the rest of the tabs will be available on the page for continuing setup.

mythtv-setup is no longer needed for V34 and later. Setup is done though the web app at port 6544. The backend has been updated so that it does not require a database to start in setup mode and does not require capture cards to be set up in order to start.

Backend Startup

For MythTV to be able to schedule and make recordings, the backend must be running at the time of the scheduled recordings. Normally this means running the backend at all times while the server is running. It should be set up to be automatically started when the server starts. This is handled automatically for you in the pre-built packages, but if you are building it yourself you have to set up some mechanism. Possible ways of doing it are systemd, Upstart, init script, /etc/rc.local. Ubuntu packages run it from Upstart (but is likely to switch to systemd in 16.04), which has the ability to restart the process if it fails.

The simplest way will be by editing the rc.local. Use gksudo gedit to edit rc.local and add the following line:

/usr/local/bin/mythbackend -d --logpath /tmp/ --user mythtv

This is a very basic and simplistic approach, but will work. For a reliable system you need to use something more advanced like Upstart. If you install from the Ubuntu or MythBuntu package the Upstart setup is done for you. Also you should create a directory other than /tmp/ for your logs. /var/log/mythtv is the popular location. Note that whatever directory you create for logs must be writeable by the mythtv user as well as frontend users. The frontend user if your normal Linux login, which you will use for viewing MythTV.

You can get a list of options available with mythbackend by running mythbackend --help.

If the backend starts up before you have added any capture cards it will immediately shut down again. Proceed to Configuring MythTV and complete the configuration up to the point of setting up a capture card, a video source and an input connection, before trying to start it again.

Next Steps

At this point you need to perform the configuration steps. See the table of contents and proceed to Configuring_MythTV and then Configuring_Frontend. Until you have done that you will not be able to do anything useful with MythTV.