Install wiki.js on windows server 2012 R2 and integrated with active directory

wiki.js is a open source wiki software(web). We installed wiki.js on our internal windows server 2012 R2 for documenting and knowledge sharing purpose. It’s tricky to install wiji.js on windows server as there is no much document on it in detail, neither instruction document on wiki.js site itself.


Our environment:

  1. Windows server 2012 R2
  2. Latest node.js
  3. Latest PostgreSQL
  4. Latest wiki.js ( 2.x)


Windows server 2012 R2 setup

  1. vc run time fix: You probably will fail to install any software that requires vc run time such as PostegreSQL. Follow this document to fix it at first.
  2. AD setup: To integrate active directory authentication to wiki.js,
    • First install a AD role.
    • Windows server 2012 AD support Ldap protocol by default.
    • Add a domain user, it will be used to query/authenticate users by wiki.js. In this example, the added user name is “ADAuthUser”, password is “123456”. You can use existing user instead of adding a new one, for example use domain administrator but certainly it’s not recommended, as password of this user will be shown on wiki admin page in plain text. The best practice is to add a specific user for Ldap access purpose. The user will need domain read permission which any domain user has, so no need to grant any special permission to this user.


Install Nodejs

Install Nodejs is quite straight forward. Down it from here, and click to install.


Install PostgreSQL

  1. Download it from here.
  2. Click to install. When install, you will be asked to input password for PostgreSQL administrator and port for SQL connection. The password will be needed later when setup SQL DB.
  3. After installation completed, go to PostgreSQL install folder\PostgreSQL\l1\pgAdmin4\bin, run pgAdmin4.exe. This is the administration tool for PostgreSQL.
  4. Input the administrator password to connect to SQL.
  5. Add a user to PostgreSQL, in this example, user name is “wikijs”, password is “123456”.
  6. Create a DB for wiki.js, in this example, DB name is “wikijs”. Set the owner of this DB to “wikijs”, and grant any other permission to this user.

Wikijs Install

  1. Download wiki.js from here.
  2. Unzip folder to any place you like, in this example, it’s unzipped to C:\wikijs
  3. Make a copy of sample.config.yml file and rename it to “config.yml”. Following the setup instruction on wiki.js to change the file. Basically the main fields to change in this files is the IP address of SQL server, the wikijs DB owner created in previous step and the password. The port to access wikijs and the port could be any available port
  4. You can turn off firewall to make it simple to test wiki.js to configure firewall to allow traffic on the wiki port. In this example, port number is 3000.
  5. Open Powershell, and nav to C:\wikijs folder in power shell.
  6. In power shell, run “node server”. There is a folder named “server” in C:\wikijs. So “node server” means run the app under server folder by node js as command line is already in C:\wikijs folder.
  7. When text in command line tells “browse to http://localhost:3000”, open it in a web browser, better NOT browse it on server by IE as it may not corrected rendered.
  8. Following instruction on the web page to complete install.

Run wiki.js in background

When run wiki.js by “node server”, it ran from command line. The command line will be terminated when user sign out. And it will NOT be launched automatically when server restart. There are some methods recommended on wiki.js official site to run it in background as service. All of them is related to nodejs environment. Unfortunately, it took me few hours to try them but none of them works for me. On windows server, there is pretty simple way to make it run in background: Add a task schedule.

  1. In administrative tools, click Task Schedule.
  2. Add task. In general tab, security options, select “Run whether user is logged on or not”.
  3. Check “Run with highest privileges”.
  4. Make a run.cmd in C:\wikijs folder and write “node server” to the file.
  5. In task “Action” tab, add a action to run “run.cmd”. Remember to set the start/working folder of the action to C:\wikijs.
  6. To debug it and run it now, just run the task immediately.

Integrate with Active Directory

  1. Login into wiki.js as administrator.
  2. Nav to admin page, click Authentication.
  3. Check and click AD/Ldap Auth.
  4. Allow self registration by this auth method. Fill following fields:
  5. LDAP URL: ldap://192.168.0.2:389, here 192.168.0.2 is example IP of AD server.
  6. Admin Bind DN: CN=ADAuthUser,CN=Users,DC=physoft,DC=cn, ADAUthUser is the domain user created in previous step for Ldap Auth purpose. DC=physoft, DC=cn is for our company domain is physoft.cn. This string tells Ldap the user to enum or auth users is ” ADAuthUser” in physoft.cn domain, and the user is under “Users” container. This is the default container when a domain user added.
  7. Admin Bind Credentials: password for ADAuthUser.
  8. Search base: CN=Users,DC=Physoft,DC=cn This string tell Ldap to enum user in “Users” container under physoft.cn.
  9. Seach filter: (sAMAccountName={{username}}) , sAMAccountName is the uid field in windows AD. And {{ username }} is variable of wiki.js. When wikijs query a specific user, {{username}} will be replaced by a specific user uid, for example ” ADAuthUser “. And finally compare the instance value to sAMAccountName field in AD.
  10. Unique ID field mapping: sAMAccountName

菲烁易维公众号