Commit | Line | Data |
---|---|---|
473a4431 CAW |
1 | .. MediaGoblin Documentation |
2 | ||
62a565e1 | 3 | Written in 2011, 2012, 2013, 2020 by MediaGoblin contributors |
473a4431 CAW |
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 | ||
abe74178 WKG |
14 | .. _deploying-chapter: |
15 | ||
4e893b6e | 16 | ===================== |
17 | Deploying MediaGoblin | |
18 | ===================== | |
00fdc7bd | 19 | |
464a5d7f | 20 | This deployment guide will take you step-by-step through |
62a565e1 | 21 | setting up your own instance of MediaGoblin. |
56d507b6 | 22 | |
62a565e1 BS |
23 | MediaGoblin most likely isn't yet available from your operating |
24 | system's package manage, however, a basic install isn't too complex in | |
e82857fa BS |
25 | and of itself. We recommend a setup that combines MediaGoblin, |
26 | virtualenv and Nginx on a .deb or .rpm-based GNU/Linux distribution. | |
44db13fa | 27 | |
62a565e1 BS |
28 | Experts may of course choose other deployment options, including |
29 | Apache. See our `Deployment wiki page | |
30 | <http://wiki.mediagoblin.org/Deployment>`_ for for more details. | |
31 | Please note that we are not able to provide support for these | |
32 | alternative deployment options. | |
e260065a | 33 | |
076bf0cf WKG |
34 | .. note:: |
35 | ||
36 | These tools are for site administrators wanting to deploy a fresh | |
44db13fa | 37 | install. If you want to join in as a contributor, see our |
076bf0cf | 38 | `Hacking HOWTO <http://wiki.mediagoblin.org/HackingHowto>`_ instead. |
e260065a | 39 | |
44db13fa JC |
40 | .. note:: |
41 | ||
42 | Throughout the documentation we use the ``sudo`` command to indicate that | |
43 | an instruction requires elevated user privileges to run. You can issue | |
44 | these commands as the ``root`` user if you prefer. | |
45 | ||
46 | If you need help configuring ``sudo``, see the | |
47 | `Debian wiki <https://wiki.debian.org/sudo/>`_ or the | |
48 | `Fedora Project wiki <https://fedoraproject.org/wiki/Configuring_Sudo/>`_. | |
49 | ||
4d8a3cd8 | 50 | |
4e893b6e | 51 | Prepare System |
52 | -------------- | |
e260065a | 53 | |
4e893b6e | 54 | Dependencies |
55 | ~~~~~~~~~~~~ | |
e260065a | 56 | |
4e893b6e | 57 | MediaGoblin has the following core dependencies: |
e260065a | 58 | |
62a565e1 | 59 | - Python 3.4+ (Python 2.7 is supported, but not recommended) |
100f6265 | 60 | - `python3-lxml <http://lxml.de/>`_ |
4e893b6e | 61 | - `git <http://git-scm.com/>`_ |
775ec9e8 | 62 | - `SQLite <http://www.sqlite.org/>`_/`PostgreSQL <http://www.postgresql.org/>`_ |
4e893b6e | 63 | - `Python Imaging Library <http://www.pythonware.com/products/pil/>`_ (PIL) |
64 | - `virtualenv <http://www.virtualenv.org/>`_ | |
62a565e1 | 65 | - `Node.js <https://nodejs.org>`_ |
e260065a | 66 | |
7e10cdde BS |
67 | These instructions have been tested on Debian 10, CentOS 8 and |
68 | Fedora 31. These instructions should approximately translate to recent | |
69 | Debian derivatives such as Ubuntu 18.04 and Trisquel 8, and to relatives of | |
70 | Fedora such as CentOS 8. | |
71 | ||
72 | Issue the following commands: | |
3a1fb089 BS |
73 | |
74 | .. code-block:: bash | |
e260065a | 75 | |
7e10cdde | 76 | # Debian 10 |
62a565e1 BS |
77 | sudo apt update |
78 | sudo apt install automake git nodejs npm python3-dev python3-gi \ | |
79 | python3-gst-1.0 python3-lxml python3-pil virtualenv | |
e260065a | 80 | |
7e10cdde BS |
81 | # Fedora 31 |
82 | sudo dnf install automake gcc git-core make nodejs npm python3-devel \ | |
62a565e1 | 83 | python3-lxml python3-pillow virtualenv |
4e893b6e | 84 | |
62a565e1 | 85 | .. note:: |
e260065a | 86 | |
62a565e1 BS |
87 | MediaGoblin now uses Python 3 by default. To use Python 2, you may |
88 | instead substitute from "python3" to "python" for most package | |
89 | names in the Debian instructions and this should cover dependency | |
7e10cdde | 90 | installation. Python 2 installation has not been tested on Fedora. |
e2212f94 | 91 | |
62a565e1 BS |
92 | For a production deployment, you'll also need Nginx as frontend web |
93 | server and RabbitMQ to store the media processing queue:: | |
2e1e9650 | 94 | |
7e10cdde | 95 | # Debian |
62a565e1 BS |
96 | sudo apt install nginx-light rabbitmq-server |
97 | ||
7e10cdde | 98 | # Fedora |
35494ed6 | 99 | sudo dnf install nginx rabbitmq-server |
775ec9e8 | 100 | |
7e10cdde BS |
101 | .. |
102 | .. note:: | |
775ec9e8 | 103 | |
7e10cdde BS |
104 | You might have to enable additional repositories under Fedora |
105 | because rabbitmq-server might be not included in official | |
106 | repositories. That looks like this for CentOS:: | |
62a565e1 | 107 | |
7e10cdde BS |
108 | sudo dnf config-manager --set-enabled centos-rabbitmq-38 |
109 | sudo dnf config-manager --set-enabled PowerTools | |
110 | sudo dnf install rabbitmq-server | |
111 | sudo systemctl enable rabbitmq-server.service | |
112 | # TODO: Celery repeatedly disconnects from RabbitMQ on CentOS 8. | |
775ec9e8 | 113 | |
7e10cdde BS |
114 | As an alternative, you can try installing redis-server and |
115 | configure it as celery broker. | |
62a565e1 BS |
116 | |
117 | Configure PostgreSQL | |
118 | ~~~~~~~~~~~~~~~~~~~~ | |
119 | ||
120 | .. note:: | |
7798f911 | 121 | |
62a565e1 BS |
122 | MediaGoblin currently supports PostgreSQL and SQLite. The default |
123 | is a local SQLite database. This will "just work" for small | |
124 | deployments. For medium to large deployments we recommend | |
125 | PostgreSQL. If you don't want/need PostgreSQL, skip this section. | |
7798f911 | 126 | |
464a5d7f | 127 | These are the packages needed for PostgreSQL:: |
775ec9e8 | 128 | |
7e10cdde | 129 | # Debian |
62a565e1 | 130 | sudo apt install postgresql python3-psycopg2 |
c3075e91 | 131 | |
7e10cdde | 132 | # Fedora |
62a565e1 | 133 | sudo dnf install postgresql postgresql-server python3-psycopg2 |
c3075e91 | 134 | |
7e10cdde | 135 | Fedora also requires that you initialize and start the |
9650aa39 | 136 | PostgreSQL database with a few commands. The following commands are |
a0392075 | 137 | not needed on a Debian-based platform, however:: |
c3075e91 | 138 | |
7e10cdde | 139 | # Feora |
44db13fa | 140 | sudo /usr/bin/postgresql-setup initdb |
a0392075 JC |
141 | sudo systemctl enable postgresql |
142 | sudo systemctl start postgresql | |
775ec9e8 JW |
143 | |
144 | The installation process will create a new *system* user named ``postgres``, | |
9650aa39 BS |
145 | which will have privileges sufficient to manage the database. We will create a |
146 | new database user with restricted privileges and a new database owned by our | |
775ec9e8 JW |
147 | restricted database user for our MediaGoblin instance. |
148 | ||
149 | In this example, the database user will be ``mediagoblin`` and the database | |
62a565e1 | 150 | name will be ``mediagoblin`` too. We'll first at the user:: |
775ec9e8 | 151 | |
62a565e1 | 152 | sudo --login --user=postgres createuser --no-createdb mediagoblin |
775ec9e8 | 153 | |
c3075e91 JC |
154 | Then we'll create the database where all of our MediaGoblin data will be stored:: |
155 | ||
62a565e1 | 156 | sudo --login --user=postgres createdb --encoding=UTF8 --owner=mediagoblin mediagoblin |
c3075e91 | 157 | |
775ec9e8 JW |
158 | .. caution:: Where is the password? |
159 | ||
160 | These steps enable you to authenticate to the database in a password-less | |
161 | manner via local UNIX authentication provided you run the MediaGoblin | |
162 | application as a user with the same name as the user you created in | |
163 | PostgreSQL. | |
164 | ||
165 | More on this in :ref:`Drop Privileges for MediaGoblin <drop-privileges-for-mediagoblin>`. | |
166 | ||
167 | ||
775ec9e8 JW |
168 | .. _drop-privileges-for-mediagoblin: |
169 | ||
4e893b6e | 170 | Drop Privileges for MediaGoblin |
171 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
17c71230 | 172 | |
fd5c35e5 | 173 | MediaGoblin does not require special permissions or elevated |
1b4a9f26 CAW |
174 | access to run. As such, the preferred way to run MediaGoblin is to |
175 | create a dedicated, unprivileged system user for the sole purpose of running | |
6ec0393d | 176 | MediaGoblin. Running MediaGoblin processes under an unprivileged system user |
fd5c35e5 JC |
177 | helps to keep it more secure. |
178 | ||
62a565e1 BS |
179 | The following command will create a system account with a username of |
180 | ``mediagoblin``. | |
fd5c35e5 | 181 | |
4c89287c | 182 | If you are using a Debian-based system, enter this command:: |
fd5c35e5 | 183 | |
7e10cdde BS |
184 | # Debian |
185 | sudo useradd --system --create-home --home-dir /var/lib/qmediagoblin \ | |
464a5d7f | 186 | --group www-data --comment 'GNU MediaGoblin system account' mediagoblin |
4c89287c | 187 | |
7e10cdde | 188 | # Fedora |
464a5d7f BS |
189 | sudo useradd --system --create-home --home-dir /var/lib/mediagoblin \ |
190 | --group nginx --comment 'GNU MediaGoblin system account' mediagoblin | |
4c89287c JC |
191 | |
192 | This will create a ``mediagoblin`` user and assign it to a group that is | |
193 | associated with the web server. This will ensure that the web server can | |
62a565e1 | 194 | read the media files that users upload (images, videos, etc.) |
4c89287c | 195 | |
62a565e1 BS |
196 | Many operating systems will automatically create a group |
197 | ``mediagoblin`` to go with the new user ``mediagoblin``, but just to | |
198 | be sure:: | |
4c89287c | 199 | |
62a565e1 BS |
200 | sudo groupadd --force mediagoblin |
201 | sudo usermod --append --groups mediagoblin mediagoblin | |
4c89287c | 202 | |
fd5c35e5 | 203 | No password will be assigned to this account, and you will not be able |
9a1ba0e8 | 204 | to log in as this user. To switch to this account, enter:: |
fd5c35e5 | 205 | |
62a565e1 | 206 | sudo su mediagoblin --shell=/bin/bash |
fd5c35e5 | 207 | |
ef2642f7 | 208 | To return to your regular user account after using the system account, type |
62a565e1 | 209 | ``exit`` or ``Ctrl-d``. |
fd5c35e5 | 210 | |
fd5c35e5 JC |
211 | .. _create-mediagoblin-directory: |
212 | ||
213 | Create a MediaGoblin Directory | |
214 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
17c71230 | 215 | |
4e893b6e | 216 | You should create a working directory for MediaGoblin. This document |
076bf0cf | 217 | assumes your local git repository will be located at |
fd5c35e5 | 218 | ``/srv/mediagoblin.example.org/mediagoblin/``. |
9650aa39 | 219 | Substitute your preferred local deployment path as needed. |
fd5c35e5 JC |
220 | |
221 | Setting up the working directory requires that we first create the directory | |
9650aa39 | 222 | with elevated privileges, and then assign ownership of the directory |
6ec0393d | 223 | to the unprivileged system account. |
17c71230 | 224 | |
62a565e1 BS |
225 | To do this, enter the following commands, changing the defaults to suit your |
226 | particular requirements:: | |
fd5c35e5 | 227 | |
7e10cdde | 228 | # Debian |
62a565e1 BS |
229 | sudo mkdir --parents /srv/mediagoblin.example.org |
230 | sudo chown --no-dereference --recursive mediagoblin:www-data /srv/mediagoblin.example.org | |
fd5c35e5 | 231 | |
7e10cdde | 232 | # Fedora |
62a565e1 BS |
233 | sudo mkdir --parents /srv/mediagoblin.example.org |
234 | sudo chown --no-dereference --recursive mediagoblin:nginx /srv/mediagoblin.example.org | |
17c71230 | 235 | |
4e893b6e | 236 | |
e260065a | 237 | Install MediaGoblin and Virtualenv |
4e893b6e | 238 | ---------------------------------- |
e260065a | 239 | |
44db13fa JC |
240 | We will now switch to our 'mediagoblin' system account, and then set up |
241 | our MediaGoblin source code repository and its necessary services. | |
242 | You should modify these commands to suit your own environment. | |
17c71230 | 243 | |
62a565e1 BS |
244 | Switch to the ``mediagoblin`` unprivileged user and change to the |
245 | MediaGoblin directory that you just created:: | |
fd5c35e5 | 246 | |
62a565e1 | 247 | sudo su mediagoblin --shell=/bin/bash |
9a1ba0e8 | 248 | $ cd /srv/mediagoblin.example.org |
17c71230 | 249 | |
62a565e1 BS |
250 | .. note:: |
251 | ||
252 | Unless otherwise noted, the remainder of this document assumes that all | |
253 | operations are performed using the unprivileged ``mediagoblin`` | |
254 | account, indicated by the ``$`` prefix. | |
255 | ||
d3b1fd2e | 256 | Clone the MediaGoblin repository and set up the git submodules:: |
e260065a | 257 | |
7e10cdde BS |
258 | $ git clone --depth=1 https://git.savannah.gnu.org/git/mediagoblin.git \ |
259 | --branch stable --recursive | |
9a1ba0e8 | 260 | $ cd mediagoblin |
e260065a | 261 | |
62a565e1 | 262 | Set up the environment:: |
9fa1e602 | 263 | |
7e10cdde BS |
264 | $ ./bootstrap.sh |
265 | $ VIRTUALENV_FLAGS='--system-site-packages' ./configure | |
266 | $ make | |
e260065a | 267 | |
62a565e1 | 268 | .. note:: |
f0e137ab | 269 | |
62a565e1 BS |
270 | If you'd prefer to run MediaGoblin with Python 2, pass in |
271 | ``--without-python3`` to the ``./configure`` command. | |
e2212f94 | 272 | |
b791ae97 JC |
273 | Create and set the proper permissions on the ``user_dev`` directory. |
274 | This directory will be used to store uploaded media files:: | |
275 | ||
7e10cdde | 276 | $ mkdir --mode=2750 user_dev |
b791ae97 | 277 | |
7981fdaf BS |
278 | This concludes the initial configuration of the MediaGoblin |
279 | environment. In the future, you can upgrade MediaGoblin according to | |
280 | the ":doc:`upgrading`" documentation. | |
9d5cd0b9 CAW |
281 | |
282 | ||
e82857fa BS |
283 | Configure Mediagoblin |
284 | --------------------- | |
e260065a | 285 | |
a7d2a892 ST |
286 | Edit site configuration |
287 | ~~~~~~~~~~~~~~~~~~~~~~~ | |
288 | ||
62a565e1 BS |
289 | Edit ``mediagoblin.ini`` and update ``email_sender_address`` to the |
290 | address you wish to be used as the sender for system-generated emails. | |
e82857fa | 291 | You'll find more details in ":doc:`configuration`". |
a7d2a892 | 292 | |
62a565e1 | 293 | .. note:: |
a7d2a892 | 294 | |
62a565e1 BS |
295 | If you're changing the MediaGoblin directories or URL prefix, you |
296 | may need to edit ``direct_remote_path``, ``base_dir``, and | |
297 | ``base_url``. | |
94c10f1c | 298 | |
a7d2a892 ST |
299 | |
300 | ||
775ec9e8 JW |
301 | Configure MediaGoblin to use the PostgreSQL database |
302 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
303 | ||
9650aa39 | 304 | If you are using PostgreSQL, edit the ``[mediagoblin]`` section in your |
464a5d7f | 305 | ``mediagoblin.ini`` and remove the ``#`` prefix on the line containing:: |
775ec9e8 JW |
306 | |
307 | sql_engine = postgresql:///mediagoblin | |
308 | ||
62a565e1 BS |
309 | This assumes you are running the MediaGoblin application under the |
310 | same system account and database account; both ``mediagoblin``. | |
775ec9e8 | 311 | |
7798f911 | 312 | |
775ec9e8 JW |
313 | Update database data structures |
314 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
315 | ||
7798f911 | 316 | Before you start using the database, you need to run:: |
775ec9e8 | 317 | |
44db13fa | 318 | $ ./bin/gmg dbupdate |
775ec9e8 JW |
319 | |
320 | to populate the database with the MediaGoblin data structures. | |
321 | ||
322 | ||
62a565e1 BS |
323 | Create an admin account |
324 | ~~~~~~~~~~~~~~~~~~~~~~~ | |
325 | ||
326 | Create a MediaGoblin account with full administration access. Provide | |
327 | your own email address and enter a secure password when prompted:: | |
328 | ||
329 | $ ./bin/gmg adduser --username you --email you@example.com | |
330 | $ ./bin/gmg makeadmin you | |
331 | ||
332 | ||
4e893b6e | 333 | Test the Server |
334 | ~~~~~~~~~~~~~~~ | |
e260065a | 335 | |
4e893b6e | 336 | At this point MediaGoblin should be properly installed. You can |
076bf0cf | 337 | test the deployment with the following command:: |
e260065a | 338 | |
44db13fa | 339 | $ ./lazyserver.sh --server-name=broadcast |
e260065a | 340 | |
4e893b6e | 341 | You should be able to connect to the machine on port 6543 in your |
62a565e1 BS |
342 | browser to confirm that the service is operable. You should also be |
343 | able to log in with the admin username and password. | |
e260065a | 344 | |
62a565e1 | 345 | Type ``Ctrl-c`` to exit the above server test. |
3948e44c | 346 | |
62a565e1 BS |
347 | The next series of commands will need to be run as a privileged user. |
348 | To return to your regular user account after using the system account, | |
349 | type ``exit`` or ``Ctrl-d``. | |
3948e44c | 350 | |
cd1abb11 | 351 | |
e82857fa BS |
352 | Deploy MediaGoblin |
353 | ------------------ | |
354 | ||
355 | The configuration described below is sufficient for development and | |
356 | smaller deployments. However, for larger production deployments with | |
357 | larger processing requirements, see the | |
358 | ":doc:`production-deployments`" documentation. | |
359 | ||
360 | .. _webserver-config: | |
56d507b6 | 361 | |
e82857fa BS |
362 | Nginx as a reverse-proxy |
363 | ~~~~~~~~~~~~~~~~~~~~~~~~ | |
a7d2a892 | 364 | |
62a565e1 BS |
365 | This configuration example will use Nginx, however, you may use any |
366 | webserver of your choice. If you do not already have a web server, | |
367 | consider Nginx, as the configuration files may be more clear than the | |
368 | alternatives. | |
4e893b6e | 369 | |
370 | Create a configuration file at | |
371 | ``/srv/mediagoblin.example.org/nginx.conf`` and create a symbolic link | |
372 | into a directory that will be included in your ``nginx`` configuration | |
62a565e1 BS |
373 | (e.g. "``/etc/nginx/sites-enabled`` or ``/etc/nginx/conf.d``) with the |
374 | following commands:: | |
cd7af789 | 375 | |
7e10cdde | 376 | # Debian |
62a565e1 BS |
377 | sudo ln --symbolic /srv/mediagoblin.example.org/nginx.conf /etc/nginx/sites-enabled/mediagoblin.conf |
378 | sudo rm --force /etc/nginx/sites-enabled/default | |
cd7af789 JC |
379 | sudo systemctl enable nginx |
380 | ||
7e10cdde | 381 | # Fedora |
62a565e1 | 382 | sudo ln -s /srv/mediagoblin.example.org/nginx.conf /etc/nginx/conf.d/mediagoblin.conf |
cd7af789 JC |
383 | sudo systemctl enable nginx |
384 | ||
62a565e1 BS |
385 | You can modify these commands and locations depending on your |
386 | preferences and the existing configuration of your Nginx instance. The | |
387 | contents of this ``/srv/mediagoblin.example.org/nginx.conf`` file | |
388 | should be modeled on the following:: | |
076bf0cf WKG |
389 | |
390 | server { | |
391 | ################################################# | |
392 | # Stock useful config options, but ignore them :) | |
393 | ################################################# | |
394 | include /etc/nginx/mime.types; | |
395 | ||
396 | autoindex off; | |
397 | default_type application/octet-stream; | |
398 | sendfile on; | |
399 | ||
400 | # Gzip | |
401 | gzip on; | |
402 | gzip_min_length 1024; | |
403 | gzip_buffers 4 32k; | |
cd7af789 | 404 | gzip_types text/plain application/x-javascript text/javascript text/xml text/css; |
076bf0cf WKG |
405 | |
406 | ##################################### | |
407 | # Mounting MediaGoblin stuff | |
408 | # This is the section you should read | |
409 | ##################################### | |
410 | ||
5224d700 BS |
411 | # Change this to allow your users to upload larger files. If |
412 | # you enable audio or video you will need to increase this. This | |
413 | # is essentially a security setting to prevent *extremely* large | |
414 | # files being uploaded. Example settings include 500m and 1g. | |
415 | client_max_body_size 100m; | |
076bf0cf | 416 | |
a49c741f CAW |
417 | # prevent attacks (someone uploading a .txt file that the browser |
418 | # interprets as an HTML file, etc.) | |
419 | add_header X-Content-Type-Options nosniff; | |
37b48053 | 420 | |
076bf0cf WKG |
421 | server_name mediagoblin.example.org www.mediagoblin.example.org; |
422 | access_log /var/log/nginx/mediagoblin.example.access.log; | |
423 | error_log /var/log/nginx/mediagoblin.example.error.log; | |
424 | ||
425 | # MediaGoblin's stock static files: CSS, JS, etc. | |
426 | location /mgoblin_static/ { | |
427 | alias /srv/mediagoblin.example.org/mediagoblin/mediagoblin/static/; | |
428 | } | |
429 | ||
430 | # Instance specific media: | |
431 | location /mgoblin_media/ { | |
432 | alias /srv/mediagoblin.example.org/mediagoblin/user_dev/media/public/; | |
433 | } | |
434 | ||
8d051cc0 CAW |
435 | # Theme static files (usually symlinked in) |
436 | location /theme_static/ { | |
437 | alias /srv/mediagoblin.example.org/mediagoblin/user_dev/theme_static/; | |
438 | } | |
439 | ||
24ede044 CAW |
440 | # Plugin static files (usually symlinked in) |
441 | location /plugin_static/ { | |
442 | alias /srv/mediagoblin.example.org/mediagoblin/user_dev/plugin_static/; | |
443 | } | |
444 | ||
82c2f9a9 | 445 | # Forward requests to the MediaGoblin app server. |
076bf0cf | 446 | location / { |
82c2f9a9 | 447 | proxy_pass http://127.0.0.1:6543; |
4e893b6e | 448 | } |
076bf0cf | 449 | } |
4e893b6e | 450 | |
f44bd7dc CAW |
451 | The first four ``location`` directives instruct Nginx to serve the |
452 | static and uploaded files directly rather than through the MediaGoblin | |
453 | process. This approach is faster and requires less memory. | |
454 | ||
455 | .. note:: | |
456 | ||
cd7af789 | 457 | The user who owns the Nginx process, normally ``www-data`` or ``nginx``, |
f44bd7dc CAW |
458 | requires execute permission on the directories ``static``, |
459 | ``public``, ``theme_static`` and ``plugin_static`` plus all their | |
460 | parent directories. This user also requires read permission on all | |
461 | the files within these directories. This is normally the default. | |
462 | ||
cd7af789 JC |
463 | Nginx is now configured to serve the MediaGoblin application. Perform a quick |
464 | test to ensure that this configuration works:: | |
465 | ||
62a565e1 | 466 | sudo nginx -t |
cd7af789 | 467 | |
9650aa39 BS |
468 | If you encounter any errors, review your Nginx configuration files, and try to |
469 | resolve them. If you do not encounter any errors, you can start your Nginx | |
62a565e1 | 470 | server (may vary depending on your operating system):: |
4e893b6e | 471 | |
44db13fa | 472 | sudo systemctl restart nginx |
4e893b6e | 473 | |
62a565e1 | 474 | Now start MediaGoblin to test your Nginx configuration:: |
4e893b6e | 475 | |
62a565e1 BS |
476 | sudo su mediagoblin --shell=/bin/bash |
477 | $ cd /srv/mediagoblin.example.org/mediagoblin/ | |
478 | $ ./lazyserver.sh --server-name=main | |
4e893b6e | 479 | |
62a565e1 BS |
480 | You should be able to connect to the machine on port 80 in your |
481 | browser to confirm that the service is operable. If this is the | |
482 | machine in front of you, visit <http://localhost/> or if it is a | |
483 | remote server visit the URL or IP address provided to you by your | |
484 | hosting provider. You should see MediaGoblin; this time via Nginx! | |
4e893b6e | 485 | |
06d8fc89 BS |
486 | Try logging in and uploading an image. If after uploading you see any |
487 | "Forbidden" errors from Nginx or your image doesn't show up, you may | |
488 | need to update the permissions on the new directories MediaGoblin has | |
489 | created:: | |
490 | ||
7e10cdde | 491 | # Debian |
06d8fc89 BS |
492 | sudo chown --no-dereference --recursive mediagoblin:www-data /srv/mediagoblin.example.org |
493 | ||
7e10cdde | 494 | # Fedora |
06d8fc89 BS |
495 | sudo chown --no-dereference --recursive mediagoblin:nginx /srv/mediagoblin.example.org |
496 | ||
4e893b6e | 497 | .. note:: |
a7d2a892 | 498 | |
62a565e1 BS |
499 | If you see an Nginx placeholder page, you may need to remove the |
500 | Nginx default configuration, or explictly set a ``server_name`` | |
501 | directive in the Nginx config. | |
a7d2a892 | 502 | |
62a565e1 BS |
503 | Type ``Ctrl-c`` to exit the above server test and ``exit`` or |
504 | ``Ctrl-d`` to exit the mediagoblin shell. | |
a7d2a892 | 505 | |
b835e153 | 506 | |
62a565e1 | 507 | .. _systemd-service-files: |
3f088a3f | 508 | |
62a565e1 BS |
509 | Run MediaGoblin as a system service |
510 | ----------------------------------- | |
3f088a3f | 511 | |
62a565e1 BS |
512 | To ensure MediaGoblin is automatically started and restarted in case of |
513 | problems, we need to run it as a system service. If your operating system uses | |
514 | Systemd, you can use Systemd ``service files`` to manage both the Celery and | |
515 | Paste processes. | |
3f088a3f | 516 | |
e82857fa BS |
517 | In the Systemd configuration below, MediaGoblin log files are kept in |
518 | the ``/var/log/mediagoblin`` directory. Create the directory and give | |
519 | it the proper permissions:: | |
520 | ||
521 | sudo mkdir --parents /var/log/mediagoblin | |
522 | sudo chown --no-dereference --recursive mediagoblin:mediagoblin /var/log/mediagoblin | |
523 | ||
62a565e1 BS |
524 | Place the following service files in the ``/etc/systemd/system/`` |
525 | directory. The first file should be named | |
526 | ``mediagoblin-celeryd.service``. Be sure to modify it to suit your | |
527 | environment's setup: | |
528 | ||
529 | .. code-block:: bash | |
530 | ||
531 | # Set the WorkingDirectory and Environment values to match your environment. | |
532 | [Unit] | |
533 | Description=MediaGoblin Celeryd | |
243354b6 | 534 | After=rabbitmq-server.service |
62a565e1 BS |
535 | |
536 | [Service] | |
537 | User=mediagoblin | |
538 | Group=mediagoblin | |
539 | Type=simple | |
540 | WorkingDirectory=/srv/mediagoblin.example.org/mediagoblin | |
541 | Environment=MEDIAGOBLIN_CONFIG=/srv/mediagoblin.example.org/mediagoblin/mediagoblin.ini \ | |
542 | CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery | |
543 | ExecStart=/srv/mediagoblin.example.org/mediagoblin/bin/celery worker \ | |
544 | --logfile=/var/log/mediagoblin/celery.log \ | |
545 | --loglevel=INFO | |
546 | ||
547 | [Install] | |
548 | WantedBy=multi-user.target | |
549 | ||
550 | ||
551 | The second file should be named ``mediagoblin-paster.service``: | |
552 | ||
553 | .. code-block:: bash | |
554 | ||
555 | # Set the WorkingDirectory and Environment values to match your environment. | |
556 | [Unit] | |
557 | Description=Mediagoblin | |
558 | ||
559 | [Service] | |
560 | Type=simple | |
561 | User=mediagoblin | |
562 | Group=mediagoblin | |
563 | Environment=CELERY_ALWAYS_EAGER=false | |
564 | WorkingDirectory=/srv/mediagoblin.example.org/mediagoblin | |
565 | ExecStart=/srv/mediagoblin.example.org/mediagoblin/bin/paster serve \ | |
566 | /srv/mediagoblin.example.org/mediagoblin/paste.ini \ | |
567 | --log-file=/var/log/mediagoblin/mediagoblin.log \ | |
568 | --server-name=main | |
569 | ||
570 | [Install] | |
571 | WantedBy=multi-user.target | |
572 | ||
573 | ||
574 | Enable these processes to start at boot by entering:: | |
b835e153 | 575 | |
62a565e1 BS |
576 | sudo systemctl enable mediagoblin-celeryd.service && sudo systemctl enable mediagoblin-paster.service |
577 | ||
578 | ||
579 | Start the processes for the current session with:: | |
580 | ||
581 | sudo systemctl start mediagoblin-celeryd.service | |
582 | sudo systemctl start mediagoblin-paster.service | |
583 | ||
584 | ||
585 | If either command above gives you an error, you can investigate the cause of | |
586 | the error by entering either of:: | |
587 | ||
588 | sudo systemctl status mediagoblin-celeryd.service | |
589 | sudo systemctl status mediagoblin-paster.service | |
590 | ||
591 | The above ``systemctl status`` command is also useful if you ever want to | |
592 | confirm that a process is still running. If you make any changes to the service | |
593 | files, you can reload the service files by entering:: | |
594 | ||
595 | sudo systemctl daemon-reload | |
596 | ||
597 | After entering that command, you can attempt to start the Celery or Paste | |
598 | processes again using ``restart`` instead of ``start``. | |
599 | ||
600 | Assuming the above was successful, you should now have a MediaGoblin | |
601 | server that will continue to operate, even after being restarted. | |
602 | Great job! | |
603 | ||
62a565e1 | 604 | |
e82857fa BS |
605 | What next? |
606 | ---------- | |
b835e153 | 607 | |
e82857fa BS |
608 | This configuration supports upload of images only, but MediaGoblin |
609 | also supports other types of media, such as audio, video, PDFs and 3D | |
610 | models. For details, see the ":doc:`media-types`" documentation. | |
fd5c35e5 | 611 | |
f44bd7dc CAW |
612 | .. |
613 | Local variables: | |
614 | fill-column: 70 | |
615 | End: |