https://wiki.mediagoblin.org/api.php?action=feedcontributions&user=Jimbo&feedformat=atomGNU MediaGoblin Wiki - User contributions [en]2024-03-29T08:46:49ZUser contributionsMediaWiki 1.39.5https://wiki.mediagoblin.org/index.php?title=Deployment&diff=1029Deployment2012-12-14T20:43:04Z<p>Jimbo: </p>
<hr />
<div>This page could use a lot of work. For now, a few smaller deployment tips!<br />
<br />
See also: http://docs.mediagoblin.org/deploying.html (some of which may belong here)<br />
<br />
= FCGI script =<br />
<br />
This works great with the apache config example below :)<br />
<br />
<pre>#!/path/to/mediagoblin/bin/python<br />
<br />
# Written in 2011 by Christopher Allan Webber<br />
#<br />
# To the extent possible under law, the author(s) have dedicated all<br />
# copyright and related and neighboring rights to this software to the<br />
# public domain worldwide. This software is distributed without any<br />
# warranty.<br />
# <br />
# You should have received a copy of the CC0 Public Domain Dedication along<br />
# with this software. If not, see<br />
# <http://creativecommons.org/publicdomain/zero/1.0/>.<br />
<br />
from paste.deploy import loadapp<br />
from flup.server.fcgi import WSGIServer<br />
<br />
CONFIG_PATH = '/path/to/mediagoblin/paste.ini'<br />
<br />
## Uncomment this to run celery in "always eager" mode... ie, you don't have<br />
## to run a separate process, but submissions wait till processing finishes<br />
# import os<br />
# os.environ['CELERY_ALWAYS_EAGER'] = 'true'<br />
<br />
def launch_fcgi():<br />
ccengine_wsgi_app = loadapp('config:' + CONFIG_PATH)<br />
WSGIServer(ccengine_wsgi_app).run()<br />
<br />
<br />
if __name__ == '__main__':<br />
launch_fcgi()</pre><br />
<br />
= Apache 2 Config with fcgid =<br />
<br />
Note that the libapache2-mod-fcgi in Debian is in the nonfree section, and MediaGoblin users will want to avoid that. Instead, libapache2-mod-fcgid can be used, but requires a slightly different configuration.<br />
<br />
<VirtualHost *:80><br />
Options +ExecCGI<br />
<br />
# Accept up to 16MB requests<br />
FcgidMaxRequestLen 16777216<br />
<br />
ServerName mediagoblin.example.org<br />
<br />
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/<br />
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/<br />
<br />
ScriptAlias / /path/to/mediagoblin/mg.fcgi/<br />
</VirtualHost><br />
<br />
= Apache Config Example =<br />
This configuration example uses mod_fastcgi.<br />
<br />
To install and enable mod_fastcgi on a Debian/Ubuntu based system:<br />
<pre># apt-get install libapache2-mod-suexec libapache2-mod-fastcgi<br />
# a2enmod suexec<br />
# a2enmod fastcgi</pre><br />
<br />
Sample configuration:<br />
<pre><br />
<VirtualHost *:80><br />
ServerName mediagoblin.yourdomain.tld<br />
ServerAdmin webmaster@yourdoimain.tld<br />
DocumentRoot /var/www/<br />
# Custom log files<br />
CustomLog /var/log/apache2/mediagobling_access.log combined<br />
ErrorLog /var/log/apache2/mediagoblin_error.log<br />
<br />
# Serve static and media files via alias<br />
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/<br />
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/<br />
<br />
# Rewrite all URLs to fcgi, except for static and media urls<br />
RewriteEngine On<br />
RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]<br />
<br />
# Allow access to static and media directories<br />
<Directory /path/to/mediagoblin/mediagoblin/static><br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
<Directory /path/to/mediagoblin/mediagoblin/user_dev/media/public><br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
<br />
# Connect to fcgi server<br />
FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543<br />
</VirtualHost><br />
</pre><br />
Then, you need to make sure mediagoblin is running in fcgi mode:<br />
<pre>cd /path/to/mediagoblin<br />
./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543</pre><br />
<br />
Note: there may be several ways to improve this configuration<br />
<br />
= Juju =<br />
<br />
There is a juju [https://juju.ubuntu.com/Charms charm] available for deploying mediagoblin into EC2 or on your local box. [https://juju.ubuntu.com/ juju] is available in Ubuntu 11.10 and later, though it is recommended that you pull it from [https://launchpad.net/~juju/+archive/pkgs| the juju PPA], which includes backported packages going back to Ubuntu 11.10. To use the juju charm, install juju and configure either the [https://juju.ubuntu.com/docs/provider-configuration-local.html local provider] or one of the cloud API providers, currently the [https://juju.ubuntu.com/docs/provider-configuration-ec2.html EC2 provider] is the best supported and works not only with Amazon Web Services but also OpenStack clouds. There is also a newer native OpenStack API provider which is known to support HP Cloud.<br />
<pre><br />
# if you have not bootstrapped<br />
juju bootstrap<br />
mkdir ~/charms<br />
bzr init-repo ~/charms/precise<br />
bzr branch lp:~clint-fewbar/charms/precise/mediagoblin/trunk ~/charms/precise/mediagoblin<br />
juju deploy --repository ~/charms local:mediagoblin<br />
juju expose mediagoblin<br />
</pre><br />
<br />
Currently the charm is volatile, deploying from trunk, and deploys a single-server version of MediaGoblin only. It will eventually relate to the existing juju charms for other supported data stores to allow one to scale out their MediaGoblin instance.<br />
<br />
= Init scripts =<br />
<br />
== Debian init scripts ==<br />
<br />
Joar has some scripts for running celery and mediagoblin separately that are designed for Debian.<br />
<br />
https://github.com/joar/mediagoblin-init-scripts<br />
<br />
== Arch Linux init scripts ==<br />
<br />
[http://whird.jpope.org/2012/04/14/mediagoblin-archlinux-rcd-scripts Jeremy Pope has written a nice blogpost] on how to add init scripts to deploy MediaGoblin with both the python paste http server and the celery deployments separated.<br />
<br />
If you want a simpler setup and don't want to deploy celery separately, consider either turning CELERY_ALWAYS_EAGER to true in the paste init script described above, or check out [http://chimo.chromic.org/2012/03/01/mediagoblin-init-script-on-archlinux/ Chimo's guide].<br />
<br />
<br />
<br />
== Generic, simple init script ==<br />
<br />
This is a super stupidly simple init script that was used for mediagoblin.com... note that this has Celery running in always eager mode.<br />
<br />
You will need to adjust the paths appropriately. This could probably be better written!<br />
<br />
#! /bin/sh<br />
<br />
## Stupidly simple mediagoblin init script.<br />
# <br />
# Written in 2012 by Christopher Allan Webber<br />
#<br />
# To the extent possible under law, the author(s) have dedicated all<br />
# copyright and related and neighboring rights to this software to the<br />
# public domain worldwide. This software is distributed without any<br />
# warranty.<br />
# <br />
# You should have received a copy of the CC0 Public Domain Dedication along<br />
# with this software. If not, see<br />
# <http://creativecommons.org/publicdomain/zero/1.0/>.<br />
<br />
PASTER=/srv/mediagoblin.com/bin/paster<br />
PASTE_CONFIG=/srv/mediagoblin.com/paste.ini<br />
OPTIONS="--pid-file=/tmp/mediagoblin.pid \<br />
--log-file=/srv/mediagoblin.com/paster.log \<br />
--server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543"<br />
<br />
CELERY_ALWAYS_EAGER=true su -pc "$PASTER serve $PASTE_CONFIG $1 $OPTIONS" webadmin<br />
<br />
= Running on Dreamhost.com =<br />
<br />
===Set up your python virtualenv===<br />
<br />
dreamhost.com servers come with python 2.4 and 2.5 installed which is too old for mediagoblin. This means you need to compile and install a newer python (don't worry this is really not difficult on dreamhost servers). In order to be able to install python packages for a local user without touching system files, we need to setup a python ''virtualenv''. Fortunately, this is not too tricky either. If your server has python 2.6 or 2.7 installed already, you can skip the [[#Install a local python|python installation stuff]] and you'll only need to [[#Setup virtualenv to install local python packages|install virtualenv]].<br />
<br />
====Install a local python====<br />
# Download the latest python: http://python.org/ftp/python/XXX/Python-XXX.tar.bz2<br />
# Unpack with <pre>tar xvjf Python-XXX.tar.bz2</pre><br />
# ''cd'' into the directory and compile and install python locally:<br />
<blockquote><pre>./configure --prefix=$HOME/local<br />
make<br />
make install</pre></blockquote><br />
:This will install python (I used 2.7.3) into /home/<USERNAME>/local/bin/python. You might get warnings about some modules not being able to compile. :It was tcl/tk and bzip2 mainly, but things still worked out overall.<br />
:<br />
:You should now be able to invoke <tt>~/local/bin/python</tt> and fall into a shell of your new python (exit with ctrl-d). Congrats, you have now a new python 2.7 that you can use. However, you will need to be able to install additional packages as a user and this is what virtualenv allows.<br />
<br />
====Setup virtualenv to install local python packages====<br />
# Download the latest virtualenv: http://pypi.python.org/packages/source/v/virtualenv/XXX<br />
# Install the virtualenv: <blockquote><pre>~/local/bin/python ~/virtualenv-1.8/virtualenv.py $HOME/local/virtenv</pre></blockquote><br />
:: You will now have: ~/local/virtenv/bin/python<br />
# In ~/.bash_profile add: <blockquote><pre>PATH=~/local/virtenv/bin:~/local/bin:${PATH}</pre></blockquote><br />
:: so that your local python will be preferred.<br />
:: Log out, log in again and test python" to see which version will be invoked. It should be the new python. Check "which easy_install" to see if the one in local/virtenv would be executed.<br />
:: <br />
:: You have now 1) a local ''python'' installation that you can use, and 2) ''easy_install'' will also work with your local user installation. From now on you can e.g. locally install the nose testing framework (''easy_install nose'') and use it (''python -c "import nose"'').<br />
<br />
===Install mediagoblin as a site package===<br />
<br />
# Check out mediagoblin from git to e.g. ~/mediagoblin<br />
# Install MediaGoblin and all dependencies for MediaGoblin with easy_install.<br />
:* In the mediagoblin directory issue:<br />
:<blockquote><pre>python setup.py</pre></blockquote><br />
:* You will also need to: easy_install lxml<br />
:* Python-image was trickier to install: <pre>easy_install --find-links http://www.pythonware.com/products/pil/ Imaging</pre><br />
::Test by leaving the mediagoblin directory and see if you can import it: <pre>python -c "import mediagoblin"</pre> looking for error messages.<br />
<br />
===Set up an WSGI environment on Dreamhost===<br />
<br />
# Enable the mod_passenger setting for ruby/python in the domains web panel<br />
# ''cd'' into the domain directory (e.g. ~/media.sspaeth.de for me)<br />
# Copy mediagoblin.ini and paste.ini from the ~/mediagoblin directory here<br />
# Create passenger_wsgi.py in your domain directory (e.g. ~/media.sspaeth.de for me):<br />
<blockquote><pre>import sys, os<br />
INTERP = "/home/<username>/local/virtenv/bin/python"<br />
#INTERP is present twice so that the new python interpreter knows the actual executable path<br />
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)<br />
<br />
from paste.deploy import loadapp<br />
application = loadapp('config:/home/mediagoblin/media.sspaeth.de/paste.ini')<br />
<br />
#If in case of errors, all you get are mysterious error 500, you can set debug=true in paste.ini to see stack traces<br />
# Otherwise, add this:<br />
#from paste.exceptions.errormiddleware import ErrorMiddleware<br />
#application = ErrorMiddleware(application, debug=True)</pre></blockquote><br />
# Set up the database by issueing: <pre>gmg dbupdate</pre><br />
# (optional but recommended) Serve the static files directly from the webserver.<br />
:In paste.ini in this section: [composite:routing] comment out the static files:<br />
#/mgoblin_static/ = mediagoblin_static<br />
#/theme_static/ = theme_static<br />
:and symlink the mediagobin/mediagoblin/static directoy to public/mgoblin_static<br />
: and mediagoblin/mediagoblin/themes to public/theme_static<br />
:<br />
:so it is displayed directly. This step might be different depending on your web server configuration. There is no reason that static<br />
:files need to go through all the python indirection when they can be served directly by nginx/apache/...<br />
:<br />
:In case you want to delete your git checkout after the installation (you don't need it, since you installed the mediagoblin package to ~/local/virtenv/lib/python2.7/mediagoblin... you should do the symlinking from there.<br />
===Open Issues===<br />
Please fill in the blanks if you find them out:<br />
* How to enable logging to a file or standard html logs? Console output just disappears.<br />
* How to set up things not using sqlite. What's wrong with mySQL?<br />
<br />
===Troubleshooting===<br />
* First of all: invoke <pre>python passenger_wsgi.py</pre> directly from the shell. This will tell you if there are import errors etc. If this command exits without any output on the console, you have already achieved a lot.<br />
* In ''paste.ini'' set debug=true. This will show you python backtraces directly in the web page<br />
* You will need to configure an smtp user/passwd/server in mediagoblin.ini, so you actually get the account creation token mailed out. Hint, the relevant settings are: <blockquote><pre>email_debug_mode = false<br />
email_sender_address = postmaster@sspaeth.de<br />
email_smtp_host = SMTP.DOMAIN.TLD<br />
email_smtp_user = USERNAME<br />
email_smtp_pass = WEIRDPASSWORD</pre></blockquote><br />
* In case you can upload media, but it does not appear. You don't have the celery server running. Add <pre>CELERY_ALWAYS_EAGER = true</pre> to the ''[celery]'' section in mediagoblin.ini<br />
<br />
=Miscellaneous Hacks=<br />
==Force translation==<br />
There might some conditions under which you would prefer that MediaGoblin always return the same translation. If you are deploying with nginx and fastcgi, you can force MediaGoblin to return a specific translation regardless of browser preferences by passing a specific HTTP_ACCEPT_LANGUAGE fastcgi parameter in your location block. Example last line in location block:<br />
<nowiki><br />
fastcgi_param HTTP_ACCEPT_LANGUAGE es; #force spanish translation<br />
</nowiki></div>Jimbohttps://wiki.mediagoblin.org/index.php?title=Deployment&diff=1028Deployment2012-12-14T20:23:36Z<p>Jimbo: </p>
<hr />
<div>This page could use a lot of work. For now, a few smaller deployment tips!<br />
<br />
See also: http://docs.mediagoblin.org/deploying.html (some of which may belong here)<br />
<br />
= FCGI script =<br />
<br />
This works great with the apache config example below :)<br />
<br />
<pre>#!/path/to/mediagoblin/bin/python<br />
<br />
# Written in 2011 by Christopher Allan Webber<br />
#<br />
# To the extent possible under law, the author(s) have dedicated all<br />
# copyright and related and neighboring rights to this software to the<br />
# public domain worldwide. This software is distributed without any<br />
# warranty.<br />
# <br />
# You should have received a copy of the CC0 Public Domain Dedication along<br />
# with this software. If not, see<br />
# <http://creativecommons.org/publicdomain/zero/1.0/>.<br />
<br />
from paste.deploy import loadapp<br />
from flup.server.fcgi import WSGIServer<br />
<br />
CONFIG_PATH = '/path/to/mediagoblin/paste.ini'<br />
<br />
## Uncomment this to run celery in "always eager" mode... ie, you don't have<br />
## to run a separate process, but submissions wait till processing finishes<br />
# import os<br />
# os.environ['CELERY_ALWAYS_EAGER'] = 'true'<br />
<br />
def launch_fcgi():<br />
ccengine_wsgi_app = loadapp('config:' + CONFIG_PATH)<br />
WSGIServer(ccengine_wsgi_app).run()<br />
<br />
<br />
if __name__ == '__main__':<br />
launch_fcgi()</pre><br />
<br />
= Apache 2 Config with fcgid =<br />
<br />
Note that the libapache2-mod-fcgi in Debian is in the nonfree section, and MediaGoblin users will want to avoid that. Instead, libapache2-mod-fcgid can be used, but requires a slightly different configuration.<br />
<br />
<VirtualHost *:80><br />
Options +ExecCGI<br />
<br />
# Accept up to 16MB requests<br />
FcgidMaxRequestLen 16777216<br />
<br />
ServerName mediagoblin.example.org<br />
<br />
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/<br />
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/<br />
<br />
ScriptAlias / /path/to/mediagoblin/mg.fcgi/<br />
</VirtualHost><br />
<br />
= Apache Config Example =<br />
This configuration example uses mod_fastcgi.<br />
<br />
To install and enable mod_fastcgi on a Debian/Ubuntu based system:<br />
<pre># apt-get install libapache2-mod-suexec libapache2-mod-fastcgi<br />
# a2enmod suexec<br />
# a2enmod fastcgi</pre><br />
<br />
Sample configuration:<br />
<pre><br />
<VirtualHost *:80><br />
ServerName mediagoblin.yourdomain.tld<br />
ServerAdmin webmaster@yourdoimain.tld<br />
DocumentRoot /var/www/<br />
# Custom log files<br />
CustomLog /var/log/apache2/mediagobling_access.log combined<br />
ErrorLog /var/log/apache2/mediagoblin_error.log<br />
<br />
# Serve static and media files via alias<br />
Alias /mgoblin_static/ /path/to/mediagoblin/mediagoblin/static/<br />
Alias /mgoblin_media/ /path/to/mediagoblin/user_dev/media/public/<br />
<br />
# Rewrite all URLs to fcgi, except for static and media urls<br />
RewriteEngine On<br />
RewriteRule ^(mgoblin_static|mgoblin_media)($|/) - [L]<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteRule ^/(.*)$ /mg.fcgi/$1 [QSA,L]<br />
<br />
# Allow access to static and media directories<br />
<Directory /path/to/mediagoblin/mediagoblin/static><br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
<Directory /path/to/mediagoblin/mediagoblin/user_dev/media/public><br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
<br />
# Connect to fcgi server<br />
FastCGIExternalServer /var/www/mg.fcgi -host 127.0.0.1:26543<br />
</VirtualHost><br />
</pre><br />
Then, you need to make sure mediagoblin is running in fcgi mode:<br />
<pre>cd /path/to/mediagoblin<br />
./lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543</pre><br />
<br />
Note: there may be several ways to improve this configuration<br />
<br />
= Juju =<br />
<br />
There is a juju [https://juju.ubuntu.com/Charms charm] available for deploying mediagoblin into EC2 or on your local box. [https://juju.ubuntu.com/ juju] is available in Ubuntu 11.10 and later, though it is recommended that you pull it from [https://launchpad.net/~juju/+archive/pkgs| the juju PPA], which includes backported packages going back to Ubuntu 11.10. To use the juju charm, install juju and configure either the [https://juju.ubuntu.com/docs/provider-configuration-local.html local provider] or one of the cloud API providers, currently the [https://juju.ubuntu.com/docs/provider-configuration-ec2.html EC2 provider] is the best supported and works not only with Amazon Web Services but also OpenStack clouds. There is also a newer native OpenStack API provider which is known to support HP Cloud.<br />
<pre><br />
# if you have not bootstrapped<br />
juju bootstrap<br />
mkdir ~/charms<br />
bzr init-repo ~/charms/precise<br />
bzr branch lp:~clint-fewbar/charms/precise/mediagoblin/trunk ~/charms/precise/mediagoblin<br />
juju deploy --repository ~/charms local:mediagoblin<br />
juju expose mediagoblin<br />
</pre><br />
<br />
Currently the charm is volatile, deploying from trunk, and deploys a single-server version of MediaGoblin only. It will eventually relate to the existing juju charms for other supported data stores to allow one to scale out their MediaGoblin instance.<br />
<br />
= Init scripts =<br />
<br />
== Debian init scripts ==<br />
<br />
Joar has some scripts for running celery and mediagoblin separately that are designed for Debian.<br />
<br />
https://github.com/joar/mediagoblin-init-scripts<br />
<br />
== Arch Linux init scripts ==<br />
<br />
[http://whird.jpope.org/2012/04/14/mediagoblin-archlinux-rcd-scripts Jeremy Pope has written a nice blogpost] on how to add init scripts to deploy MediaGoblin with both the python paste http server and the celery deployments separated.<br />
<br />
If you want a simpler setup and don't want to deploy celery separately, consider either turning CELERY_ALWAYS_EAGER to true in the paste init script described above, or check out [http://chimo.chromic.org/2012/03/01/mediagoblin-init-script-on-archlinux/ Chimo's guide].<br />
<br />
<br />
<br />
== Generic, simple init script ==<br />
<br />
This is a super stupidly simple init script that was used for mediagoblin.com... note that this has Celery running in always eager mode.<br />
<br />
You will need to adjust the paths appropriately. This could probably be better written!<br />
<br />
#! /bin/sh<br />
<br />
## Stupidly simple mediagoblin init script.<br />
# <br />
# Written in 2012 by Christopher Allan Webber<br />
#<br />
# To the extent possible under law, the author(s) have dedicated all<br />
# copyright and related and neighboring rights to this software to the<br />
# public domain worldwide. This software is distributed without any<br />
# warranty.<br />
# <br />
# You should have received a copy of the CC0 Public Domain Dedication along<br />
# with this software. If not, see<br />
# <http://creativecommons.org/publicdomain/zero/1.0/>.<br />
<br />
PASTER=/srv/mediagoblin.com/bin/paster<br />
PASTE_CONFIG=/srv/mediagoblin.com/paste.ini<br />
OPTIONS="--pid-file=/tmp/mediagoblin.pid \<br />
--log-file=/srv/mediagoblin.com/paster.log \<br />
--server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543"<br />
<br />
CELERY_ALWAYS_EAGER=true su -pc "$PASTER serve $PASTE_CONFIG $1 $OPTIONS" webadmin<br />
<br />
= Running on Dreamhost.com =<br />
<br />
===Set up your python virtualenv===<br />
<br />
dreamhost.com servers come with python 2.4 and 2.5 installed which is too old for mediagoblin. This means you need to compile and install a newer python (don't worry this is really not difficult on dreamhost servers). In order to be able to install python packages for a local user without touching system files, we need to setup a python ''virtualenv''. Fortunately, this is not too tricky either. If your server has python 2.6 or 2.7 installed already, you can skip the [[#Install a local python|python installation stuff]] and you'll only need to [[#Setup virtualenv to install local python packages|install virtualenv]].<br />
<br />
====Install a local python====<br />
# Download the latest python: http://python.org/ftp/python/XXX/Python-XXX.tar.bz2<br />
# Unpack with <pre>tar xvjf Python-XXX.tar.bz2</pre><br />
# ''cd'' into the directory and compile and install python locally:<br />
<blockquote><pre>./configure --prefix=$HOME/local<br />
make<br />
make install</pre></blockquote><br />
:This will install python (I used 2.7.3) into /home/<USERNAME>/local/bin/python. You might get warnings about some modules not being able to compile. :It was tcl/tk and bzip2 mainly, but things still worked out overall.<br />
:<br />
:You should now be able to invoke <tt>~/local/bin/python</tt> and fall into a shell of your new python (exit with ctrl-d). Congrats, you have now a new python 2.7 that you can use. However, you will need to be able to install additional packages as a user and this is what virtualenv allows.<br />
<br />
====Setup virtualenv to install local python packages====<br />
# Download the latest virtualenv: http://pypi.python.org/packages/source/v/virtualenv/XXX<br />
# Install the virtualenv: <blockquote><pre>~/local/bin/python ~/virtualenv-1.8/virtualenv.py $HOME/local/virtenv</pre></blockquote><br />
:: You will now have: ~/local/virtenv/bin/python<br />
# In ~/.bash_profile add: <blockquote><pre>PATH=~/local/virtenv/bin:~/local/bin:${PATH}</pre></blockquote><br />
:: so that your local python will be preferred.<br />
:: Log out, log in again and test python" to see which version will be invoked. It should be the new python. Check "which easy_install" to see if the one in local/virtenv would be executed.<br />
:: <br />
:: You have now 1) a local ''python'' installation that you can use, and 2) ''easy_install'' will also work with your local user installation. From now on you can e.g. locally install the nose testing framework (''easy_install nose'') and use it (''python -c "import nose"'').<br />
<br />
===Install mediagoblin as a site package===<br />
<br />
# Check out mediagoblin from git to e.g. ~/mediagoblin<br />
# Install MediaGoblin and all dependencies for MediaGoblin with easy_install.<br />
:* In the mediagoblin directory issue:<br />
:<blockquote><pre>python setup.py</pre></blockquote><br />
:* You will also need to: easy_install lxml<br />
:* Python-image was trickier to install: <pre>easy_install --find-links http://www.pythonware.com/products/pil/ Imaging</pre><br />
::Test by leaving the mediagoblin directory and see if you can import it: <pre>python -c "import mediagoblin"</pre> looking for error messages.<br />
<br />
===Set up an WSGI environment on Dreamhost===<br />
<br />
# Enable the mod_passenger setting for ruby/python in the domains web panel<br />
# ''cd'' into the domain directory (e.g. ~/media.sspaeth.de for me)<br />
# Copy mediagoblin.ini and paste.ini from the ~/mediagoblin directory here<br />
# Create passenger_wsgi.py in your domain directory (e.g. ~/media.sspaeth.de for me):<br />
<blockquote><pre>import sys, os<br />
INTERP = "/home/<username>/local/virtenv/bin/python"<br />
#INTERP is present twice so that the new python interpreter knows the actual executable path<br />
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)<br />
<br />
from paste.deploy import loadapp<br />
application = loadapp('config:/home/mediagoblin/media.sspaeth.de/paste.ini')<br />
<br />
#If in case of errors, all you get are mysterious error 500, you can set debug=true in paste.ini to see stack traces<br />
# Otherwise, add this:<br />
#from paste.exceptions.errormiddleware import ErrorMiddleware<br />
#application = ErrorMiddleware(application, debug=True)</pre></blockquote><br />
# Set up the database by issueing: <pre>gmg dbupdate</pre><br />
# (optional but recommended) Serve the static files directly from the webserver.<br />
:In paste.ini in this section: [composite:routing] comment out the static files:<br />
#/mgoblin_static/ = mediagoblin_static<br />
#/theme_static/ = theme_static<br />
:and symlink the mediagobin/mediagoblin/static directoy to public/mgoblin_static<br />
: and mediagoblin/mediagoblin/themes to public/theme_static<br />
:<br />
:so it is displayed directly. This step might be different depending on your web server configuration. There is no reason that static<br />
:files need to go through all the python indirection when they can be served directly by nginx/apache/...<br />
:<br />
:In case you want to delete your git checkout after the installation (you don't need it, since you installed the mediagoblin package to ~/local/virtenv/lib/python2.7/mediagoblin... you should do the symlinking from there.<br />
===Open Issues===<br />
Please fill in the blanks if you find them out:<br />
* How to enable logging to a file or standard html logs? Console output just disappears.<br />
* How to set up things not using sqlite. What's wrong with mySQL?<br />
<br />
===Troubleshooting===<br />
* First of all: invoke <pre>python passenger_wsgi.py</pre> directly from the shell. This will tell you if there are import errors etc. If this command exits without any output on the console, you have already achieved a lot.<br />
* In ''paste.ini'' set debug=true. This will show you python backtraces directly in the web page<br />
* You will need to configure an smtp user/passwd/server in mediagoblin.ini, so you actually get the account creation token mailed out. Hint, the relevant settings are: <blockquote><pre>email_debug_mode = false<br />
email_sender_address = postmaster@sspaeth.de<br />
email_smtp_host = SMTP.DOMAIN.TLD<br />
email_smtp_user = USERNAME<br />
email_smtp_pass = WEIRDPASSWORD</pre></blockquote><br />
* In case you can upload media, but it does not appear. You don't have the celery server running. Add <pre>CELERY_ALWAYS_EAGER = true</pre> to the ''[celery]'' section in mediagoblin.ini<br />
<br />
=Miscellaneous Hacks=<br />
==Force translation==<br />
There might some conditions under which you would prefer that MediaGoblin always return the same translation. If you are deploying with nginx and fastcgi, you can force MediaGoblin to return a spefcific translation regardless of browser preferences by passing a specific HTTP_ACCEPT_LANGUAGE fastcgi parameter in your location block. Example last line in location block:<br />
<nowiki><br />
fastcgi_param HTTP_ACCEPT_LANGUAGE es; #force spanish translation<br />
</nowiki></div>Jimbo