I'm done with managing IP addresses in use in an Excel sheet and decided to look for a IPAM solution.
Windows has an IPAM solution for free that comes as a role in the server OS and it integrates with your DHCP servers. However, it doesn't seem it shows VLAN's very well.
This is why I chose PHP ipam.
PHP ipam doesn't support the latest PHP server version, it takes several months before it's supported. It is possible to just install it, PHP ipam will warn you about this and tells you what you need to configure to make it work with an unsupported PHP version.
This article will guide you step by step in installing PHP on a Ubuntu Server.
- Install MariaDB with the following command:
sudo apt install mariadb-server mariadb-client
- Once installed enable and start MariaDB with the following command:
sudo systemctl enable mariadb && sudo systemctl start mariadb
- Now lets start securing the DB by entering the following command:
sudo mysql_secure_installation
Most likely a root password has already been set so you do not have to create a new one. Most of the question anwsers are based on your situation.
If you want to remotely access the DB then allow it. If you want to keep the test DB's for something then keep that as well or else delete it. - Now it's time to create a database, first enter the following command:
sudo mysql -u root -p
- Now enter the lines below one by one
- CREATE DATABASE phpipam;
- GRANT ALL ON phpipam.* TO phpipam@localhost IDENTIFIED BY 'YOURPASSWORDHERE';
- FLUSH PRIVILEGES;
- QUIT;
- Now it's time to install PHP, if the latest version is supported, use the following command to install PHP and move on to step 12 :
sudo apt -y install php php-{mysql,curl,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,mbstring,gmp,json,xml,fpm}
If the latest version is not supported go to step 7. - By default Ubuntu doesn't support installation of older PHP versions. You need to add a new source and repository to make it happen.
Add additional software sources with the following command:sudo apt -y instal software-properties-common
- Add the php repository soyou can install older versions of php with:
sudo add-apt-repository ppa:ondrej/php
- Update the package manager with the changes you made by entering
sudo apt-get update
- Now install the last supported version of PHP with the following command:
sudo apt -y install php(versionnumber)
For example,sudo apt -y install php7.4
for version 7.4 - Once the correct version of PHP is installed, it's time to install the modules, do this with the following command:
sudo apt -y install php-{mysql,curl,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,mbstring,gmp,json,xml,fpm}
- Finally it's time to install PHP ipam, use the following commands one by one
sudo apt -y install git
sudo git clone --recursive https://github.com/phpipam/phpipam.gi /var/www/html/phpipam
- Navigate to the directory where PHP ipam is installed with
cd /var/www/html/phpipam
- Copy the template config file with the following:
sudo cp config.dist.php config.php
- Now we need to make some changes in the config file, first open it with
sudo nano config.php
- The first thing you see should be the connection details, in the $db['pass'] line enter the password you created in step 5. The rest of the settings can be left as is, if you havn't changed them that is during the creation of the database.
- PHP Ipam works with Apache2 as well as NGINX. This guide only covers NGINX because that is my prefered solution.
Install NGINX with the following command:sudo apt -y install nginx
- If Apache2 also came installed, then you need to disable it, use the following command:
sudo systemctl stop apache2 && sudo systemctl disable apache2
- Now we need to configure the NGINX settings, use the following command:
sudo nano /etc/nginx/conf.d/phpipam.conf
- Copy the settings below to the NGINX config file, just make sure to change the server_name to something you will use to reach the PHP ipam interface. this can be a FQDN, IP address or webaddress.
server {
listen 80;
# root directory
server_name ipam.example.com www.ipam.example.com;
index index.php;
root /var/www/html/phpipam;location / {
try_files $uri $uri/ /index.php$is_args$args;
}location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
} - Change the ownership of the www directory with the following command:
sudo chown -R www-data:www-data /var/www/html
- To apply the new settings we need to restart NGINX, use this command:
sudo systemctl restart nginx
- Now go to your PHP ipam webpage, you should be welcomed by a first time configuration page
- Select 1. new phpipam installation > 2. MySQL/mariaDB Impot instructions
- It should list a few steps with instructions how to configure your DB. Most of this has been done in the previous steps.
All you need to do is look at step 3 and copy the command listed there in your Ubuntu server.
The command should look like this:sudo mysql -u root -p phpipam < /var/www/html/phpipam/db/SCHEMA.sql
- Once done with step 25, click on the login button
- You can now login with the default credentials admin + ipamadmin