Category Archives: Domain Names

Enabling Multiple Domain Names and Sites on Apache2 Server

Today I set up a new server and I am documenting exactly how to set up multiple domain names, sub domains and websites on a new Apache2 Server. I am using Ubuntu, but I believe these directions are similar for any Linux Apache2 web server.

Pointing your domain or sub-domain

It is a good practice to point your domain name or sub-domain first, before you set it up on your server which I'll cover afterwards below, so let's go ahead and point our domain. Whether you are using a new domain name or a sub-domain on one of your existing domain names, the process is similar for pointing the domain name or sub domain name to your server IP address. You will need to go to your domain management console and create a Type "A" record. This will normally be done in your DNS provider's advanced DNS settings or zone file settings. Use the following settings to create two new records:

  • Name: if there is a name field, enter the domain name or sub-domain name(most require you to follow the domain with a "." so for my sub domain I entered "".
  • Type: "A" for both records.
  • Hostname field: enter "www" in the first record and "@" in the second.
  • Destination IPv4 address(sometimes just called Address): Use your server's IP address for both records.
  • TTL: use "14400" for both records.

That should be enough information for you to figure out how to create your two host records on just about any platform, but if your platform differs, ask your provider for assistance or google the providers name followed by DNS instructions or "How to point a name with Provider Name". You are creating two similar records, one for WWW and one for @. That way visitors of your site can access with either or just The Hostname of @ makes the record for the domain without "www" in front of it. If your provider's DNS settings do not include the Host or Hostname field where we put either www or @, then you probably need to create two records with different names instead. For example, name one record "" and name the other "". If you're using a sub domain then name one "" and the other "" You don't really need a www record for sub domains usually, but you can use one if you want, it won't hurt anything and might help some users find your site.

Steps to adding  a second domain name to your server

Here I am going to explain how I set up a sub domain as as second domain name pointing to a second website on my Linux/Apache2 web server:

Note: My first site was already set up in var/www/html. Most people prefer to set up multiple websites under the var/www directory, but to keep things simple, I'm going to use the var/www/html folder and not var/www. It really makes no difference. It's just a preference.

  1. Create your directory structure for your new website that will reside on your new domain or sub-domain. I'm creating a sub domain like, but these directions are the same as if I were using just instead. First, create the directory /var/www/html/ Then create /var/www/html/ and /var/www/html/ If you are logged into FileZilla as root, you can create these from there, otherwise log in with putty and create them using the sudo command.
  2. Create your log files. Simple make two empty files named access.log and error.log and upload them to the logs folder you created in step one above.
  3. Create a VHOSTS file named after the domain or sub-domain followed by .conf, so in my case, I'd name my file THen copy and paste the  content below under the heading "VHOSTS Example File Contents" into it then change all instances of my sub-domain name with your own domain or sub domain and upload that file to /etc/apache2/sites-available.
  4. Next, use the a2ensite tool from the Linux command line to finalize the new site with the following command(replace with your domain or sub-domain):  sudo a2ensite
  5. Reset apache2 with: sudo service apache2 restart

VHOSTS Example File Contents

<Directory /var/www/html/>
    Require all granted
<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/

    ErrorLog /var/www/html/
    CustomLog /var/www/html/ combined

Automating the process of setting up domain names and sub domains

If you have to do this often or alter DNS records often and create lots of virtual hosts, you should probably look into automating the process. I provide such a service and have done so for several of my clients. What I do is create a simple user interface in a secure admin web page on your own server where you can simply enter the domain name or sub domain name into a form field and press GO and it does all the above work for you! A real time saver if you have to do this more than once in a great while! IF you are interested in this service, contact me, Ian L. of for a fast, free quote by email or Skype. My email is and my Skype name is ianlin11. Or use the contact link on this site.


That is how you do it!

NGINX New Site Creation and Server Configurations

Today I'm going to share with my readers my list for manually creating another website on one of my NGINX servers. I am partially logging this here for my own reference as I often look for these directions I keep stored in a .txt file on my laptop. Wherever you see text in green in this post, it will indicate that the text is to be entered as a command at the command prompt in Linux.

Step by Step Directions to Add a New Site on NGINX Servers

1) Sign into Linux server using an application like Putty (Windows) or Terminal (Mac):

Login with root user and password if possible, otherwise login with the user and password you have and remember to use sudo commands(purring sudo before each command line command)

2) Create the website directory (for example,

mkdir -p /var/www/
mkdir -p /var/www/

3) Change the ownership of the directory to the web user:
chown -R www-data:www-data /var/www/
chown -R www-data:www-data /var/www/

4) Create the web site config file. To do this, you can simply copy the config file of an existing site and then make the required changes. For example try this command but change the existing_site to your own existing website on your server:
cp /etc/nginx/sites-available/ /etc/nginx/sites-available/

5) Edit the new config file to replace with the new site’s values:

nano /etc/nginx/sites-available/
Edit the line that reads: root /var/www/ to be the current domain name.
Edit the two server_name instances to be the new domain name.
Edit access_log and error_log paths for new domain name
Save the file by hitting Ctrl-X, then Y and then Enter.

6) Enable the new site in NGINX:

ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

7) Restart NGINX:

service nginx restart

9) Create the database and user.

mysql -u root -p
create database database name;
(note: I often create the db and user with the same name as the domain name. That makes it easy to remember. However, MySQL users are limited to 16 characters. so if the domain name is longer, I truncate both in some fashion. Just make sure theu match.
grant all on your_new_site.* to 'your_new_site' identified by 'secret_password';
(the last part is the password. just make up a hard one - record this where only you can find it, you’ll need it with the restore)

8) Copy your new website files into the public_html folder with your sFTP client and your site is up and running!

Using PHP to create an NGINX SITE MAKER

I used the above knowledge to create a Site Maker tool that does all the steps for you. All you have to do is enter a domain name. Email me if interested at


So, this isn't too hard if you have something to reference such as the above cheat sheet. Once you get used it doing it, it is really easy. However if it's too complex, you can do what I did and make a tool to do it for you. Even if it's not too difficult, the tool saves you time if you add a lot of sites to your NGINX server as I do. Email me if you have interest in such a tool and I can custom build you one for your server! is my email.

Understanding IP Addresses

Have you ever needed to know how an IP Address works? Have perhaps just wondered how they worked? Well in my line of work it has eventually become necessary for me to fully understand exactly how IP addresses work and are made up. Therefore I aim to share my knowledge on such with anyone who cares to read about IP addresses here on my wonderful blog.

First of all it's important to know that IP addresses are displayed in what is known as dotted-decimal format. For example your current IP address is

For anyone Interested, I got your IP address using the following PHP code:

$ipaddress2 = $_SERVER[REMOTE_ADDR];
echo "<h3>Your Current IP Address: $ipaddress2</h3>";

Just notice the format of the IP address above for now though.

Two Main Parts of an IP Address

While an IP address appears to have 4 parts due to the dotted-decimal format used, in reality, IP addresses are made up of only two main parts. They are "Network ID" and "Host ID". The two parts are not equal or consistent. The Network ID is defined first and the Host ID will be the remaining portion of the IP address.

IP Address Classes

IP addresses are divided into different classes. There are actually five IP classes, but only three are in common use, they are Classes A,B, and C. Classes D and E are reserved classes. Class D is Reserved for Multicasting. Class E is Experimental; used for research. The three main classes are shown in the following examples:

  • Class A - Class A IP addresses use 8 bits for the Network ID(8 bits = 1 byte or 1 segment in dotted-decimal format or 1 octet). Class A addresses only include IP addresses from 1.x.x.x to 126.x.x.x. The IP range 127.x.x.x is reserved for loopback IP addresses. Therefore a Class A IP address might look like From what we know about the two parts of an IP address now, we know that the "19." portion of this example IP address defines the Network ID and the  remaining part(23.20.100) represents the Host ID.
  • Class B - Class B IP addresses use 16 bits for the Network ID(16 bits = 2 bytes or 2 segments in dotted-decimal format or 2 octets). The remaining 16 bits are used for the Host ID of course.
  • Class C - Class C IP addresses use 24 bits for the Network ID(24 bits = 3 bytes or 3 segments in dotted-decimal format or 3 octets). The remaining 8 bits are used for the Host ID in this case.

How to Determine IP Address Class

Determining whether an IP address belongs to class A, B or C can be a daunting task if you don't understand how IP addresses function. That is why I will explain it clearly here for you! First you need to realize that IP classes are determined by the first few bits of the IP address. Then you need to know that bits are not the same as the dotted-decimal format you are accustomed to! For example My IP address now shows as if I open this post in my current browser. What class does belong to? Well here is how I found out:

First, convert the dotted-decimal formatted IP address of to its binary form and count the bits. Actually, you can do just the first octet or 173 in this case. Here is how to convert a decimal octet to a binary Byte:

You divide the number(173 in this case) by 2 and take the answer with the remainder and note both. Then divide the answer by two and note the answer and remainder this eight times. Start at the top of a sheet of paper and move to a new line each time you start a new calculation.  Be sure to circle the remainder each time as those are the 8 bits that make up the Byte we are after. Here is my sloppy example of how I did it with my IP address that began with 173:

binarypaper_ink_li Notice that I circled the remainder after each division problem above. The final step is to start at the bottom and write each circled remainder down in order.

So from the image above, I get the binary number: 10101101

The first three bits of the binary 10101101 determine it's class. In my case, the first three bits are 101.

Then refer to the following table to determine your class:

  • CLASS A: the binary will begin with a zero.
  • CLASS B: the binary must start with 10.
  • CLASS C: the binary must start with 110.

So as you can see from the above table and the image above that, my IP address of converts to a binary number of 10101101 and can then be identified as a CLASS B IP address because its binary form begins with 10. Alot to do to figure out the class of an IP, but it is mostly for learning purposes that I have explained it all like I have. Really, all you have to do is refer to the following table of information which will allow you to convert it to a class using just the first octet of the IP address(173 in my case):

Quick & Easy Method to Determine IP Class

  • CLASS A: First 3 digits of the IP address will be from 0 to 127.
  • CLASS B: First 3 digits of the IP address will be from 128 to 191.
  • CLASS C: First 3 digits of the IP address will be from 192 to 223.

So again, my IP( starts with 173 so I can use the above three lines of data to confirm that it is indeed a CLASS C IP address because 173 falls in between 128 and 191.



How to change DNS settings on your local PC

Have you ever been working on a website, changed your DNS settings over to a different server and later needed to access that server again from the old domain name for some reason? Well if you are an active developer, this situation is somewhat common. I'll explain or you can skip the rest of this paragraph to quickly learn now to do it. Let's say you own the domain name and a web server with an IP address of Now assume you have a WordPress blog on that server that you had to move to another server with IP Let's say you already changed the DNS settings for to point to the new server with IP but you need to go back to the original WordPress site on the other server with an IP of What do you do? We all know a WordPress site won't function properly with just the IP address, so that is out. What you need to do is repoint to in order to access that WordPress site again. What a PITA, right? Well read on and I'll show you a fast and easy way to make the site on the original server work with even after you've pointed it to another IP address or web server! It's as simply as controlling a local host file on your local PC to make route to even though the internet routes it to! Here's how:

Using hosts file to override DNS settings for your PC

A lot of people don't realize that when you make a request to the Internet using your local computer it first checks a local copy of the hosts file for an entry and only if one isn’t present it goes out to the Internet DNS servers. Therefore there's an opportunity present for you to redirect only for your own PC if you wanted to! Here are the easy steps:

  1. Open file explorer and navigate to C:\Windows\System32\drivers\etc.
  2. Open the file named "hosts" in notepad or another text editor that could be used as a code editor such as Notepad++, which is what I use.
  3. Now simply add a line to the end of the hosts file that contains the IP address of the server you want to route the domain name too followed by a space and then the domain name you want to reroute. So in our example scenario above, you would enter a new line that reads simply:
  4. Save the hosts file and open your browser and navigate to the domain which in our example was Note that there is a difference between and, so if you want it to work with www, you have to add another entry for

If you're using Notepad++ or similar as I was, you'll need to open it in administrator mode in order to be able to save the hosts file. Good luck! That's all there is to it.

How to change local DNS settings on a Mac

If you're on a Mac, the instructions are basically the same but do this instead:

From the terminal, type:

nano /private/etc/hosts
and then add the IP and domain name as described above, so the only real difference between Mac and a PC when it comes to changing DNS settings is that you will use a different editor and the hosts file is located in different places.



How to Use IPTables

What is iptables?

iptables is a fairly flexible firewall system developed for Linux/Unix operating systems and used commonly for web server administrators to block access to servers by IP address or groups of IP addresses. It can also be used to white-list IP addresses as well. It is a command line tool that allows server administrators to enter simply one line commands to add, edit or delete rules for accessing the web server from the outside world.

Understanding iptables Infrastructure

Understanding the infrastructure of iptables in an important component to learning how to use iptables. Basically there are tables, chains and rules. Tables contain chains and chains contain rules. Here is a simple graphic to illustrate my point:


There are four default tables in iptables and you can add others if you want to get deep into config options. However, I recommend using the default tables to keep things simple. In fact, the filter table is the only one we will be messing with for now. The four default tables are filter, nat, mangle and raw.

  • Filter Table - default table for iptables. If you do not define a table, you’ll be using the filter table. The filter table has the following built-in chains:
    1. Input Chain - handles incoming connections.
    2. Output Chain - handles outgoing connections.
    3. Forward Chain - handles routing of connections like a router.
  • Nat Table - Consists of prerouting, postrouting and output chains. The prerouting chain helps translate destination ip address of the packets to match the routing on the local server. The postrouting chain translates packets as they leave the system and alters packets after routing. The output chain is NAT(Network Address Translation) for locally generated packets on the firewall.
  • Mangle Table - for specialized packet alteration. We will leave this table alone for now as it it outside the scope of this tutorial, but just know it is there.
  • Raw Table - for configuration exemptions. Raw table has a prerouting chain and an output chain.

Chain? WTF does my server need Chains for? Is it winter already?

When using iptables, there are basically three types of chains that we are mainly interested in. They are input chains, output chains and forward chains, the three chains from the filter table described above.

  • Input Chain - used to control the behavior of incoming connections. For example, if a user attempts to SSH into your server, iptables will attempt to match the IP address and port to a rule in the input chain.
  • Output Chain - used with outgoing connections. For example, if you try to ping, iptables will check its output chain to see what the rules are regarding ping and before making a decision to allow or deny the attempt to connect.
  • Forward Chain - used for incoming connections that aren’t delivered locally. It is something like a router where data is always being sent to it but is not destined for the actual router. Data is forwarded to its target. Unless you’re doing some type of routing or NATing  that requires forwarding, you probably won't use a forward chain much if at all.

Understanding iptables Commands

In order to use iptables in Linux, you need to know the basic commands, so I'll go over some of the more common iptables commands here for your learning pleasure!

Note that after you make any change, it is important to save iptables with the following command on Debian/Ubuntu servers:


or in some cases


The save command is a little different for other servers, so take note of the one that applies to your server as noted below:

  • Centos / Redhat: service iptables save or sudo service iptables save if you are not root user.
  • If that didn't work, try:  /etc/init.d/iptables save with and without sudo first.

If you don't save after a change by typing the above at your command prompt and hitting enter, you will most likely lose your changes and/or they will never take effect.

iptables Command to Block a Single Simple IP address

If you wish to simply block an IP such as from accessing your server in any way and from any port, type this at your command prompt and press enter, then save:

iptables -A INPUT -s -j DROP

Whenever possible, always test to be sure your iptables rules work after adding then to be safe. Be sure to save using the appropriate iptables save command as mentioned above after you successfully enter your new rule.

Blocking all IP addresses but your own with iptables

If your server is getting throttled and you want to lock it down immediately or you are simply under construction and don't want anyone but you to be able to access your server, here is how you can block all IP addresses from accessing your server and white-list just one or more IP addresses that will be able to access your server:

iptables -A INPUT -s -j ACCEPT
iptables -A OUTPUT -d -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT DROP

First, you should flush your current rules(see below). Then simply replace with your own IP address in the commands above and enter each of the four commands one at a time from the command line, pressing enter after each, then save iptables.

Flushing iptables rules

To get rid of all active rules in iptables, enter the following command at the Linux command prompt:

iptables -F

Deleting Single iptables Rules

If you entered one or more iptables rules you want to delete without deleting the entire configuration, here is how to do it:

  1. List numbered rules using this command: sudo iptables -L INPUT -n --line-numbers
  2. To delete the first rule enter: sudo iptables -D INPUT 1(where 1 is the line number you want to delete)
  3. Confirm deletion took place by running the first command again and verify the rule is no longer present: sudo iptables -L INPUT -n --line-numbers
  4. Save iptables to be safe: sudo iptables-save


Restrict Number of Connections Per IP

Use connlimit to place restrictions on the number of connections allowed per IP address. To allow 4 ssh connections per client host, enter:
# iptables -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 4 -j REJECT

Set HTTP requests to 20:
# iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 --connlimit-mask 24 -j DROP

  1. --connlimit-above 3 : Match if the number of existing connections is above 3.
  2. --connlimit-mask 24 : Group hosts using the prefix length. For IPv4, this must be a number between (including) 0 and 32.


What is this nonsense after the slash in iptables ip addresses?

This is what I need to touch on before we go much further because you've no doubt seen existing rules in your iptables with IP addresses listed similar to:

...and have surely wondered why there is a slash followed by a number after the ip addresses listed in your iptables rules. Well I'll explain as best as I can in the next section as it is a little complicated to explain...

Knowing how to read and write more complex iptables rules with CIDR notation.

Learning to write iptables rules can get very frustrating if you don't understand how the notation works. CIDR, Classless Inter Domain Routing notation, is often confused with network masks which are similar but not the same. I will offer my best explanation of CIDR notation here which I've gathered from several different sources to put together an explanation I feel comfortable with:

Imagine an IP address something like xxx.yyy.zzz.www/N, where N is the number of bits from 0 to 32. Each of the other numbers represents one byte out of the 4 bytes that make up an IP address. N says how many BITS of those 4 bytes matter. So any address that looks like 10.X.Y.Z/8 refers to ANY IP starting with "10.": 8 bits = 1 byte, meaning everything after the first byte is ignored. The convention is to use zeroes in the ignored positions, so the canonical name for that subnet is Most of the time, N is a multiple of 8, so it says to ignore a certain number of bytes.

Once in a while, you'll see something other than that, like a /29. This means that PART of one of the bytes is ignored. For simplicity's sake however, we will stick to multiples of 8 in this guide.

It's also important to note that if the N is omitted, then it's usually assumed to be 32, i.e. a single IP address specification.

So, taking what I've just explained above regarding CIDR notation, Here are some general examples of how netmasks work in conjunction with iptables rules:  - A CIDR of 8 bits means that only 1 of 4 possible bytes of the IP address is noted as represented by the "10" here. so this would cover the IP range from to In other words any IP address starting with "10.". - A CIDR of 16 means that 2 of 4 possible bytes of the IP address are noted as represented here by "100.50.". In this case, a range from to is covered. - A CIDR of 24 means that 3 of the 4 IP address bytes are noted as seen here with "92.50.8." This time a range from to is represented.

Those should be the three most common types of CIDR notations. Following the above pattern of incrementing the number of bits by 8, the next logical example would be something like While that is a perfectly good notation and will work, it is also moot because 32 bits would represent the entire IP address, so you might as well enter it without the CIDR notation(with no slash and number after the IP).  In iptables rules, means the exact same thing as simply putting

What do Bytes and Bits have to do with IP Addresses?

Good question, glad I asked myself! To properly understand how CIDR notation works you have to understand the math behind it. A Byte is made up of 8 bits(that's why we increment by 8 in our previous examples). An IP address is made up of 4 Bytes or 32 Bits(4x8=32).

As you probably know, an IP address is made of of four numbers separated by dots or periods(.) like this: N.N.N.N where N can be any number from 0 to 255. This raised a question in my mind: In an IP address byte, how does a range from 0 to 255 have 8 bits? Well my question just goes to show I don't fully understand how Bytes and Bits correspond with numbers because I googled around and discovered that indeed Eight binary bits can represent any whole number from zero to 255, so the segments of a dotted decimal address are decimal numbers with a range from 0 to 255.  I think it's enough for now to understand that it is correct without getting into exactly how Bytes and Bits work with IP addresses because I don't want this tutorial to confuse you even more. Let's just know for now that 1 Byte = 8 Bits and that a Byte can be any number from 0 to 255 in an IP address which is made up of 4 Bytes and/or 32 Bits. If anyone would like to explain how this works in more detail, feel free to make a comment on this post and I'll make sure it gets published.

Open .txt File Peel Off One Line and Save File with PHP

This code snippet will demonstrate how to use PHP to open a .txt file or any other plain text  file such as .php, .html, .xml etc., retrieve the text in the first line of the file, delete that line and save the file. We are effectively peeling off one line from the file and saving it using pure PHP. Here is how:

//included in index-cron.php to peel off one keyword from keywords.txt file and use it saving rest back to file.
//turn debugging on/off:
$debug = true;
//read in keyword phrases from keywords.txt file:
$lines = "";
$file = fopen("keywords.txt", "r") or exit("Unable to open keywords.txt file!");
//Output a line of the file until the end is reached:
    while(!feof($file)) {
    $line = fgets($file);
    $alllines .= $line."<br>";
    //code to later delete first line from keywords.txt file:
        if($line_no > 1){//if over line 1, store in writelines var to write back to file later.
        $writelines .= $line;
        }else{//else line no. is NOT over 1, so store line in cur_keywrd var:
        $curkey = trim($line);
        $cur_keywrd = $curkey;
        }//end else line is under 1 so put in cur_keywrd var.
    }//end while reading in lines from keywords.txt file
if($debug) echo "<h2>Keyword taken from keywords.txt file: $cur_keywrd</h2><hr>";

//now rewrite keywords.txt file with all but first 1 lines:
$kfile = 'keywords.txt';
$fh = fopen($kfile, 'w') or die("ERROR! Cannot open $kfile file for saving Keywords back to it!");
fwrite($fh, $writelines);
if($debug) echo "keyword $cur_keywrd Deleted from keywords.txt file!<hr>";

There you have it! Copy and paste the above code into a .php file named fetch_keywords.php. Now let's test it...

Make a file named keywords.txt and add the following test content to it:

test keyword 1
test keyword 2
test keyword 3
test keyword 4
test keyword 5
test keyword 6
test keyword 7
test keyword 8
test keyword 9
test keyword 10
test keyword 11
test keyword 12

Save keywords.txt and upload it to the same directory as fetch_keywords.php then open fetch_keywords.php in a browser and you will see this:


If your screen looks like the above shot, then you're doing great! If not, debugging time, but it should work. See where it says "test keyword 1"? That's the keyword it peeled from the keywords.txt file. Now try refreshing the page and it will increment to "test keyword 2". Refresh one more time just for fun and see "test keyword 3" appear. Now download keywords.txt and open it and you'll be able to verify that it did indeed remove the first few lines from the file. This is very usefull if you need to use PHP to read in keywords from a file or domains, phone numbers, names, etc from a file to use the data in your script. Have fun with this and if you need to read multiple lines, the first 100 lines in from a file and save it after deleting those 100 lines, read on, I'll show you how to do that too!

How to read the first 100 lines from a file, delete them and save the file

The next PHP snippet I"ll show you was used to read from a huge list of domain names, take the first 100 domains, use them in my script and save the unused domains back to the .txt file.

The code is similar to the above code with some important changes as you can see below:

//script to peel of first 100 domains from doms.txt file and save it
//turn debugging on/off:
$debug = true;
//read in domain names from doms.txt file:
$lines = "";
$file = fopen("doms.txt", "r") or exit("Unable to open doms.txt file!");
//Output a line of the file until the end is reached:
    while(!feof($file)) {
    $line = fgets($file);
    $alllines .= $line."<br>";
    //code to later delete first 100 lines from doms.txt file:
        if($line_no > 100){//if over line 100, store in writelines var to write back to file later.
        $writelines .= $line;
        }else{//else line no is NOT over 100, so store line in dom array:
        $uselines .= $line."<br>";
        $curURL = trim($line);
        //if cur URL doesn't conain a TLD, add .com
            $curURL = $curURL.".com";
            }//end if curURL doesn't have a dot
        $dom_array[] = $curURL;
        }//end else line is under 100 so put in dom array.
    }//end while reading in lines from doms.txt file
if($debug) echo"<h2>Domains taken from dom.txt file:</h2>$uselines<hr>";

//now rewrite doms.txt file with all but first 100 lines:
$domFile = 'doms.txt';
$fh = fopen($domFile, 'w') or die("ERROR! Cannot open $domFile file for saving domains back to it!");
fwrite($fh, $writelines);
if($debug) echo"Above Domains Deleted from doms.txt file!<hr>";

Godaddy FTP

How to Download Godaddy or Domain Lists

I build a lot of apps for SEO people and Domainers, both are interested in doing various things with lists of domain names, especially domainers or domain name buyers. Before today, I never knew how to get names from simply forwards to without using some crazy screen scraping techniques because normal HTML scrapers will not work as the page is created on the fly with Ajax or something similar. Today I found out that Godaddy has an FTP link accessible from Firefox browsers that contains zip files containing all of their domain name lists! Beware that it may not open in other browsers, but the link is and contains all domain lists from and, so you can imagine that this was quite a find for me! Good luck and I hope this helps you like it did me.

Link to download .zip files containing all Godaddy domain lists:

Connecting to Godaddy with FTP

Amazingly enough, I was also able to figure out how to connect to the directory that holds all of Godaddy's domain lists using FTP client FileZilla. Here is how:

  • For host enter:
  • For protocol, leave regular FTP selected.
  • For encryption select: use plain FTP
  • Logon type is: Normal
  • User name is: auctions
  • Leave password blank
  • Click "Connect" and it should work!


Install Command Line Whois on Linux Server

If the Whois command, as demonstrated  below, doesn't work from the command line, then you likely have to install the Whois library.

Install Whois from Command Line

  1. Open a command prompt and log in to your Linux server. I use Putty to do this.
  2. change to the super user. I used sudo su or su sudo but some servers may have slightly different commands for this. Google it if you are not sure and those commands don't do the trick, or you could simply proceed all future commands with sudo if all else fails.
  3. From the command Prompt, type: yum install whois

Possible issues installing Linux Command Line Whois

WHen I installed I got an error message that said that the following:

Existing lock /var/run/ another copy is running as pid 27256.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum-updatesd-he
    Memory :  29 M RSS (328 MB VSZ)
    Started: Mon May 19 19:18:12 2014 - 13:54 ago
    State  : Running, pid: 27256

So I had to learn how to kill that process and try again. Simply type:

kill ####

where #### is replaced by the pid number noted in the error. In my case it was 2756 as you can see in the red error text above.

You may have to also try these commands from command prompt if it's not working yet:

1) service yum-updatesd stop
2) chkconfig yum-updatesd off

Using Linux Command Line Whois

Once installed, Linux Whois commands are fairly easy to use. For example, if you wanted the whois data for the domain from the whois server,, then use the following commands:

 whois -h


Note the -h parameter in the first example above. Only use that if you have a specific need to specify the host of the whois server you want to query, otherwise, use the simpler second example of "whois" and you'll be good.

Here are options you can use with the Whois command as well:


-h HOST Connect to WHOIS database host HOST.
-H Suppress the display of legal disclaimers.
-p PORT When connecting, connect to network port PORT.
--verbose Operate verbosely.
--help Display a help message, and exit.


Whois Alternative, jWhois

You can also use the very similar jWhois library if whois doesn't do the trick for you. Simply use the following command to install it instead and use it similarly:

yum -y install jwhois

This worked for me(jwhois) wen the above whois instructions Did Not.

Coding a PHP Whois App that uses the Whois Command

The following PHP code will work with either whois or jWhois out of the box:

//whois servers that got what we need:
// have a try with below email!!! use with current whis first then this
function whoEmail($curdomn){
$whoserver = '';//'';//'';
$comand = "whois -h $whoserver $curdomn";
$output = shell_exec($comand);
echo "Output: $output<hr>";
$outarra = explode('Registrant Email:',$output);//key 1 is email plus xtra
$output2 = $outarra[1];
$outarra2 = explode('Registry',$output2);//key 0 is email so trim it
$emailout = trim($outarra2[0]);
//echo "Email: $emailout<hr>";
//echo "$curdomn produced:<pre>$output</pre><hr>";
return $emailout;
}//end whoEmail function.

//test function:
$e = whoEmail('');
echo "Email: $e<br>";


Notice at the top of my PHP script there are commented out whois server URLs. Feel free to experiment because I found that all of the ones listed there work with different domains. You can add more as well and increase the apps functionality by adding more code of course.


While I did find information online regarding the whois library and how to installl and use it, I found that it did not work and had to use the second option on this page, the jWhois library, which worked fine. I also went on to show you how you can write a nifty PHP script to work with the whois command, whether you used whois or jwhois, it will work the same.


PHP Functions to Validate Domain Names and IP Addresses

If you are similar to me in that you like to create PHP applications for the domain name industry or you have a need to validate domains or IPs, then this tutorial is for you.

Validate a Domain Name with PHP

The Valid Domain Function:

function validDom($domain) {
    if(!preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i", $domain)) {
    return false;
return $domain;
}//end validDom function.

Executing the ValidDom Function:

if(ValidDom($domain)) {
echo "<p style='color:green'>$domain is valid.</p>";
echo "<p style='color:red'>ERROR! $domain is NOT a valid domain name.</p>";

Validate an IP address with PHP


The Valid IP function:

function validIP($ip) {
$ipnums = explode(".", $ip);
    if(count($ipnums) != 4) {//if there is not 4 numbers to the IP return false
    return false;
    foreach($ipnums as $ipnum) {//for ea. IP number make sure it's less than 256:
        if(!is_numeric($ipnum) || ($ipnum > 255)) {
        return false;
return $ip;//if made it this far, returns valid IP
}//end validIP function

Executing the ValidIP Function:

if(ValidIP($ip)) {
echo "<p style='color:green'>$ip is valid.</p>";
echo "<p style='color:red'>ERROR! $ip is NOT a valid IP address.</p>";

The Ultimate PHP WhoIs Parsing Code – Jafty Whois

As far as I am concerned, this is the holy grail of PHP Whois apps and I have tried a lot of them. I of course had to make my own to get what I wanted, but I used what I took in from experimenting with all the popular choices out today to come up with JAFTY WHOIS.

The trick was to keep it as simple as possible and get it to run as many consecutive queries as possible. The purpose of the code is to fetch Whois data for a quantity of domain names. It gets such data as the domain owner's email address, contact information, expire and creation date.

The Code

I developed the ultimate Jafty Whois code with two key functions. The first is called "queryWhois" and is the function that does the actual query to the whois server. The second function, called "runDom", basically runs the "queryWhois" function. The job of the "runDom" function is to monitor the "queryWhois" function and sometimes run it again based on what it returns.

Here are the two functions as they are in the working demo (Contact Ian at for complete demo code):

function queryWhois($domain,$whoisserver = "") {
$port = 43;
$timeout = 10;
$fp = @fsockopen($whoisserver, $port, $errno, $errstr, $timeout) or die("fsocketopen Error " . $errno . " - " . $errstr);
fputs($fp, $domain . "\r\n");
$out = "";
    $out .= fgets($fp);
$res = "";
    if((strpos(strtolower($out), "error") === FALSE) && (strpos(strtolower($out), "not allocated") === FALSE)) {
    $rows = explode("\n", $out);
        foreach($rows as $row) {
        $row = trim($row);
            if(($row != '') && ($row{0} != '#') && ($row{0} != '%')) {
            $res .= $row."\n";
return $res;
}//end queryWhois function.

function runDom($domain){
$whoisserver = ".com";//just for showing note below, not actual server...
$result = queryWhois($domain);
    return "Error: No results found for $domain!";
    //look for "Whois Server:" indicating we need to get results from a diff server:
        while(strpos($result, "Whois Server:") !== FALSE){
        preg_match("/Whois Server: (.*)/", $result, $matches);
        $secondary = $matches[1];
            if($secondary) {
            $result = queryWhois($domain,$secondary);
            $whoisserver = $secondary;
        }//end while looking for secondary whois server.
return "<h2>$domain results from $whoisserver server:</h2>" . $result;
}//end runDom function

Why does the queryWhois function need monitored?

Great question and that's the secret to this code's success. Lets take the raw queryWhois function and run it by itself without the "runDom" functon and see what happens. There are two likely scenarios, the first will return standard whois results and that's fine, but the second will return something like the below example. That's bad because it doesn't contain the whois data we are ultimately looking for! However, it does contain the key to getting that data. It contains the whois server you need to query instead. This is done with the queryWhois function too, but it needs to be told to run again with the a different whois server, so in comes the "runDom" function to tell it to run again when this secondary whois server is spotted, passing that whois server URL as a variable to the queryWhois function like: queryWhois($domain, $serverURL). The $serverURL variable would be set to the new whois server found while running the queryWhois function the first time.

Example results of queryWhois function when a secondary whois server is found instead of domain name's whois data:

--------------------Start queryWhois test results------------------

Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to
for detailed information.
Domain Name: AAAX.COM
Registrar: DOMAIN.COM, LLC
Whois Server:
Referral URL:
Status: clientTransferProhibited
Status: clientUpdateProhibited
Updated Date: 18-nov-2013
Creation Date: 01-dec-1999
Expiration Date: 01-dec-2014
>>> Last update of whois database: Sun, 18 May 2014 06:40:14 UTC <<<
NOTICE: The expiration date displayed in this record is the date the...*

---------------------End queryWhois test results----------------

*NOTE:  where you see ...* at the end of the above test results, I shortened the results because the remaining text was irrelevant for this demonstration.

Notice in the above example test results where I highlighted the whois server text in orange bold text. That is what the runDom function searches for, and if the text "whois server:" is found, it knows to rerun the queryWhois function a second time using the whois server named after the colon.

Example results of runDom function controlling the queryWhois function so that it runs secondary Whois server found during first run of queryWhois function:

------------------------Start test results--------------------

Domain Name: results from server:

Domain Name: AAAX.COM
Registry Domain ID:
Registrar WHOIS Server:
Registrar URL:
Updated Date: 2013-11-18 09:04:07
Creation Date: 1999-12-01 15:20:53
Registrar Registration Expiration Date: 2014-12-01 15:20:53
Registrar:, LLC
Registrar IANA ID: 886
Registrar Abuse Contact Email:
Registrar Abuse Contact Phone: +1.6027165396
Reseller: MyDomain
Reseller: +1.8004057875
Domain Status: clientTransferProhibited
Domain Status: clientUpdateProhibited
Registry Registrant ID:
Registrant Name: TODD BERNHARD
Registrant Organization: Domain Owner
Registrant Street: 20 Barclay Square Drive
Registrant City: Rochester
Registrant State/Province: NY
Registrant Postal Code: 14618
Registrant Country: US
Registrant Phone: 585475.1030
Registrant Phone Ext:
Registrant Fax: 585475.1030
Registrant Fax Ext:
Registrant Email:
Registry Admin ID:
Admin Organization: Domain Owner
Admin Street: 20 Barclay Square Drive
Admin City: Rochester
Admin State/Province: NY
Admin Postal Code: 14618
Admin Country: US
Admin Phone: 585475.1030
Admin Phone Ext:
Admin Fax: 585475.1030
Admin Fax Ext:
Admin Email:
Registry Tech ID:
Tech Organization: Domain Owner
Tech Street: 20 Barclay Square Drive
Tech City: Rochester
Tech State/Province: NY
Tech Postal Code: 14618
Tech Country: US
Tech Phone: 585475.1030
Tech Phone Ext:
Tech Fax: 585475.1030
Tech Fax Ext:
Tech Email:
DNSSEC: Unsigned
URL of the ICANN WHOIS Data Problem Reporting System:
>>> Last update of WHOIS database: 2013-11-18 09:04:07 <<<
Registration Service Provider:
This company may be contacted for domain login/passwords,
DNS/Nameserver changes, and general domain support questions.

-------------------------End test results---------------------


Sometimes the queryWhois function will return the results the first time and doesn't need the runDom function to extract the secondary whois server and rerun it. So, it should be noted that sometimes it returns results and sometimes it returns a string of text that most likely contains the actual whois server to query for the domain name passed to it. Without the important runDom function, the queryWhois function would only work approximately one out of five times. If you require assistance with Jafty Whois or would like a custom application built based on it, contact Ian L. of at

PHP_SELF Function to Get Current Page URL

You may use the PHP_SELF function to the your current page url, but pay attention to what it returns below.

Here are some examples:

Here is how to print the current page URL to your screen:
echo PHP_SELF;

If your script that includes PHP_SELF is at, it would return:

Handy Regex Notes for Notepad++

Here are some regex expressions I have found to be useful with notepad++ as a programmer:

  1. .*' - (dot star apostrophe), finds all  occurrences of "'s".
  2. .*word - finds all occurrences of any number of characters up to the word "word".
  3. word.* - finds all occurrences of the word "word" followed by any number of characters.
  4. [a-z][a-z][a-z].com  - finds all three letter .com domain names(lower case). Simply change the a-z to uppercase to look for uppercase 3 letter domains.
  5. [a-z][a-z].com - finds all two letter .com domain names in lower case. Change to A-Z for uppercase.
  6. [0-9][0-9][0-9].com - finds all three number .com domain names.
  7. Adult T - [0-9a-zA-Z ]+, - finds all occurrences of "Adult T -" followed by another word or number(or combo) and then a comma.
  8. .*[\|]  - Finds and replace all but the domain name in cases where ea. line in a file looks like: | sure that the regex ends in a space). Note that the pipe character is escaped with a backslash.
  9. ^\s - find are replace all blank lines. Deletes blank lines when search for this and replace with nothing.

Make all lowercase

While not a regex, I learned how to change all characters to lowercase using Notepad++ today as well. All you do is select the entire document or the part you want lowercase and right click then select "lowercase" and DONE!

Find & Replace Part of a String

Lets say you have a CSV file with these contents:
1 Adult T - Led Zeppelin, black, XL

2 Adult T - Motley Crue, black, Med

3 Adult T - Grateful Dead, tie die, Sm

...and you need to replace:

"Adult T - Grateful Dead," with "Grateful Dead T-Shirt,"

This is where the \1, \2, \3 abilties of Notepad++ version 6+ comes in very handy. First you define parts one and two in parenthesis, so as in the #7 example above you'd change it to this instead:
Search for:
(Adult T - )([0-9a-zA-Z ]+),
and replace with:
\2 T-Shirt,

The above tells Notepad to find the text "Adult T - " and any string after it until you hit a comma. Then in the last line above, it says to replace it with what is in the 2nd parenthesis and to add T-Shirt to it so "Adult T - Led Zeppelin," becomes "Led Zeppelin T-Shirt,". Works like a charm!

By reading and studying the above examples, you should be able to modify the regex expressions to do just about anything. I am using only simple regular expressions here to make it easier to understand because most of us have a terrible time understanding all the regular expression rules.

Google PageRank

What is Google PageRank

PageRank(AKA PR) is one of the methods Google uses to determine a page's importance and therefore it's position in search engine results and the domain name's value in part. The PR of all web pages changes every month when Google does their re-indexing.

How is PageRank determined by Google?
PageRank is determined solely by incoming Links. So to increase your PageRank, increase the number of links to your site. The quality of links is also a big factor in your site's PR. For example, links coming into your site from a site with a PR of 1 are not as valuable as links coming to your site with a PR of 6. Keep this in mind when going after incoming links to your site and check the PR of the sites where you place links.

Is it better to have a high or a low PageRank?
I used to wonder whether it was better to have a zero or a five. Well now that I understand a little about how it works, it's definitely better to have a higher PR than a lower one.

Want to learn more about SEO? Check out these relative books from Amazon:

Buy Scripts, Applications and Web Tools at

Yes, I finally am starting to sell some of my products that I have been developing for over 12 years now. I am only putting together the best tools I have made and remaking certain ones I find the most useful for sale on my website,

Types of Products for sale on

  • Email Marketing tools
  • Domain name tools
  • DNS tools
  • Server administration tools
  • webmaster tools
  • PHP tools
  • Customized tools for business
  • Have me build one custom for you if you don't see what you need

CLICK HERE TO VISIT and see what's listed for sale now. However, I do not have them all listed yet, so drop me an email or give me a phone call at 330-903-6074 or 330-417-3617 to find out how I can help you.


Want to learn more about SEO? Check out these relative books from Amazon:

Be sure to visit to view my portfolio and see the web development services I offer! You an also email me at if you need anything.

Domain Name and Nameserver Tools

This is a simple list of links I put together for anyone needing help with domain name monitoring and nameserver set up. They are meant to give you information regarding your domain name, IP address and nameservers. - This site is one I use regularly to make sure my domain name is pointed right and to test nameservers for that domain or nameservers that I have built. is a great place for gathering WhoIs info for your domain and if you look around a bit they have other useful domain name tools and info. has a useful tool for running all sorts of DNS tests on a domain name. - is a great tool for checking to see if your domain is pointed to the proper server. Looking up your IP address and getting nameserver information for the domain name and/or IP address. IT lists MX records, A records, nameserver IPs and other host file data and zone information that is useful.

FYI - If you need custom domain name tools or SEO tools, I specialize in developing such tools for the internet. Web-based domain name, SEO, Calculators and business development tools are my no. one specialty. If you need any such custom tools contact Ian at and we can work something out and get a free estimate on the spot.


 Virtual Work

Need to hire the perfect coder, designer, developer or graphics specialist? EmployWorkers has all areas of Information technology covered and more.

Virtual employment agency

Where work that needs done, gets done.

Need to find work in the Information Technology field, is for you! We employ all skilled workers in a vast array of areas including, but not limited to graphic design, logo design, Photoshop, web design, web development, application development, special needs coding, PHP, HTML, CSS, SEO, writing of all types, programming of all types and much more. If you need work, visit today and sign up for free. Finding work online has never been easier!

I, Ian L. of have created to fill a niche left open by the buyout of They had a simpley to use website for posting jobs and finding work. I have expanded on the idea by making it even easier to sign up, post jobs and find work all for free. You never pay a cent, we collect a small percentage of the project price only in cases where a job was completed satisfactory and accepted by the employer. We have a zero risk policy where you don't pay anything until you are satisfied with our services. Money for projects is held in escrow so the worker knows he will be paid once he fulfils his contract with the employer, but employers can dispute at any time they feel there is a breech in the contract and get their escrowed funds returned to them hassle free. Most times you will find that satisfaction is standard however because uses a skilled pool of workers and expertly matches the most qualified workers with your project.

Go ahead and visit today and give it a try whether you are an employer seeking assistance on a project or a worker looking for your next project, we have got you in mind!

Finding the right domain name

Finding the right domain name takes patience, time, research and knowledge. I will help with some tips for those of you who are seeking to buy a domain name for your website or to buy several to add to your domain portfolio.

Domain name finding tips

  • TOOLS - use online tools to assist you. There are all sorts of tools that can help you pick the right domain name for your needs. See my list of tools below for more information. If you are a serious domainer, have someone like me build custom tools for you because all of the real good tools are kept secret and have been custom made for domainers like you. If you spend a little money you can have a tool developed that can find you great domain names on a regular basis. I build tools for domainers that can cost anywhere from $50 to $500 depending on how complex they are to code, but most cost under $200. Email me at if you want me to build a tool for you.
  • Don't always buy a new domain name. While new domains are inexpensive, often around $7, they have no traffic which makes them worthless and means you will have to do a lot more seo work than if you bought one with traffic already.
  • Research - check a domain name for traffic stats, overture score, dmoz, google, etc

Tools for finding a domain name:

  • Bulk Domain Availability Checker I like this tool because you can write out a whole list of domain name you like and paste them into the textarea provided and it will tell you not only if the domain names are available, but if they have been registered before as well. I like to take a good look at ones that have been registered before to see if they have existing traffic still which can make them valuable.
  • Domain Stats Checker is a good tool for checking to see if the domain is really good. It will not list data on domains that do not have a significant history, but if you happen to stumble across a domain name that has stats with this tool, chances are you found a winner.
  • Way Back Machine is a tool that lets you see what the website, if any, looked like in the past for any domain name they have records on and they have records for many.
  • domain registrar - once you find the domain name you want to buy, you have to make the purchase which can be done through any of the big domain name registrars such as, but I linked this one,, because they had a promo at the time I wrote this post for $0.50/year domain name registration! Good luck, it may not be there by the time you read this, but give it a shot, otherwise, just go with Godaddy who is normally the cheapest or close to it.
  • Alexa Rank Checking Tool - allows you to check up to ten domain names at a time to see if they have an Alexa ranking. My suggestion is to buy any cheap domains with an Alexa rank listed.
  • Back Link and PR checker - checks one domain at a time for PR rank and back links.