{"id":505,"date":"2016-05-08T20:46:21","date_gmt":"2016-05-09T00:46:21","guid":{"rendered":"https:\/\/ithinkvirtual.com\/?p=505"},"modified":"2018-02-10T09:53:56","modified_gmt":"2018-02-10T14:53:56","slug":"installing-phpipam-on-ubuntu-16-04","status":"publish","type":"post","link":"https:\/\/ithinkvirtual.com\/2016\/05\/08\/installing-phpipam-on-ubuntu-16-04\/","title":{"rendered":"Installing phpIPAM on Ubuntu 16.04"},"content":{"rendered":"
I have been thinking, for a while now, about deploying an IP Address Management (IPAM) system in my Home Lab environment to keep track of my assigned addresses across my various VLANs. \u00a0In looking for the right solution, I came across many different choices, from Infloblox to Microsoft’s very own IPAM feature within Microsoft Windows Server 2012 R2. \u00a0I read many articles, and kept seeing rave reviews and tons of praise about phpIPAM<\/a> and that it was simple to install and get it running (at least that’s how it’s advertised). \u00a0I went to the phpIPAM website to lookup more information and noticed they have an installation guide<\/a> available. \u00a0Upon observing it, I quickly became disappointed at the lack of detailed instructions to actually deploy it on a system. \u00a0I guess they assume everyone has adequate knowledge of Linux operating systems, but myself personally, I’m still pretty novice at Linux and am looking to become more proficient with it. \u00a0I figured this is a good opportunity to get some hands-on Linux experience since I already knew how to, at the ver least, install an OS! \u00a0<\/p>\r\n So like any normal “noob” at this, I started consulting “Mr. Google” searching for easy to follow guides on installing phpIPAM and stumbled across one that made it all look very simple (I will share all\u00a0links at the end of this post). \u00a0I spun up an Ubuntu VM and followed the guide precisely, step-by-step, and was disappointed when I could not access the phpIPAM\u00a0installation web page. \u00a0After more searching, I stumbled on even more articles and each one used\u00a0different methods to get it to work properly. \u00a0I thought to myself, “there has to be an easier way to get this working right?” \u00a0<\/p>\r\n So after countless hours of trial and error, taking little tid-bits from several references, I managed to finally get phpIPAM successfully deployed and working on Ubuntu 16.04. \u00a0At this point, I figured it would be a great idea\u00a0to document my installation steps so that I can share my experience with all of you and hope that this guide will be of some\u00a0value. \u00a0Let’s get to it!<\/p>\r\n Prerequisites:<\/strong><\/em><\/p>\r\n For the purposes of this guide, I will not cover the actual OS installation steps and am confident that you can easily get an OS installed and running.<\/p>\r\n I will first configure the server with a LAMP configuration. \u00a0I began with a “vanilla” or shall I say “minimal” installation of Ubuntu Server 16.04 64-bit and I will be running all of the commands as the root user. \u00a0Having had Linux installed and\u00a0my server ready means that the “L” part of the “LAMP” configuration is already done. \u00a0FYI<\/strong><\/em> – features\u00a0that define a LAMP<\/strong><\/em> configuration and be installed in any order.<\/p>\r\n \u00a0<\/a><\/p>\r\n Log in with your local account then enter:<\/p>\r\n \u00a0<\/a><\/p>\r\n First, I updated apt-get by running:<\/p>\r\n \u00a0<\/a><\/p>\r\n Once completed, we will move on to the “M” phase of the configuration and install the MySQL<\/strong> database. \u00a0I chose to use MariaDB<\/strong> instead of MySQL<\/strong> as I’ve read there are many performance improvements over MySQL.<\/p>\r\n To install MariaDB, run the following:<\/p>\r\n \u00a0<\/a><\/p>\r\n When the components have finished installing, we can set a root password for MariaDB by entering the following:<\/p>\r\n <\/a><\/p>\r\n You will then be asked the following series of questions:<\/p>\r\n Next, test the login to MariaDB by entering the following:<\/p>\r\n Enter the root users password that you previously configured. \u00a0If successful, you should see a screen similar to this:<\/p>\r\n <\/a><\/p>\r\n To exit MariaDB, type quit<\/strong><\/em> and press Enter<\/strong><\/em><\/p>\r\n <\/p>\r\n Now, I have just completed the “M” phase of our LAMP configuration and can move on to the “A” phase and install Apache2.<\/p>\r\n To install apache2, simply run the following command:<\/p>\r\n <\/a><\/p>\r\n When that has finished, test apache to make sure it works by opening a web browser and browse\u00a0to\u00a0the VM’s IP or FQDN (http:\/\/ipaddress<\/strong><\/em> or http:\/\/FQDN<\/strong><\/em>). \u00a0I will use Google Chrome and access it via hostname (FQDN) since I’ve created the DNS record already.<\/p>\r\n <\/a><\/p>\r\n Success! \u00a0This now completes the “A” phase of the LAMP configuration and I can now move on to the final “P” phase by installing PHP7.0<\/p>\r\n I will begin by simply installing php7.0 and the Apache2 php module. \u00a0To do this, enter the following:<\/p>\r\n <\/p>\r\n <\/a><\/p>\r\n When that finishes,\u00a0restart apache by running:<\/p>\r\n To test that PHP7.0 installed successfully, I will make an info.php file in the web server directory by running the following:<\/p>\r\n <\/a><\/p>\r\n You can also use nano<\/strong><\/em> instead of vi<\/strong><\/em> or vim<\/strong><\/em>. \u00a0Then I add the following lines by first pressing “I<\/strong>” for “I<\/strong>nsert<\/strong><\/em>“<\/p>\r\n <\/a><\/p>\r\n Save the file by pressing “esc<\/strong><\/em>” followed by “Shift :<\/strong><\/em>” then type the letters\u00a0“wq<\/strong><\/em>” and press Enter.<\/strong> \u00a0Next, run the following command to change ownership of the file:<\/p>\r\n <\/a><\/p>\r\n Now, I can test to ensure PHP is running under Apache2 by opening a web browser and navigating to the IP or FQDN \/info.php<\/strong><\/em> link (http:\/\/ipaddress\/info.php<\/strong><\/em> or http:\/\/FQDN\/info.php<\/strong><\/em>). \u00a0If successful, you should see a page like this.<\/p>\r\n <\/a><\/p>\r\n Perfect! \u00a0Now I will add some additional php modules that will be needed for phpIPAM to work along with some others to add support for MariaDB. \u00a0I’ll start with the following command to list the available php7.0 modules.<\/p>\r\n I’ll then install the necessary php modules that are needed by phpIPAM to add support for the database (MariaDB<\/strong><\/em>) by entering the following (some of them may have already been installed via php 7.0 installation earlier) :<\/p>\r\n <\/a><\/p>\r\n Restart apache2 by running:<\/p>\r\n Point your web browser to the \/info.php<\/strong><\/em> page again and reload it. \u00a0If all is well, you should see the new modules installed along with “mysqli<\/strong>“. \u00a0Now I know that MariaDB is supported in my php 7.0 installation<\/p>\r\n <\/a><\/p>\r\n At this point, I have finished the “P” phase in the LAMP configuration and can move on to installing phpIPAM. \u00a0But before doing that, I want to add a few extra modules to my PHP configuration to make it run faster via APCU, and to add support for PHPMyAdmin and SSL.<\/p>\r\n Start by entering the following to speed up PHP<\/p>\r\n Then restart apache2 with<\/p>\r\n <\/a><\/p>\r\n If you want to ensure it’s installed and running, again load the \/info.php<\/strong><\/em> site in your web browser and look for the following<\/p>\r\n <\/a><\/p>\r\n If you’d like, and for security concerns, you can delete the info.php<\/strong><\/em> at this time by running\u00a0<\/p>\r\n Now, I am going to enable SSL so that I have (https:\/\/<\/strong><\/em>) access to my web server as well. \u00a0Do this by running the following:<\/p>\r\n Then restart apache2 again with<\/p>\r\n <\/a><\/p>\r\n Test it\u00a0by launching your apache web server link in your web browser using (https:\/\/ipaddress<\/strong><\/em> or https:\/\/FQDN<\/strong><\/em>)<\/p>\r\n <\/a><\/a><\/p>\r\n The last thing to officially complete my “P” phase of my LAMP configuration is to install phpMyAdmin to allow me to manage my database easily from a web browser. \u00a0To install, enter:<\/p>\r\n <\/a><\/p>\r\n You will be presented with the following screen. \u00a0Select the “apache2<\/strong><\/em>” option by pressing the “space bar<\/strong><\/em>” on the highlighted object, and press Enter<\/strong>.<\/p>\r\n \u00a0<\/a><\/p>\r\n Next, you will be presented with this screen. \u00a0Select “Yes<\/strong><\/em>” and press Enter<\/strong>.<\/p>\r\n \u00a0<\/a><\/p>\r\n On this next screen, just press Enter<\/strong> as a random password will be generated for the phpmyadmin account<\/p>\r\n \u00a0<\/a><\/p>\r\n Next, I need to explicitly enable “crypt<\/strong><\/em>” and “mbstring<\/strong><\/em>” or the web page will not load properly. \u00a0Do this by running the following:<\/p>\r\n Then, restart apache 2 again with:<\/p>\r\n <\/a><\/p>\r\n And the final command to finish the installation is to run the following:<\/p>\r\n <\/a><\/p>\r\n Test phpMyAdmin by navigating to the web server \/phpmyadmin<\/strong><\/em> page (http(s):\/\/ipaddress\/phpmyadmin<\/strong><\/em> or http(s):\/\/FQDN\/phpmyadmin<\/strong><\/em>). \u00a0The login is root<\/strong><\/em>\u00a0and the database password you created earlier.<\/p>\r\n <\/a><\/p>\r\n Excellent! \u00a0Now, my LAMP configuration is complete and I can start with the phpIPAM configurations and installation.<\/p>\r\n Since I’ve already installed all of the required modules, the next thing to do is download the phpipam file and then extracting it to the web servers directory (\/var\/www\/html<\/strong><\/em>). \u00a0Start by changing over to the \/tmp<\/strong><\/em> directory<\/p>\r\n Next, download phpipam. \u00a0I am using the latest version which, at the time of this writing, is phpipam-1.2.1.tar<\/strong><\/em><\/p>\r\n <\/a> <\/a><\/p>\r\n Extract the file to the web server directory:<\/p>\r\n <\/a><\/p>\r\n The files have been extracted to a new folder at \/var\/www\/html\/phpipam<\/strong><\/em>. \u00a0Now we need to edit the config.php<\/strong><\/em> file in that directory. \u00a0But there is no such file so we have to create it by copying the default config.dist.php<\/strong> file to config.php<\/strong>. \u00a0Do this by running:<\/p>\r\n <\/a><\/p>\r\n Now we can edit this file with vim, vi, or nano:<\/p>\r\n <\/a><\/p>\r\n By default, the file will look like this and I will need to change the following selections:<\/p>\r\n <\/a> <\/a><\/p>\r\n I will make the following changes before saving and exiting the file:<\/p>\r\n <\/a> <\/a><\/p>\r\n Since I have defined the ‘BASE’<\/strong>, it also explicitly said to change this in the .htaccess<\/strong><\/em> file. \u00a0To open and edit this file, enter:<\/p>\r\n <\/a><\/p>\r\n By default, the file looks like this and I will be changing the following line<\/p>\r\n <\/a><\/p>\r\n To look like this before saving and exiting the file:<\/p>\r\n <\/a><\/p>\r\n Next, I will edit the default apache web file (000-default.conf<\/strong><\/em>) by entering:<\/p>\r\n <\/a><\/p>\r\n By default it looks like this:<\/p>\r\n\r\n\t
\r\n\t
\r\n\t
\r\n\t
\r\n\t
sudo su<\/pre>\r\n
apt-get update<\/pre>\r\n
apt-get -y install mariadb-server mariadb-client wget<\/pre>\r\n
mysql_secure_installation<\/pre>\r\n
\r\n\t
mysql -u root -p<\/pre>\r\n
apt-get -y install apache2<\/pre>\r\n
apt-get -y install php7.0 libapache2-mod-php7.0<\/pre>\r\n
systemctl restart apache2<\/pre>\r\n
vim\u00a0\/var\/www\/html\/info.php<\/pre>\r\n
<?php\r\nphpinfo();\r\n?><\/pre>\r\n
chown www-data:www-data\u00a0\/var\/www\/html\/info.php<\/pre>\r\n
apt-cache search php7.0<\/pre>\r\n
apt-get -y install php7.0-cli php7.0-curl php7.0-gmp php7.0-json php7.0-ldap php7.0-mcrypt php7.0-mysql php7.0-xml php-pear<\/span><\/pre>\r\n
systemctl restart apache2<\/pre>\r\n
apt-get -y install php-apcu<\/pre>\r\n
systemctl restart apache2<\/pre>\r\n
rm -f\u00a0\/var\/www\/html\/info.php<\/pre>\r\n
a2enmod ssl\r\na2ensite default-ssl<\/pre>\r\n
systemctl restart apache2<\/pre>\r\n
apt-get -y install phpmyadmin\u00a0php-mbstring php-gettext<\/pre>\r\n
phpenmod mcrypt\r\nphpenmod mbstring<\/pre>\r\n
systemctl restart apache2<\/pre>\r\n
echo \"update user set plugin='' where User='root'; flush privileges;\" | mysql --defaults-file=\/etc\/mysql\/debian.cnf mysql<\/span><\/pre>\r\n
cd \/tmp<\/pre>\r\n
wget https:\/\/sourceforge.net\/projects\/phpipam\/files\/phpipam-1.2.1.tar<\/pre>\r\n
tar -xvf phpipam-1.2.1.tar -C \/var\/www\/html<\/pre>\r\n
cp \/var\/www\/html\/phpipam\/config.dist.php \/var\/www\/html\/phpipam\/config.php<\/pre>\r\n
vim \/var\/www\/html\/phpipam\/config.php<\/pre>\r\n
vim \/var\/www\/html\/phpipam\/.htaccess<\/pre>\r\n
vim \/etc\/apache2\/sites-available\/000-default.conf<\/pre>\r\n