Skip to content

Commit

Permalink
Merge branch '877-nginx-instructions'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Nov 21, 2013
2 parents 0e19cb2 + a5057a1 commit e36ba3e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
6 changes: 4 additions & 2 deletions doc/conf.py
Expand Up @@ -57,6 +57,8 @@
.. |sqlalchemy| replace:: SQLAlchemy
.. |javascript| replace:: JavaScript
.. |apache| replace:: Apache
.. |nginx_config_file| replace:: /etc/nginx/sites-available/ckan_default
.. |reload_nginx| replace:: sudo service nginx reload
'''

Expand Down Expand Up @@ -87,7 +89,7 @@
href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
Attribution ShareAlike (Unported) v3.0 License</a>.<br />
<img src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png" alt="CC License Logo" />
<a href="http://opendefinition.org/"><img src="http://assets.okfn.org/images/ok_buttons/oc_80x15_blue.png" border="0"
<a href="http://opendefinition.org/"><img src="http://assets.okfn.org/images/ok_buttons/oc_80x15_blue.png" border="0"
alt="{{ _('Open Content') }}" /></a>
'''
html_show_sphinx = False
Expand Down Expand Up @@ -146,7 +148,7 @@
#'sidebarbgcolor': '#F2F2F2',
#'sidebartextcolor': 'black',
#'sidebarlinkcolor': '#355F7C',
#'headfont': 'Trebuchet MS'
#'headfont': 'Trebuchet MS'
#}
sys.path.append(os.path.abspath('_themes'))
html_theme_path = ['_themes']
Expand Down
57 changes: 49 additions & 8 deletions doc/deployment.rst
Expand Up @@ -16,6 +16,7 @@ Because CKAN uses WSGI, a standard interface between web servers and Python web
applications, CKAN can be used with a number of different web server and
deployment configurations including:

* Apache_ with the modwsgi Apache module proxied with Nginx_ for caching
* Apache_ with the modwsgi Apache module
* Apache_ with paster and reverse proxy
* Nginx_ with paster and reverse proxy
Expand All @@ -24,8 +25,9 @@ deployment configurations including:
.. _Apache: http://httpd.apache.org/
.. _Nginx: http://nginx.org/

This guide explains how to deploy CKAN using Apache and modwsgi on an Ubuntu
server. These instructions have been tested on Ubuntu 12.04.
This guide explains how to deploy CKAN using Apache and modwsgi and proxied
with Nginx on an Ubuntu server. These instructions have been tested on Ubuntu
12.04.

If run into any problems following these instructions, see `Troubleshooting`_
below.
Expand All @@ -51,11 +53,20 @@ support to Apache)::

sudo apt-get install apache2 libapache2-mod-wsgi

.. _modwsgi: https://code.google.com/p/modwsgi/
.. _modwsgi: https://code.google.com/p/modwsgi/


----------------
3. Install Nginx
----------------

Install Nginx_ (a web server) which will proxy the content from Apache_ and add
a layer of caching::

sudo apt-get install nginx

--------------------------
3. Install an Email Server
4. Install an Email Server
--------------------------

If one isn't installed already, install an email server to enable CKAN's email
Expand All @@ -71,7 +82,7 @@ return.


------------------------------
4. Create the WSGI Script File
5. Create the WSGI Script File
------------------------------

Create your site's WSGI script file |apache.wsgi| with the following
Expand All @@ -96,15 +107,15 @@ CKAN to run in).


--------------------------------
5. Create the Apache Config File
6. Create the Apache Config File
--------------------------------

Create your site's Apache config file at |apache_config_file|, with the
following contents:

.. parsed-literal::
<VirtualHost 0.0.0.0:80>
<VirtualHost 0.0.0.0:8080>
ServerName default.ckanhosted.com
ServerAlias www.default.ckanhosted.com
WSGIScriptAlias / |apache.wsgi|
Expand All @@ -128,17 +139,47 @@ This tells the Apache modwsgi module to redirect any requests to the web server
to the WSGI script that you created above. Your WSGI script in turn directs the
requests to your CKAN instance.

-------------------------------
7. Create the Nginx config file
-------------------------------

Create your site's Nginx config file at |nginx_config_file|, with the
following contents:

.. parsed-literal::
proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
proxy_temp_path /tmp/nginx_proxy 1 2;
server {
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_cache cache;
proxy_cache_bypass $cookie_auth_tkt;
proxy_no_cache $cookie_auth_tkt;
proxy_cache_valid 30m;
proxy_cache_key $host$scheme$proxy_host$request_uri;
# In emergency comment out line to force caching
# proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
}
}
------------------------
6. Enable Your CKAN Site
8. Enable Your CKAN Site
------------------------

Finally, enable your CKAN site in Apache:

.. parsed-literal::
sudo a2ensite ckan_default
sudo ln -s |nginx_config_file| /etc/nginx/sites-enabled/ckan_default
|reload_apache|
|reload_nginx|
You should now be able to visit your server in a web browser and see your new
CKAN instance.
Expand Down

0 comments on commit e36ba3e

Please sign in to comment.