How to put an IP Logger to your website

Neonlej

New Member
Dec 23, 2018
7
2
8
Hello guys, I have a website and I wanted to know if there is any way to track down my visitors IP. I do not mean any harm to the people visiting it! I just simply want to see it.

Is the any code or something? Because I saw a lot of php codes but none of them worked (probably I'm just too dumb, I'm not really into it)
Could someone please help me with this? Thanks!

(sorry mods if I posted it to a wrong thread!)
 

Neonlej

New Member
Dec 23, 2018
7
2
8
I uploaded the .php and everything but it doesn't seem like it's working.

<?php include "logger.php"; ?> was wrote into the html file but still. If somebody knows the answer it would be very very great. maybe kalle
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
I uploaded the .php and everything but it doesn't seem like it's working.

<?php include "logger.php"; ?> was wrote into the html file but still. If somebody knows the answer it would be very very great. maybe kalle
Change your file extension from .html to .php and it should start working :)
 

Neonlej

New Member
Dec 23, 2018
7
2
8
I'm really glad ya'll tryna help but, do I need to change the name of the index.html to .php? I don't really get it.

I want to run the .php from html

And do I need to create the ips.txt or it does by itself?
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
I'm really glad ya'll tryna help but, do I need to change the name of the index.html to .php? I don't really get it.

I want to run the .php from html

And do I need to create the ips.txt or it does by itself?
Look dude, you cant run PHP from HTML.
So you need to create index.php file, put all of the html from your previous file to this index.php, and include that logger into index.php like you did in previous reply.
Just dont mix php and html opening tags, and you should be fine.
Ill give you an example.

PHP:
<?php
    include_once('logger.php');
?>
    
<html>
    <head></head>
    <body>
        <h2>This is not IP logger, belive me. </h2>
    </body>
</html>
 

Neonlej

New Member
Dec 23, 2018
7
2
8
I'm really sorry, but it still not working. Then I guess I need to write it all from html to php because my site is written in html and all that.
Do you mean I need to copy from my index.html to index.php? Becauese it sounds strange to me. I'm really dumb about this haha.

Anyways thanks guys, you are all really helpful and polite.
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
Do you mean I need to copy from my index.html to index.php? Becauese it sounds strange to me. I'm really dumb about this haha.
Neonlej, we have a few questions here.

  1. Do you pay for this hosting (server) or is this free?
  2. Do you have root access with SSH or can you sudo - if you are unsure, is this hosted on a Linux or Windows server?
  3. Are you using Apache, Nginx, or another web server software to run the server?
By answering these questions, the solution may be different but we can better help.
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
I'm really sorry, but it still not working. Then I guess I need to write it all from html to php because my site is written in html and all that.
Do you mean I need to copy from my index.html to index.php? Becauese it sounds strange to me. I'm really dumb about this haha.

Anyways thanks guys, you are all really helpful and polite.
Yes you need to put all from index.html to index.php, and all of that is still gonna work.
And also forgot to mention, you need webserver to run php. Check question that Asphyxia asked.
 

Neonlej

New Member
Dec 23, 2018
7
2
8
1. Yes, I do pay for it.
2. Yes, I can acces is through puTTY
3. Apache

f2c55545999686ea0d0e26fa932302b6.png
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
@Neonlej,

Couple things then - we are going to update & upgrade packages firstly if you have not already done so. Just copy/paste this into your PuTTY:
Code:
apt-get update
apt-get upgrade -y
apt-get install apache2
apt-get install mysql-server
mysql_secure_installation
apt-get install php php-pear php-mysql
service apache2 restart

You should now have PHP available to run on your server. Be careful, if you have unsafe PHP, someone can compromise your VPS. This will also install SQL, to be used as a database - a better way to store IP logs than a text file in my opinion but this is up to you.

If you want PHP to be executed, just rename your .html file to .php - because then both HTML and PHP will work fine.

If you want to keep the file type as .html there are a few options. Embed the other PHP file into your .html file using an iframe or allow PHP inside of .html files by using AddHandler or SetHandler. Alternatively, there is a blog tutorial here showing more info.
 
Last edited:

Neonlej

New Member
Dec 23, 2018
7
2
8
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php
E: Unable to locate package php-mysql

This is what i get after apt-get install php php-pear php-mysql
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
This is what i get after apt-get install php php-pear php-mysql
Ahh right, I toggle between multiple Linux distros.

Digital Ocean has decent LAMP stack tutorials for various distros. If you are on Debian 9, Google "Debian 9 Lamp Stack Tutorial".

Code:
apt install mariadb-server
mysql_secure_installation
apt install php libapache2-mod-php php-mysql
systemctl restart apache2

Because your VPS is saying "php" is missing, my guess is that you are on an older version of Debian, so maybe php5 instead - then php5-mysql, etc.

Many things you can try, what Debian version is running though?
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
I'm using Debian version 8.11
Okay, so this information shows you how.

Code:
apt update
apt upgrade -y

Now we can search for any PHP packages, for example apt-cache search php5.

Code:
apt install php5 apache2 -y
systemctl restart apache2

This will work - sorry about earlier I was not at a system.
 
Last edited:
Top