How To Get Latitude And Longitude From City Name In PHP

This is a quick and easy way to find out latitude and longitude information of a specific city in PHP, using the Google Maps API.

Continue reading

Using the CSS text-transform Property Is Good

We should always try sticking to the three-layer model of web development:

  • The structure and content layer: HTML
  • The presentation and design: CSS
  • The behavior: Javascript

This makes for easily maintainable web pages, better performance thanks to caching and increased re-usability since you have everything in a specific file and this makes it easy to move it somewhere else.

Continue reading

Install phpIPAM on Apache

A few days ago I discovered a nifty little web app called phpIPAM (short for PHP IP Address Management). The name pretty much gives it away, but from the developers’ own words:

Its goal is to provide light, modern and useful IP address management.

And honestly, it manages to do that extremely well. It has a bunch of different features, but one of my favourite ones is the visual representation of a subnet:



I was about to create the typical Excel spreadsheet with all the IP information since the number of servers in my home network has now reached a point where I tend to forget some of the IP addresses I am using, but then I found this web app and I decided to give it a try, but I think I will keep using it for a while.

Also, installing it is super quick and easy. I will go ahead and assume that you already have the following:

  • Apache (2.2 or 2.4)
  • PHP5
  • MySQL

Basically, a full LAMP stack on your machine.

Install phpIPAM

  1. Install the necessary PHP extensions:
    sudo apt-get install php5-gmp php-pear
  2. Enable mod_rewrite in Apache:
    sudo a2enmod rewrite
  3. Restart Apache to enable this change:
    sudo service apache2 restart
  4. Change to your web server’s root directory (by default, /var/www):
    cd /var/www
  5. Create a directory for phpIPAM:
    sudo mkdir phpipam
  6. Download phpIPAM to this directory:
    sudo wget http://sourceforge.net/projects/phpipam/files/phpipam-1.1.tar
  7. Unpack it:
    tar -xvf phpipam-1.1.tar
  8. Edit config.php:
    1. Enter your DB details
      $db['host'] = "localhost";
      $db['user'] = "your_db_user";
      $db['pass'] = "your_db_user_password";
      $db['name'] = "phpipam";
    2. Set the base folder to phpipam:
      define('BASE', "/phpipam/");
  9. Edit .htaccess to set the base folder here as well:
    RewriteBase /phpipam/
  10. Remove the tar file:
    rm phpipam-1.1.tar
  11. Access webserver_ip/phpipam and complete the installation procedure (essentially just creating the database). You can let the installer itself take care of the creation of the database though, if you just enter the DB username and password.

Enable Apache and PHP on Mac OS X Yosemite, the Quick Reference

I don’t know about you, but sometimes all I need is a quick refresh to my memory on how to do something, and I don’t need complete, in-depth instructions. Those times, I don’t want to scroll through long instructions, I just need some precise information, and I need it quick. This is why I wrote this quick post to be used as a reference for myself, and I thought that other people might find it useful too.

Note: if you would prefer in-depth instructions on this, I will refer you to the articles linked at the end of this post. They really cover everything there is to know about the topic and I wouldn’t be able to add any other useful information.

If you want to do some local web development on a Mac, you have two options: you either use a full stack like MAMP, or you enable Apache and PHP and install MySQL only. On Mac OS X, Apache and PHP are already installed, and it’s only a matter of enabling them.

Enable Apache

Technically, Apache doesn’t even need to be enabled, it just needs to be started:

sudo apachectl start

Enable PHP

To enable PHP you need to edit the httpd.conf file (/etc/apache2/). Specifically, you need to uncomment the following line:

LoadModule php5_module libexec/apache2/libphp5.so

And then run:

sudo apachectl restart

Now, this is all you need to do to be up and running: if you visit http://localhost you will see the Apache default page.

[Optional] Bring back the Sites folder

If you stopped at the previous step, you would use the default system-wide Apache folder: /Library/WebServer/Documents/. If you prefer to have a user-level folder instead, there are a few extra steps to follow.

  1. Uncomment #LoadModule userdir_module libexec/apache2/mod_userdir.so from httpd.conf
  2. Uncomment #Include /private/etc/apache2/extra/httpd-userdir.conf from httpd.conf
  3. Uncomment #Include /private/etc/apache2/users/*.conf from http-userdir.conf (which you can find under /etc/apache2/extra/httpd-userdir.conf)
  4. Create a Sites folder inside your home folder
  5. Create a <your_username>.conf file inside /etc/apache2/users/
  6. Copy and paste the following code inside the conf file

<Directory "/Users/<your_username>/Sites/">
    Options FollowSymLinks Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    Require local

Restart Apache and you are good to go.

For more in-depth instructions on how to do this, have a look at the following two excellent articles:

© 2018 Daniel's TechBlog

Theme by Anders NorénUp ↑

%d bloggers like this: