Commit | Line | Data |
---|---|---|
473a4431 CAW |
1 | .. MediaGoblin Documentation |
2 | ||
3 | Written in 2011, 2012 by MediaGoblin contributors | |
4 | ||
5 | To the extent possible under law, the author(s) have dedicated all | |
6 | copyright and related and neighboring rights to this software to | |
7 | the public domain worldwide. This software is distributed without | |
8 | any warranty. | |
9 | ||
10 | You should have received a copy of the CC0 Public Domain | |
11 | Dedication along with this software. If not, see | |
12 | <http://creativecommons.org/publicdomain/zero/1.0/>. | |
13 | ||
4e893b6e | 14 | ===================== |
15 | Deploying MediaGoblin | |
16 | ===================== | |
00fdc7bd | 17 | |
e260065a CAW |
18 | GNU MediaGoblin is fairly new and so at the time of writing, there |
19 | aren't easy package-manager-friendly methods to install MediaGoblin. | |
20 | However, doing a basic install isn't too complex in and of itself. | |
56d507b6 | 21 | |
e260065a CAW |
22 | There's an almost infinite way to deploy things... for now, we'll keep |
23 | it simple with some assumptions and use a setup that combines | |
24 | mediagoblin + virtualenv + fastcgi + nginx on a .deb or .rpm based | |
25 | GNU/Linux distro. | |
26 | ||
076bf0cf WKG |
27 | .. note:: |
28 | ||
29 | These tools are for site administrators wanting to deploy a fresh | |
30 | install. If instead you want to join in as a contributor, see our | |
31 | `Hacking HOWTO <http://wiki.mediagoblin.org/HackingHowto>`_ instead. | |
e260065a | 32 | |
4e893b6e | 33 | Prepare System |
34 | -------------- | |
e260065a | 35 | |
4e893b6e | 36 | Dependencies |
37 | ~~~~~~~~~~~~ | |
e260065a | 38 | |
4e893b6e | 39 | MediaGoblin has the following core dependencies: |
e260065a | 40 | |
4e893b6e | 41 | - Python 2.6 or 2.7 |
42 | - `python-lxml <http://lxml.de/>`_ | |
43 | - `git <http://git-scm.com/>`_ | |
775ec9e8 | 44 | - `SQLite <http://www.sqlite.org/>`_/`PostgreSQL <http://www.postgresql.org/>`_ |
4e893b6e | 45 | - `Python Imaging Library <http://www.pythonware.com/products/pil/>`_ (PIL) |
46 | - `virtualenv <http://www.virtualenv.org/>`_ | |
e260065a | 47 | |
4e893b6e | 48 | On a DEB-based system (e.g Debian, gNewSense, Trisquel, Ubuntu, and |
49 | derivatives) issue the following command: :: | |
e260065a | 50 | |
775ec9e8 | 51 | sudo apt-get install git-core python python-dev python-lxml \ |
076bf0cf | 52 | python-imaging python-virtualenv |
e260065a | 53 | |
4e893b6e | 54 | On a RPM-based system (e.g. Fedora, RedHat, and derivatives) issue the |
55 | following command: :: | |
56 | ||
775ec9e8 | 57 | yum install python-paste-deploy python-paste-script \ |
076bf0cf WKG |
58 | git-core python python-devel python-lxml python-imaging \ |
59 | python-virtualenv | |
e260065a | 60 | |
775ec9e8 JW |
61 | Configure PostgreSQL |
62 | ~~~~~~~~~~~~~~~~~~~~ | |
63 | ||
64 | .. note:: | |
65 | ||
66 | MediaGoblin currently supports PostgreSQL and SQLite. The default is a | |
67 | local SQLite database. This will "just work" for small deployments. If | |
68 | you don't want/need postgres, ignore all the postgres related parts. For | |
69 | medium to large deployments we recommend PostgreSQL. | |
70 | ||
71 | These are the packages needed for Debian Wheezy (testing): :: | |
72 | ||
73 | sudo apt-get install postgresql postgresql-client | |
74 | ||
75 | The installation process will create a new *system* user named ``postgres``, | |
76 | it will have privilegies sufficient to manage the database. We will create a | |
77 | new database user with restricted privilegies and a new database owned by our | |
78 | restricted database user for our MediaGoblin instance. | |
79 | ||
80 | In this example, the database user will be ``mediagoblin`` and the database | |
81 | name will be ``mediagoblin`` too. | |
82 | ||
83 | To create our new user, run: :: | |
84 | ||
85 | sudo -u postgres createuser mediagoblin | |
86 | ||
87 | then answer NO to *all* the questions: :: | |
88 | ||
89 | Shall the new role be a superuser? (y/n) n | |
90 | Shall the new role be allowed to create databases? (y/n) n | |
91 | Shall the new role be allowed to create more new roles? (y/n) n | |
92 | ||
93 | then create the database all our MediaGoblin data should be stored in: :: | |
94 | ||
95 | sudo -u postgres createdb -E UNICODE -O mediagoblin mediagoblin | |
96 | ||
97 | where the first ``mediagoblin`` is the database owner and the second | |
98 | ``mediagoblin`` is the database name. | |
99 | ||
100 | .. caution:: Where is the password? | |
101 | ||
102 | These steps enable you to authenticate to the database in a password-less | |
103 | manner via local UNIX authentication provided you run the MediaGoblin | |
104 | application as a user with the same name as the user you created in | |
105 | PostgreSQL. | |
106 | ||
107 | More on this in :ref:`Drop Privileges for MediaGoblin <drop-privileges-for-mediagoblin>`. | |
108 | ||
109 | ||
e260065a | 110 | Configure MongoDB |
4e893b6e | 111 | ~~~~~~~~~~~~~~~~~ |
112 | ||
775ec9e8 JW |
113 | .. warning:: |
114 | ||
115 | If this is a fresh setup and you have already set up PostgreSQL, you | |
116 | will not need this step. | |
117 | ||
118 | First, install MongoDB. On a DEB-based system run: :: | |
119 | ||
120 | sudo apt-get install mongodb | |
121 | ||
122 | on a RPM-based system, run: :: | |
123 | ||
124 | yum install mongodb-server | |
125 | ||
4e893b6e | 126 | After installing MongoDB some preliminary database configuration may |
127 | be necessary. | |
128 | ||
076bf0cf WKG |
129 | Ensure that MongoDB `journaling |
130 | <http://www.mongodb.org/display/DOCS/Journaling>`_ is enabled. Journaling | |
131 | is enabled by default in version 2.0 and later 64-bit MongoDB instances. | |
132 | Check your deployment, and consider enabling journaling if you're running | |
133 | 32-bit systems or earlier version. | |
e260065a | 134 | |
4e893b6e | 135 | .. warning:: |
e260065a | 136 | |
4e893b6e | 137 | Running MongoDB without journaling risks general data corruption |
138 | and raises the possibility of losing data within a 60-second | |
139 | window when the server restarts. | |
e260065a | 140 | |
4e893b6e | 141 | MediaGoblin recommends enabling MongoDB's journaling feature by |
142 | adding a ``--journal`` flag to the command line or a "``journal: | |
143 | true``" option to the configuration file. | |
e260065a | 144 | |
4e893b6e | 145 | MongoDB can take a lot of space by default. If you're planning on |
146 | running a smaller instance, consider the `scaling down guide | |
147 | <http://wiki.mediagoblin.org/Scaling_Down>`_ for some appropriate | |
148 | tradeoffs to conserve space. | |
17c71230 | 149 | |
775ec9e8 JW |
150 | .. _drop-privileges-for-mediagoblin: |
151 | ||
4e893b6e | 152 | Drop Privileges for MediaGoblin |
153 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
17c71230 | 154 | |
4e893b6e | 155 | As MediaGoblin does not require special permissions or elevated |
156 | access, you should run MediaGoblin under an existing non-root user or | |
157 | preferably create a dedicated user for the purpose of running | |
158 | MediaGoblin. Consult your distribution's documentation on how to | |
159 | create "system account" or dedicated service user. Ensure that it is | |
160 | not possible to log in to your system with as this user. | |
17c71230 | 161 | |
4e893b6e | 162 | You should create a working directory for MediaGoblin. This document |
076bf0cf WKG |
163 | assumes your local git repository will be located at |
164 | ``/srv/mediagoblin.example.org/mediagoblin/`` for this documentation. | |
165 | Substitute your prefer ed local deployment path as needed. | |
17c71230 | 166 | |
4e893b6e | 167 | This document assumes that all operations are performed as this |
168 | user. To drop privileges to this user, run the following command: :: | |
17c71230 | 169 | |
076bf0cf | 170 | su - [mediagoblin] |
17c71230 | 171 | |
076bf0cf | 172 | Where, "``[mediagoblin]``" is the username of the system user that will |
4e893b6e | 173 | run MediaGoblin. |
174 | ||
e260065a | 175 | Install MediaGoblin and Virtualenv |
4e893b6e | 176 | ---------------------------------- |
e260065a | 177 | |
076bf0cf WKG |
178 | .. note:: |
179 | ||
180 | As of |version|, MediaGoblin has a rapid development pace. As a result | |
181 | the following instructions recommend installing from the ``master`` | |
182 | branch of the git repository. Eventually production deployments will | |
183 | want to transition to running from more consistent releases. | |
e260065a | 184 | |
4e893b6e | 185 | Issue the following commands, to create and change the working |
076bf0cf | 186 | directory. Modify these commands to reflect your own environment:: |
17c71230 | 187 | |
076bf0cf WKG |
188 | mkdir -p /srv/mediagoblin.example.org/ |
189 | cd /srv/mediagoblin.example.org/ | |
17c71230 | 190 | |
076bf0cf | 191 | Clone the MediaGoblin repository:: |
e260065a | 192 | |
076bf0cf | 193 | git clone git://gitorious.org/mediagoblin/mediagoblin.git |
e260065a | 194 | |
076bf0cf | 195 | And setup the in-package virtualenv:: |
e260065a | 196 | |
076bf0cf | 197 | cd mediagoblin |
95ff15d6 | 198 | (virtualenv --system-site-packages . || virtualenv .) && ./bin/python setup.py develop |
e260065a | 199 | |
4e893b6e | 200 | .. note:: |
e260065a | 201 | |
4e893b6e | 202 | If you have problems here, consider trying to install virtualenv |
203 | with the ``--distribute`` or ``--no-site-packages`` options. If | |
204 | your system's default Python is in the 3.x series you man need to | |
205 | run ``virtualenv`` with the ``--python=python2.7`` or | |
206 | ``--python=python2.6`` options. | |
e260065a | 207 | |
4e893b6e | 208 | The above provides an in-package install of ``virtualenv``. While this |
209 | is counter to the conventional ``virtualenv`` configuration, it is | |
210 | more reliable and considerably easier to configure and illustrate. If | |
211 | you're familiar with Python packaging you may consider deploying with | |
212 | your preferred the method. | |
e260065a | 213 | |
076bf0cf WKG |
214 | Assuming you are going to deploy with FastCGI, you should also install |
215 | flup:: | |
99192f24 | 216 | |
076bf0cf | 217 | ./bin/easy_install flup |
99192f24 | 218 | |
4e893b6e | 219 | This concludes the initial configuration of the development |
220 | environment. In the future, if at any point you want update your | |
076bf0cf | 221 | codebase, you should also run:: |
e260065a | 222 | |
076bf0cf | 223 | ./bin/python setup.py develop --upgrade && ./bin/gmg migrate. |
e260065a | 224 | |
4e893b6e | 225 | Deploy MediaGoblin Services |
226 | --------------------------- | |
e260065a | 227 | |
775ec9e8 JW |
228 | Configure MediaGoblin to use the PostgreSQL database |
229 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
230 | ||
231 | Edit the ``[mediagoblin]`` section in your ``mediagoblin_local.ini`` and | |
232 | put in: :: | |
233 | ||
234 | sql_engine = postgresql:///mediagoblin | |
235 | ||
236 | if you are running the MediaGoblin application as the same 'user' as the | |
237 | database owner. | |
238 | ||
239 | Update database data structures | |
240 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
241 | ||
242 | Before you start using the database, you need to run: :: | |
243 | ||
244 | ./bin/gmg dbupdate | |
245 | ||
246 | to populate the database with the MediaGoblin data structures. | |
247 | ||
248 | ||
4e893b6e | 249 | Test the Server |
250 | ~~~~~~~~~~~~~~~ | |
e260065a | 251 | |
4e893b6e | 252 | At this point MediaGoblin should be properly installed. You can |
076bf0cf | 253 | test the deployment with the following command:: |
e260065a | 254 | |
076bf0cf | 255 | ./lazyserver.sh --server-name=broadcast |
e260065a | 256 | |
4e893b6e | 257 | You should be able to connect to the machine on port 6543 in your |
258 | browser to confirm that the service is operable. | |
e260065a | 259 | |
4e893b6e | 260 | Connect the Webserver to MediaGoblin with FastCGI |
261 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
56d507b6 | 262 | |
94011579 | 263 | This section describes how to configure MediaGoblin to work via |
076bf0cf | 264 | FastCGI. Our configuration example will use nginx, however, you may |
4e893b6e | 265 | use any webserver of your choice as long as it supports the FastCGI |
266 | protocol. If you do not already have a web server, consider nginx, as | |
267 | the configuration files may be more clear than the | |
268 | alternatives. | |
269 | ||
270 | Create a configuration file at | |
271 | ``/srv/mediagoblin.example.org/nginx.conf`` and create a symbolic link | |
272 | into a directory that will be included in your ``nginx`` configuration | |
273 | (e.g. "``/etc/nginx/sites-enabled`` or ``/etc/nginx/conf.d``) with | |
076bf0cf | 274 | one of the following commands (as the root user):: |
4e893b6e | 275 | |
076bf0cf WKG |
276 | ln -s /srv/mediagoblin.example.org/nginx.conf /etc/nginx/conf.d/ |
277 | ln -s /srv/mediagoblin.example.org/nginx.conf /etc/nginx/sites-enabled/ | |
4e893b6e | 278 | |
279 | Modify these commands and locations depending on your preferences and | |
280 | the existing configuration of your nginx instance. The contents of | |
076bf0cf WKG |
281 | this ``nginx.conf`` file should be modeled on the following:: |
282 | ||
283 | server { | |
284 | ################################################# | |
285 | # Stock useful config options, but ignore them :) | |
286 | ################################################# | |
287 | include /etc/nginx/mime.types; | |
288 | ||
289 | autoindex off; | |
290 | default_type application/octet-stream; | |
291 | sendfile on; | |
292 | ||
293 | # Gzip | |
294 | gzip on; | |
295 | gzip_min_length 1024; | |
296 | gzip_buffers 4 32k; | |
297 | gzip_types text/plain text/html application/x-javascript text/javascript text/xml text/css; | |
298 | ||
299 | ##################################### | |
300 | # Mounting MediaGoblin stuff | |
301 | # This is the section you should read | |
302 | ##################################### | |
303 | ||
304 | # Change this to update the upload size limit for your users | |
305 | client_max_body_size 8m; | |
306 | ||
307 | server_name mediagoblin.example.org www.mediagoblin.example.org; | |
308 | access_log /var/log/nginx/mediagoblin.example.access.log; | |
309 | error_log /var/log/nginx/mediagoblin.example.error.log; | |
310 | ||
311 | # MediaGoblin's stock static files: CSS, JS, etc. | |
312 | location /mgoblin_static/ { | |
313 | alias /srv/mediagoblin.example.org/mediagoblin/mediagoblin/static/; | |
314 | } | |
315 | ||
316 | # Instance specific media: | |
317 | location /mgoblin_media/ { | |
318 | alias /srv/mediagoblin.example.org/mediagoblin/user_dev/media/public/; | |
319 | } | |
320 | ||
321 | # Mounting MediaGoblin itself via FastCGI. | |
322 | location / { | |
323 | fastcgi_pass 127.0.0.1:26543; | |
324 | include /etc/nginx/fastcgi_params; | |
325 | ||
326 | # our understanding vs nginx's handling of script_name vs | |
327 | # path_info don't match :) | |
328 | fastcgi_param PATH_INFO $fastcgi_script_name; | |
329 | fastcgi_param SCRIPT_NAME ""; | |
4e893b6e | 330 | } |
076bf0cf | 331 | } |
4e893b6e | 332 | |
333 | Now, nginx instance is configured to serve the MediaGoblin | |
334 | application. Perform a quick test to ensure that this configuration | |
335 | works. Restart nginx so it picks up your changes, with a command that | |
076bf0cf | 336 | resembles one of the following (as the root user):: |
4e893b6e | 337 | |
076bf0cf WKG |
338 | sudo /etc/init.d/nginx restart |
339 | sudo /etc/rc.d/nginx restart | |
4e893b6e | 340 | |
341 | Now start MediaGoblin. Use the following command sequence as an | |
076bf0cf | 342 | example:: |
4e893b6e | 343 | |
076bf0cf WKG |
344 | cd /srv/mediagoblin.example.org/mediagoblin/ |
345 | ./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543 | |
4e893b6e | 346 | |
347 | Visit the site you've set up in your browser by visiting | |
348 | <http://mediagobilin.example.org>. You should see MediaGoblin! | |
349 | ||
4e893b6e | 350 | .. note:: |
351 | ||
a085dda5 | 352 | The configuration described above is sufficient for development and |
353 | smaller deployments. However, for larger production deployments | |
354 | with larger processing requirements, see the | |
355 | ":doc:`production-deployments`" documentation. |