Rusty's Database

Rusty's Technical Adventures

phpIPAM Installation – Ubuntu 20.04 LTS

How to Install phpIPAM – Nginx – Ubuntu 20.04

Notes:

Guide:

  1. Update the server.

    apt update && apt-get -y upgrade
    
  2. Install the necessary requirements.

    apt -y install mariadb-server mariadb-client php php-{mysql,curl,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,mbstring,gmp,json,xml,fpm,ldap} nginx
    
  • This command will download/install the necessary php modules, along with mariadb (sql database), and the webserver application (nginx.)
  1. We’ll stop apache2 from running and disable it on startup.

    systemctl stop apache2 && sudo systemctl disable apache2
    
  2. Enable the mariadb service on system start up as well as start it.

    systemctl enable mariadb && systemctl start mariadb
    
  3. Run through the “mysql_secure_installation”

    mysql_secure_installation
    
    • If this is a fresh install, there is no root password so hit “enter”
    • Hit “y” to create a root password.
    • After creating the root password, hit “y” through the next four prompts. This removes default users/databases and disables remote access to the SQL Database.
  4. Access the SQL Database using the password that was just created.

    mysql -u root -p
    
    • The “-u” flag tells mysql what user to log in with, this example the user is “root”
    • The “-p” flag states there is a password associated with the user.
  5. Create the database along with the password and privileges.

    CREATE DATABASE phpipam;
    GRANT ALL ON phpipam.* TO phpipam@localhost IDENTIFIED BY 'securepassword';
    FLUSH PRIVILEGES;
    QUIT;
    
    • There are several variables that can be changed, however, the most important is to change securepassword to a secure password to protect the IPAM Database.
  6. Download phpIPAM from the github repository.

    git clone --recursive https://github.com/phpipam/phpipam.git /var/www/html/phpipam
    
    • The directory can be changed, but for simplicity, we’ll leave it default.
  7. Change to the installation directory.

    cd /var/www/html/phpipam
    
  8. Copy the config file.

    cp config.dist.php config.php
    
    • config.php is technically missing, so by copying the config.dist.php file, we not only have a backup of the default settings, but we also create the “missing” config.php file.
  9. Edit “config.php”

    nano config.php
    
    • Use whichever text editor you use to change the database connection details at the top of the document. If following this guide, the only line that needs to be changed is the password. Example: “$db[‘pass’] = ‘phpipamadmin’;” to “$db[‘pass’] = ‘securepassword’;” Where securepassword is the password created during the creation of the SQL Database.
  10. Save the file “ctrl + x” if using nano.

  11. Next we’ll have to create the Nginx Server configuration file

    nano /etc/nginx/conf.d/phpipam.conf
    
    • Modify the “server_name” to the IP or the DNS name of the server.
      server {
          listen       80;
          # root directory
          server_name 10.10.10.10;
          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;
              }
      
       }
      
  12. Change the permissions of the “/var/www/html” directory.

    chown -R www-data:www-data /var/www/html
    
    • The “-R” changes the permissions recursively. Meaning the permissions of all files within the “html” directory will be changed.
  13. Restart the Nginx service to apply all the changes we’ve made.

    systemctl restart nginx
    
  14. Browse to the IP/DNS name of the server.

  15. Select “New phpipam install”

  16. Select “MySQL import instructions”

  17. Copy option #4 and enter that command into the CLI of the server.

  18. Now we can login

    • The default user/pass is admin/ipamadmin
    • After logging in for the first time, you’ll be required to change the password of the admin account. Once this is complete, the installation is done.

There are several other items that should be taken care of such as Firewall rules and SSL. But this is a basic installation of phpIPAM. The application is now functional to be tested or configured for production use.


Comments

Leave a Reply