The following sections will take you through the installation of Mediadrop.
Now that your system is ready to accept all the applications you want to install, let's begin with the MySQL part:
debian@beaglebone:~$ install mysql-server mysql-client
Actually, sudo apt-get install
works behind the scenes. From this point onwards, we'll rely on aliases to ease our life from the command line. Refer to the Appendix to get all the details.
During this you'll be asked for the database's root password, then the remaining system files:
debian@beaglebone:~$ install libjpeg-dev zlib1g-dev libfreetype6-dev libmysqlclient-dev python-dev
Finally, the Python-related requirements that will help you in virtual environments can be installed using the following command:
debian@beaglebone:~$ install python-setuptools python-virtualenv
With system requirements in place, you can set up MediaDrop in just six installation steps. Before doing that, you need to define a database for it.
You need to create some credentials and assign a user to a new MediaDrop database. It requires you to type only a few commands. If this is something that you don't want to do, the script is available on the GitHub companion website at https://github.com/dlewin/BeagleboneBlack-Server-Book.
Just execute the following command:
./create_mediadropdb.sh
Instead, if you are like me and want to control your entire system, then open a MySQL console, and pay attention to the syntax of the following command (with the ;
):
debian@beaglebone:~$ mysql –u root –p
Then, fill in the password you have defined in the installation steps.
You will now have access to the MySQL console for all the database operations that MediaDrop requires. Now, perform the following steps:
create user 'debian'@'localhost'IDENTIFIED BY 'temppwd';
MediaDrop
database; pay attention to the use of capital letters:create database MediaDrop;
use MediaDrop;
debian
user:grant create,insert,update,select,delete on MediaDrop.* to debian@localhost; exit
Here's a screenshot that shows these operations along with the related MySQL feedback you should get:
MediaDrop has been programmed in Python, a simple but powerful language that we'll also use in Chapter 6, Illuminate Your Imagination with Your Own Projects. As plugins are also in Python, you are free to extend the platform as you wish.
Let's see how to define a dedicated environment for this purpose.
Virtual environments introduce a functionality provided with Python that I like to use: actually, with this functionality, you can resolve the problems of software versions and incompatibility. The principle is to use as many virtual spaces with different packages or executables as you want without any confusion that might create a broken system. Thanks to the isolation provided by this tool, you are guaranteed that it is kept as you want it to be and thus you always have a safe system.
If you want to know more about virtualenv, take a look at https://virtualenv.readthedocs.org/en/latest/. There is also a virtualenvwrapper that is intended to ease the creation and deletion of many virtual environments at https://virtualenvwrapper.readthedocs.org/en/latest/.
Currently, we are using the 0.10.3 version of MediaDrop, but nothing stops you from trying the next version in order to test any side effects on your architecture. Thus, instead of executing the current environment, you'll just have to start MediaDrop from the n+1 environment.
Virtual environment is presented just here, but you should create an environment each time you need different usages of an application or dependencies. It requires just less than a minute and can be done by performing the following steps:
venv
:debian@beaglebone:~$ virtualenv --distribute venv
debian@beaglebone:~$ source venv/bin/activate
That's all! You are in now. Cool, eh?
The command prompt is preceded by the virtual environment's name, so you can guess which environment is currently activated, which is shown in the screenshot that follows the code:
(venv)debian@beaglebone:~$
You can now install any package you want; it will only be accessible in the currently activated environment.
For installation, retrieve the last stable release from downloads:
(venv)debian@beaglebone:~$ mkdir MediaDrop (venv)debian@beaglebone:~$ cd MediaDrop (venv)debian@beaglebone:~/MediaDrop$ wget http://static.mediadrop.net/releases/MediaCore-0.10.3.tar.gz
You can find all the releases at http://static.mediadrop.net/releases/.
Then, perform the following steps:
(venv)debian@beaglebone:~/MediaDrop$ tar xvzf MediaCore-0.10.3.tar.gz
(venv)debian@beaglebone:~/MediaDrop$ cd MediaCore-0.10.3 (venv)debian@beaglebone:~/MediaDrop/MediaCore-0.10.3$ python setup.py develop
Finished processing dependencies for MediaCore==0.10.3 (venv)debian@beaglebone:~/MediaDrop/MediaCore-0.10.3$ cd .. (venv)debian@beaglebone:~/MediaDrop$
(venv)debian@beaglebone:~/MediaDrop$ paster make-config MediaCore production.ini
This will generate the production.ini
file, which the server will use as a configuration file. So, we can adapt by editing it.
What we want to do here is tell which database we created and the related credentials. So, edit the production.ini
file, with nano
(or vim
) in order to focus on the [app:main]
section, as we want to change the following line:
sqlalchemy.url = mysql://username:pass@localhost/dbname?charset=utf8&use_unicode=0
The settings are shown in the following screenshot:
At the same time, as port 8080 is already used, let's change this to an available port, something such as 8082. As you'll see later on, many servers use the 8080 port for their configuration settings, and obviously only one application will be able to use this port, which means that according to your configurations, you will have to decide which application will use the 8080 port.
Now, save and quit the editor. We are done with the configuration part.
We have completed all the configuration steps, and we are now going to deploy all the website data content.
To do this, copy the data
directory from the sources to be at the same level as your production.ini
file:
(venv)debian@beaglebone:~/MediaDrop$ cp -a MediaCore-0.10.3/data/.
Give it the write permissions for the debian
user; when some content is uploaded, it will be written here:
(venv)debian@beaglebone:~/MediaDrop$ chmod 666 data
It's now time to fill the MediaDrop
database we've created previously with some tables and required data. We just have to call a predefined command:
(venv)debian@beaglebone:~/MediaDrop$ paster setup-app deployment.ini