Deployment: Difference between revisions
(Changing juju charm to reflect recent updates.) |
|||
Line 126: | Line 126: | ||
= Juju = |
= Juju = |
||
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 |
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. |
||
<pre> |
<pre> |
||
# if you have not bootstrapped |
|||
juju bootstrap |
|||
mkdir ~/charms |
mkdir ~/charms |
||
bzr init-repo ~/charms/ |
bzr init-repo ~/charms/precise |
||
bzr branch lp:~clint-fewbar/charms/ |
bzr branch lp:~clint-fewbar/charms/precise/mediagoblin/trunk ~/charms/precise/mediagoblin |
||
juju deploy --repository ~/charms local:mediagoblin |
juju deploy --repository ~/charms local:mediagoblin |
||
juju expose mediagoblin |
juju expose mediagoblin |
||
</pre> |
</pre> |
||
Currently the charm is |
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. |
||
= ArchLinux init scripts = |
= ArchLinux init scripts = |
Revision as of 04:33, 9 October 2012
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)
FCGI script
This works great with the apache config example below :)
#!/path/to/mediagoblin/bin/python # Written in 2011 by Christopher Allan Webber # # To the extent possible under law, the author(s) have dedicated all # copyright and related and neighboring rights to this software to the # public domain worldwide. This software is distributed without any # warranty. # # You should have received a copy of the CC0 Public Domain Dedication along # with this software. If not, see # <http://creativecommons.org/publicdomain/zero/1.0/>. from paste.deploy import loadapp from flup.server.fcgi import WSGIServer CONFIG_PATH = '/path/to/mediagoblin/paste.ini' def launch_fcgi(): ccengine_wsgi_app = loadapp('config:' + CONFIG_PATH) WSGIServer(ccengine_wsgi_app).run() if __name__ == '__main__': launch_fcgi()
Apache 2 Config with fcgid
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.
<VirtualHost *:80> ServerName media.example.com ServerAlias www.media.example.com DocumentRoot /path/to/mediagoblin 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 /mgoblin_static> Order allow,deny Allow from all </Directory> <Directory /mgoblin_media> Order allow,deny Allow from all </Directory> <Directory /path/to/mediagoblin/> SetHandler fcgid-script Options +ExecCGI FcgidWrapper /path/to/mediagoblin/mg.fcgi order allow,deny allow from all </Directory> </VirtualHost>
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
Juju
There is a juju charm available for deploying mediagoblin into EC2 or on your local box. juju is available in Ubuntu 11.10 and later, though it is recommended that you pull it from the juju PPA, which includes backported packages going back to Ubuntu 11.10. To use the juju charm, install juju and configure either the local provider or one of the cloud API providers, currently the 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.
# if you have not bootstrapped juju bootstrap mkdir ~/charms bzr init-repo ~/charms/precise bzr branch lp:~clint-fewbar/charms/precise/mediagoblin/trunk ~/charms/precise/mediagoblin juju deploy --repository ~/charms local:mediagoblin juju expose mediagoblin
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.
ArchLinux init 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.
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 Chimo's guide.