You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

OpenLDAP is a free and open source implementation of the Lightweight Directory Access Protocol developed by the OpenLDAP Project. OpenLDAP is released under OpenLDAP Public License. In this guide, we’ll look at how to install OpenLDAP and phpLDAPadmin on Ubuntu 20.04|18.04 LTS, and later add user accounts for central authentication in your Network.

If you need advanced centralized user management platform, see

How to Install and Configure FreeIPA Server on Ubuntu

How to Configure FreeIPA Client on CentOS/Ubuntu

How to Configure FreeIPA replication on Ubuntu / CentOS

What is phpLDAPadmin?

phpLDAPadmin is a web-based PHP application for administering Lightweight Directory Access Protocol servers. phpLDAPadmin is licensed under the GNU General Public License.

This tool exists to ease your OpenLDAP administration often done through commands such asldapadd,ldapdelete, ldapmodify, ldapsearch e.t.c.

Step 1: Install OpenLDAP on Ubuntu 20.40|18.04 LTS

We’ll start with the installation of OpenLDAP on Ubuntu 18.04 LTS. Set your system hostname and add it to file/etc/hosts.

$ sudo hostnamectl set-hostname ldap.example.com
$ sudo vim /etc/hosts
192.168.18.50 ldap.example.com

Replace ldap.example.com with your correct hostname/valid domain name.

The OpenLDAP packages are available on Ubuntu 20.04|18.04 upstream repositories, and you install them by just firing apt install commands.

sudo apt update
sudo apt -y install slapd ldap-utils

During the installation, you’ll be prompted to set LDAP admin password, provide your desired password, then press <OK>

install openldap ubuntu 18.04 set password 01 min

Confirm the password and continue installation by selecting <ok> with TAB key.

install openldap ubuntu 18.04 set password 02 min

You can confirm that your installation was successful using the commandslapcat  to output SLAPD database contents.

[email protected]:~# slapcat 
dn: dc=example,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: example.com
dc: example
structuralObjectClass: organization
entryUUID: e2990be6-689b-1038-8d53-cd4ea0a9f2fa
creatorsName: cn=admin,dc=example,dc=com
createTimestamp: 20181020100850Z
entryCSN: 20181020100850.169668Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=com
modifyTimestamp: 20181020100850Z

dn: cn=admin,dc=example,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator
userPassword:: e1NTSEF9ekc4WjVhTSt1RnBrTk1hb1hjRUt4S0cvbk8vSkNUS0k=
structuralObjectClass: organizationalRole
entryUUID: e29b65e4-689b-1038-8d54-cd4ea0a9f2fa
creatorsName: cn=admin,dc=example,dc=com
createTimestamp: 20181020100850Z
entryCSN: 20181020100850.185122Z#000000#000#000000
modifiersName: cn=admin,dc=example,dc=com
modifyTimestamp: 20181020100850Z

Step 2: Add base dn for Users and Groups

The next step is adding a base DN for users and groups. Create a file named basedn.ldif with below contents:

dn: ou=people,dc=example,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=example,dc=com
objectClass: organizationalUnit
ou: groups

Replace example and com with your correct domain components.

Now add the file by running the command:

$ ldapadd -x -D cn=admin,dc=example,dc=com -W -f basedn.ldif
Enter LDAP Password: 
adding new entry "ou=people,dc=example,dc=com"
adding new entry "ou=groups,dc=example,dc=com"

Step 3: Install phpLDAPadmin on Ubuntu 20.40|18.04 LTS

Once we have OpenLDAP running, it is time to install phpLDAPadmin which will help you manage your LDAP server. phpLDAPadmin requires PHP and Apache web server installed on your Ubuntu system.

sudo apt -y install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear

Enable php*-cgi extension

# Ubuntu 18.04
sudo a2enconf php7.2-cgi
sudo  systemctl reload apache2

# Ubuntu 20.04
sudo a2enconf php7.4-cgi
sudo  systemctl reload apache2

Install phpLDAPadmin by running the command:

sudo apt -y install phpldapadmin

Modify access permissions on /etc/apache2/conf-enabled/phpldapadmin.conf to allow access only from your trusted subnets.

Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.18.0/24

You’ll need to restart apache web server after making the change:

sudo systemctl restart apache2

If you have active UFW firewall, open port 80 and port 443

sudo ufw allow proto tcp from any to any port 80,443

To access phpLDAPadmin, you’ve to access:

http://(server’s hostname or IP address)/phpldapadmin

Use a client machine allowed from the network to access the dashboard.

phpldapadmin ubuntu 18.04 01 minClick the “login” button at the top left corner to login to the admin dashboard.

install phpLDAPadmin ubuntu 18.04 02 min
Login DN: cn=admin,dc=example,dc=com
Password: Use the admin password configured earlier.

Step 4: Install LDAP Account Manager on Ubuntu 20.40|18.04 LTS – Recommended

I noticed phpLDAPadmin doesn’t work well with PHP 7 which is a default version of PHP on Ubuntu 20.04|18.04. I recommend you use LDAP Account Manager instead. Follow our guide below to install and configure LDAP Account Manager on Ubuntu 20.04|18.04.

How to install and configure LDAP Account Manager on Ubuntu

The guide also shows you how to add user accounts and groups to your LDAP server.

Step 6: Configure your Ubuntu 20.04|18.04 as LDAP Client

The last step is to configure the systems in your network to authenticate against the LDAP server we’ve just configured:

How to configure Ubuntu as LDAP Client

Wrapping Up

Thanks for installing and configuring your LDAP authentication environment using our guides. Until next time, I want to thank you for visiting. Don’t forget to follow us on social media to get the latest updates.

As an appreciation for the content we put out,
we would be thrilled if you support us!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here