#Installing Koop on an IIS Server with iisnode
- Install latest version of node.js for windows (https://nodejs.org/)
- Install the URL Rewrite module for IIS (http://www.iis.net/downloads/microsoft/url-rewrite)
- Install iisnode from GitHub (https://github.com/tjanczuk/iisnode)
run C:\Program Files\iisnode\setupsamples.bat from command prompt (run as Administrator/elevated privileges)
test that it works (http://localhost/node/helloworld/hello.js)
-
Install PostgreSQL 9.4.1 (http://www.enterprisedb.com/products-services-training/pgdownload#windows)
-
Follow instructions to implement a persistent cache (https://github.com/koopjs/koop-sample-app/blob/master/docs/PG_CACHE.md)
-
Install cURL for Windows (http://www.confusedbycode.com/curl/)
-
Install koop-sample-app (https://github.com/koopjs/koop-sample-app)
-
Add virtual directory to iis for koop and point to koop-sample-app location (in my case d:\koop-sample-app)
-
Add web.config with URL rewrite mod to d:\koop-sample-app
<configuration> <system.webServer> <!-- indicates that the hello.js file is a node.js application to be handled by the iisnode module --> <handlers> <add name="iisnode" path="server.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <rule name="server"> <match url="/*" /> <action type="Rewrite" url="server.js" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
-
Update server.js in koop-sample-app folder to: https://github.com/koopjs/koop-sample-app/blob/master/docs/PG_CACHE.md
var express = require("express"),
cors = require('cors'),
config = require("config"),
koop = require('koop')( config ),
socrata = require('koop-socrata'),
ckan = require('koop-ckan'),
github = require('koop-github'),
agol = require('koop-agol'),
gist = require('koop-gist'),
pgCache = require('koop-pgcache');
koop.registerCache( pgCache );
http.createServer(app).listen(process.env.PORT || config.server.port);
- update koop-sample-app\config\default.json to use postgres (https://github.com/koopjs/koop-sample-app/blob/master/docs/PG_CACHE.md)
{
"server": {
"port": 1337
},
"data_dir": "/usr/local/koop/",
"db": {
"conn": "postgres://username:password@localhost/koopdev"
}
}
- update d:\koop-sample-app\server.js to allow koop to run at a virtual dir (i.e. /koop)
// add koop middleware
//app.use( koop );
app.use('/koop', koop ); //This is changed to all koop to run at a different location
//app.get('/status', function(req, res){
app.get('/koop/status', function(req, res){ //Have to listed for status at the right location
res.json( koop.status );
});
// serve the index
//app.get("/", function(req, res, next) {
app.get("/koop", function(req, res, next) { //If user requests the /koop root, need to give them the right data
res.send('Koop Sample App!');
});
-
Add your socrata site using cURL
curl --data "host=https://data.wa.gov&id=wa" localhost/koop/socrata
-
Verify your socrata provider is working by visiting: http://localhost/koop/socrata
-
Test an actual dataset by visiting something like: http://50.18.49.187/koop/socrata/wa/3uf4-3kn2/FeatureServer
can you add this to the koop wiki? that'd make it easier for others to help keep it up to date (for example, @ngoldman cleaned up the logic in
server.js
and revised the way we get custom ports)it'd also probably be helpful to mention explicitly the need to run
npm install
(see here)at some point we'll be aggregating doc like this for http://koopjs.github.io, but for now i think the koop wiki is a good collection location.