No module Published on Offcanvas position

Installing PHP ipam on Ubuntu with MariaDB

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.

  1. Install MariaDB with the following command: sudo apt install mariadb-server mariadb-client
  2. Once installed enable and start MariaDB with the following command: sudo systemctl enable mariadb && sudo systemctl start mariadb
  3. 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.
  4. Now it's time to create a database, first enter the following command: sudo mysql -u root -p
  5. Now enter the lines below one by one
    • CREATE DATABASE phpipam;
    • GRANT ALL ON phpipam.* TO phpipam@localhost IDENTIFIED BY 'YOURPASSWORDHERE';
    • FLUSH PRIVILEGES;
    • QUIT;
  6. 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.
  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
  8. Add the php repository soyou can install older versions of php with: sudo add-apt-repository ppa:ondrej/php
  9. Update the package manager with the changes you made by entering sudo apt-get update
  10. 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
  11. 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}
  12. Finally it's time to install PHP ipam, use the following commands one by one
    This installs PHP ipam in the /var/www/html directory, if you want you can change this.
  13. Navigate to the directory where PHP ipam is installed with cd /var/www/html/phpipam
  14. Copy the template config file with the following: sudo cp config.dist.php config.php
  15. Now we need to make some changes in the config file, first open it with sudo nano config.php
  16. 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.
  17. 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
  18. If Apache2 also came installed, then you need to disable it, use the following command: sudo systemctl stop apache2 && sudo systemctl disable apache2
  19. Now we need to configure the NGINX settings, use the following command: sudo nano /etc/nginx/conf.d/phpipam.conf
  20. 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;
        }
    }

  21. Change the ownership of the www directory with the following command: sudo chown -R www-data:www-data /var/www/html
  22. To apply the new settings we need to restart NGINX, use this command: sudo systemctl restart nginx
  23. Now go to your PHP ipam webpage, you should be welcomed by a first time configuration page
  24. Select 1. new phpipam installation > 2. MySQL/mariaDB Impot instructions
  25. 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 
  26. Once done with step 25, click on the login button
  27. You can now login with the default credentials admin + ipamadmin