phpIPAM is a free and open-source IP address management system. It is written in PHP and uses a MySQL database server to store its data. It is a light, modern and easy to use system. It provides numerous features like IPv4/IPv6 IP address management, Domain authentication (AD, LDAP, Radius), VLAN, VRF and Subnet management, PowerDNS integration, NAT support, email notifications etc.
In this tutorial, we will install phpIPAM on CentOS 7 server.
phpIPAM does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run
sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.
yum -y install httpd mariadb-server mariadb
phpIPAM can be installed on any version of PHP greater than 5.3. But as PHP 5.3 has reached the end of life. We will install PHP 7 to obtain high performance. PHP 7 is not included in default YUM repository, hence you will need to add the Webtatic repository in your system. Webtatic repository requires EPEL repository to work. Run the following command to install EPEL repository.
yum -y install epel-release
yum -y update
Now install Webtatic repository using the following commands.
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update
To install PHP 7.1 and all the required PHP modules, run the following command.
yum -y install php71w php71w-cli php71w-session php71w-sockets php71w-gmp php71w-mcrypt php71w-simplexml php71w-json php71w-gettext php71w-filter php71w-pcntl php71w-mbstring php71w-gd php71w-common php71w-ldap php71w-pdo php71w-pear php71w-snmp php71w-xml php71w-mysql git
Once you have PHP installed, you can check the version of PHP using the following command.
You should get output similar to this.
[root@liptan-pc ~]# php -v PHP 7.1.4 (cli) (built: Apr 15 2017 08:07:03) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
You will also need to make a change into PHP configuration file
/etc/php.ini using your favorite editor.
If you do not have nano installed, you can install it using
yum -y install nano. Scroll down to find the following lines.
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =
Remove the semicolon from the start of the line and provide the appropriate time zone. For example:
date.timezone = Asia/Kolkata
Now start the Apache web server and enable it to start at boot time using the following command.
systemctl start httpd
systemctl enable httpd
To start MariaDB and enable it to start at boot time using the following commands.
systemctl start mariadb
systemctl enable mariadb
Now run the following commands to secure your MySQL or MariaDB installation.
It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose
y and set a strong password for the installation. It will also ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer
y to all the questions.
To create a database we will need to login to MySQL command line first. Run the following command for same.
mysql -u root -p
This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your phpIPAM installation.
CREATE DATABASE phpipam_data;
The above query will create a database named
phpipam_data. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.
CREATE USER 'phpipam_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username
phpipam_user. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.
GRANT ALL PRIVILEGES ON phpipam_data.* TO 'phpipam_user'@'localhost';
Now run the following command to immediately apply the changes on the database privileges.
Exit from MySQL prompt using
As we have all the dependencies ready, we can now download the install package from GitHub.
git clone https://github.com/phpipam/phpipam.git
git checkout 1.2
The above command will checkout the latest stable version.
Now you will need to disable your SELinux. To temporary disable SELinux, run the following command.
To completely disable the SELinux you will need to edit
Find the following line:
Change it to:
Now, you will need to provide the ownership of the application to web server user using the following command.
chown -R apache:apache /var/www/phpipam
You will need to configure the database connection now. Copy the example configuration file to default file using following command.
cp config.dist.php config.php
Now edit the file using your favorite text editor.
You will find the following lines at the top of the file.
/* database connection details ******************************/ $db['host'] = "localhost"; $db['user'] = "phpipam"; $db['pass'] = "phpipamadmin"; $db['name'] = "phpipam"; $db['port'] = 3306;
Change the database username, password, and name according to the database and user created earlier. For example, the configuration should look like the below.
/* database connection details ******************************/ $db['host'] = "localhost"; $db['user'] = "phpipam_user"; $db['pass'] = "StrongPassword"; $db['name'] = "phpipam_data"; $db['port'] = 3306;
You may also need to allow HTTP traffic on port
80 through the firewall if you are running one. Run the following commands for same.
firewall-cmd --zone=public --permanent --add-service=http
Now create a virtual host for the phpIPAM application. Run the following command for same.
Paste the following lines into the file.
<VirtualHost *:80> ServerAdmin email@example.com DocumentRoot "/var/www/phpipam" ServerName phpipam.yourdomain.com ServerAlias www.phpipam.yourdomain.com <Directory "/var/www/phpipam"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog "/var/log/httpd/phpipam.yourdomain.com-error_log" CustomLog "/var/log/httpd/phpipam.yourdomain.com-access_log" combined </VirtualHost>
phpipam.yourdomain.com with any domain or sub-domain you want to use to access the application. Save the file and exit from the editor. Run the following command to restart your Apache server.
systemctl restart httpd
Now complete the installation using a web browser, go to the following link using your favorite web browser.
You will be welcomed by the following page.
Click on Automatic database installation button. In next interface, you will need to provide the MySQL username and password of the database you have entered in
config.php. Click on Show advanced options button and uncheck all the options as we have already created the database and set appropriate permissions.
Now click on Install phpipam database button, the installer will install the database now. The installation is now finished, you can access the admin panel now at the following URL.
You can now log in using the default username
Admin and password
ipamadmin. Once you are logged in, you will be asked to change your default password. After changing your password you can access your dashboard.
To enable automatic host availability and discovery check for a subnet, go to Administration >> IP related management >> Subnets. Now click on the Edit subnet icon corresponding to the subnet you wish to use. Toggle Yes button for Check hosts status and Discover new hosts. Select Localhost as network discovery agent.
Finally, add cron jobs to check for availability and discovery scripts to run at every 15 minutes.
Open crontab using the following command.
Now copy and paste following lines into the file:
*/15 * * * * /usr/bin/php /var/www/phpipam/functions/scripts/pingCheck.php */15 * * * * /usr/bin/php /var/www/phpipam/functions/scripts/discoveryCheck.php
In this tutorial, we learned how to install phpIPAM on CentOS 7. You can now successfully deploy the phpIPAM application to manage the network infrastructure of your organization.