Deployment: Difference between revisions

From GNU MediaGoblin Wiki
Jump to navigation Jump to search
(→‎MongoDB setup: smallfiles)
(added apache config sample using fcgi)
Line 1: Line 1:
This page could use a lot of work. For now, a few smaller deployment tips!
This page could use a lot of work. For now, a few smaller deployment tips!

See also: http://docs.mediagoblin.org/deploying.html (some of which may belong here)


= Use Virtualenv =
= Use Virtualenv =
Line 19: Line 21:


./lazyserver.sh is all good and well for debugging, but probably not for deployments. Instead, you should probably run
./lazyserver.sh is all good and well for debugging, but probably not for deployments. Instead, you should probably run

= Apache Config Example =
This configuration example uses mod_fastcgi.

To install and enable mod_fastcgi on a Debian/Ubuntu based system:
<pre># apt-get install libapache2-mod-suexec libapache2-mod-fastcgi
# a2enmod suexec
# a2enmod fastcgi</pre>

Sample configuration:
<pre>
<VirtualHost *:80>
ServerName mediagoblin.yourdomain.tld
ServerAdmin webmaster@yourdoimain.tld
DocumentRoot /var/www/
# Custom log files
CustomLog /var/log/apache2/mediagobling_access.log combined
ErrorLog /var/log/apache2/mediagoblin_error.log

# Serve static and media files via alias
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/

# Rewrite all URLs to fcgi, except for static and media urls
RewriteEngine On
RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]

# Allow access to static and media directories
<Directory /path/to/mediagoblin/mediagoblin/static>
Order allow,deny
Allow from all
</Directory>
<Directory /path/to/mediagoblin/mediagoblin/user_dev/media/public>
Order allow,deny
Allow from all
</Directory>

# Connect to fcgi server
FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543
</VirtualHost>
</pre>
Then, you need to make sure mediagoblin is running in fcgi mode:
<pre>cd /path/to/mediagoblin
./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543</pre>

Note: there may be several ways to improve this configuration

Revision as of 21:16, 2 December 2011

This page could use a lot of work. For now, a few smaller deployment tips!

See also: http://docs.mediagoblin.org/deploying.html (some of which may belong here)

Use Virtualenv

Our Development quick start guide recommends using zc.buildout, but this system is somewhat problematic for actual deployments (if a buildout goes badly, buildout removes all your packaging setup and your scripts in bin/ and other things... yuck :\). Use Virtualenv instead. In the future, all our docs will bet set up to recommend using Virtualenv.

MongoDB setup

You should almost certainly run MongoDB with Journaling on if you have a new enough version of MongoDB. (If you don't, maybe you should get a newer version!) Without journaling there's some risk you could lose data that isn't yet written to disk if MongoDB is shut down incorrectly. But read about disk space below.

Also, keep in mind the following assumptions MongoDB makes about your deployment environment

Running MediaGoblin's web server and Celery separately

./lazyserver.sh is all good and well for debugging, but probably not for deployments. Instead, you should probably run

Apache Config Example

This configuration example uses mod_fastcgi.

To install and enable mod_fastcgi on a Debian/Ubuntu based system:

# apt-get install libapache2-mod-suexec libapache2-mod-fastcgi
# a2enmod suexec
# a2enmod fastcgi

Sample configuration:

<VirtualHost *:80>
ServerName mediagoblin.yourdomain.tld
ServerAdmin webmaster@yourdoimain.tld
DocumentRoot /var/www/
# Custom log files
CustomLog /var/log/apache2/mediagobling_access.log combined
ErrorLog /var/log/apache2/mediagoblin_error.log

# Serve static and media files via alias
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/

# Rewrite all URLs to fcgi, except for static and media urls
RewriteEngine On
RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]

# Allow access to static and media directories
<Directory /path/to/mediagoblin/mediagoblin/static>
  Order allow,deny
  Allow from all
</Directory>
<Directory /path/to/mediagoblin/mediagoblin/user_dev/media/public>
  Order allow,deny
  Allow from all
</Directory>

# Connect to fcgi server
FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543
</VirtualHost>

Then, you need to make sure mediagoblin is running in fcgi mode:

cd /path/to/mediagoblin
./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543

Note: there may be several ways to improve this configuration