I would like to know how to run and deploy CKAN using lighttpd.
Actually, I'm using mod_proxy to redirect lighttpd to httpd alternative port (that's running ckan):
$HTTP["host"] == "ckan.example.com"{
proxy.server = ( "" =>
( "" =>
("host" => "127.0.0.1", "port" => 81)
)
)
}
But for sure it's reduced the performance.
The apache configuration is as follows:
WSGISocketPrefix /var/run/wsgi
<VirtualHost 0.0.0.0:81>
ServerName localhost
ServerAlias localhost
WSGIScriptAlias / /etc/ckan/default/apache.wsgi
# Pass authorization info on (needed for rest api).
WSGIPassAuthorization On
# Deploy as a daemon (avoids conflicts between CKAN instances).
WSGIDaemonProcess ckan_default display-name=ckan_default processes=2 threads=15
WSGIProcessGroup ckan_default
# Add this to avoid Apache show error:
# "AH01630: client denied by server configuration: /etc/ckan/default/apache.wsgi"
<Directory /etc/ckan/default>
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/ckan_default.error.log
CustomLog /var/log/httpd/ckan_default.custom.log combined
</VirtualHost>
The /etc/ckan/default/apache.wsgi is:
import os
activate_this = os.path.join('/usr/lib/ckan/default/bin/activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
from paste.deploy import loadapp
config_filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'development.ini')
from paste.script.util.logging_config import fileConfig
fileConfig(config_filepath)
application = loadapp('config:%s' % config_filepath)
One way to do it as FastCGI would be perfect.
Without install nothing else, is possible run CKAN as a daemon and use proxy to serve ckan on port 80 by lighttpd.
So, to do that was necessary turn it a service on CentOS7:
With CentOS7 (and all RHEL7 Family) was easy to create service. You just need to create an ckand.service and run CKAN as a Daemon.
mkdir -p /var/run/ckan && chown ckan:ckan /var/run/ckan -R
mkdir -p /var/log/ckan && chown ckan:ckan /var/log/ckan -R
You may need to change configuration file path.
[Unit]
Description=CKAN Daemon Service
Requires=solr.service postgresql.service
After=solr.service postgresql.service
[Service]
User=ckan
Group=ckan
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
PIDFile=/var/run/ckan/ckan.pid
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false
ExecStart=/usr/lib/ckan/default/bin/paster serve /etc/ckan/default/development.ini --daemon --pid-file=/var/run/ckan/ckan.pid --log-file=/var/log/ckan/ckan.log
ExecStop=/usr/lib/ckan/default/bin/paster serve /etc/ckan/default/development.ini --stop-daemon --pid-file=/var/run/ckan/ckan.pid
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=default.target
1st you must make sure that have proxy module activated and then on /etc/lighttpd/vhost.d/ you must create a .conf like that:
$HTTP["host"] == "ckan.example.com" {
proxy.server = ( "" =>
( "" =>
("host" => "127.0.0.1", "port" => 5000) # if you're running ckan on a different port please change here
)
)
}
cd /etc/ckan/default
wget https://gist.githubusercontent.com/LeonanCarvalho/a7bd73fe9632873c1bd7898c73d4b218/raw/637db259f4e1ac8980ea3377259bd65042cd1a8b/ckand.service
#It can't be a symbolic link
ln -P /etc/ckan/default/ckand.service /etc/systemd/system/ckand.service
systemctl enable ckand
systemctl start ckand
systemctl status ckand -l
cd /etc/lighttpd/vhost.d
wget https://gist.githubusercontent.com/LeonanCarvalho/a7bd73fe9632873c1bd7898c73d4b218/raw/637db259f4e1ac8980ea3377259bd65042cd1a8b/ckan_lighttpd_vhost.conf
systemctl restart lighttpd
Please check content of links before wget, you may change it after download.