How to Install phpIPAM – Nginx – Ubuntu 20.04
Notes:
- phpIPAM Website: phpIPAM IPAM IP address management software
- This guide is how I typically install phpIPAM on Ubuntu 20.04 using Nginx as the webserver.
Guide:
Update the server.
apt update && apt-get -y upgrade
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.)
We’ll stop apache2 from running and disable it on startup.
systemctl stop apache2 && sudo systemctl disable apache2
Enable the mariadb service on system start up as well as start it.
systemctl enable mariadb && systemctl start mariadb
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.
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.
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.
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.
Change to the installation directory.
cd /var/www/html/phpipam
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.
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.
Save the file “ctrl + x” if using nano.
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; } }
- Modify the “server_name” to the IP or the DNS name of the server.
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.
Restart the Nginx service to apply all the changes we’ve made.
systemctl restart nginx
Browse to the IP/DNS name of the server.
Select “New phpipam install”
Select “MySQL import instructions”
Copy option #4 and enter that command into the CLI of the server.
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.
Leave a Reply
You must be logged in to post a comment.