Sunflower is a simple image gallery written in Django framework. It strives to be easy to use and focus on presenting content in a clear and distraction-free fashion.
You can see working example under konradwasowicz.com/sunflower
This assumes you're using virtualenv
for deployment
- Create new virtualenv folder
virtualenv <project_name>
- Activate it:
# from within <project_name> folder
source bin/activate
- Clone sunflower repository:
git clone https://github.com/exaroth/sunflower.git
- Lastly install all the requirements:
# from within sunflower folder
pip install -r requirements.txt
- (Optional) Install memcached and run it on port 11211:
# for mac users
brew install memcached
# for linux users
sudo apt-get install memcached
Then run it:
memcached -d -p 11211
Note: Sunflower will still run even without memcached but the content won't be cached (d'oh).
-
Inside
/static/
directory executenpm install && bower install
to download required Javascript libraries. -
Configure database settings inside
settings.py
file and executepython manage.py syncdb
to create required tables. -
Then edit
run_dev_server.sh
file and changeDJANGO_DIR
to an absolute path to your project (the directory withmanage.py
file). -
Execute
run_dev_server.sh
:
./run_dev_server.sh
This will start django dev server along with grunt and will compile less and refresh browser each time you make any changes to html, js or less files.
This assumes you're using Nginx as a http server and Gunicorn as WSGI one.
-
Install gunicorn inside virtualenv and add it to
INSTALLED_APPS
in settings.py -
IMPORTANT Change
SECRET_KEY
value to anything you like. -
Add your hostname into
ALLOWED_HOSTS
list -
Define database backend inside
settings.py
- see relevant entry in Django documentation for details. -
Execute
python manage.py syncdb
. -
Go to
static/
folder and executegrunt build
if you have made any changes to css or javascript, this will compile, concatenate and minify all the required files. -
Edit
run_sunflower.sh
script, inside you will find following variables (starred entries should be changed):APP_NAME
- name of the application- *
DJANGO_DIR
- absolute path to the project - *
USER
- define user account gunicorn process will be running as (preferablywww-data
) - *
SOCKET_FILE
- absolute path to unix socket file to be used withbind
flag when running gunicorn server NUM_WORKERS
- number of workers to be used by gunicornDJANGO_SETTINGS_MODULE
- string denoting settings.py module inside the appDJANGO_WSGI_MODULE
- same as above but for wsgi module
-
Then configure Nginx server to use gunicorn as reverse proxy. You can find example configuration that works fairly well in Gunicorn documentation. Be sure to add proper aliases for
static
andmedia
directories as files inside are served straight from hdd. -
Finally run memcached, execute
run_sunflower.sh
and restart Nginx with new configuration and you're set to go.