Howto get the relative path of a file / folder in Unix / Linux with PHP

Sometimes you´ll need the relative path of a file or folder stored on your webserver. Especially if you´re one a shared environment this can be a bit tricky sometimes.

Here is a short and easy solution for your problem:

  • create a php file named ‘fullpath.php’
  • open the file and enter the following php code
  • <?php
    $dir = dirname(__FILE__);
    echo "<p>Full path to this dir: " . $dir . "</p>";
    echo "<p>Full path to a .htpasswd file in this dir: " . $dir . "/.htpasswd" . "</p>";
  • upload the file to the folder on your webserver which you want to know the path (f.e.
  • open your webbrowser and go to the location you´ve uploaded the file (f.e.
  • enjoy your relative path (which could look f.e. something like this  ‘/var/www/vhosts/’)
  • Note: if you plan to use this relative path for other applications you may need to add an additional ‘/’ at the end (‘/var/www/vhosts/’)


The long search for a Webmail Solution

Update: Comments have been disabled as being the no.1 source of spam.

Over the past years I have been using my providers (1&1) webmail solution. They had 2 versions of it. A very simple and old school one and a web 2.0 like styled newer one. The newer one had many features but was dead slow. The older one lacked nearly everything a modern webmail application has, but was quite fast. With the daily mail mass increasing and time to spare for it decreasing I decided that I need a new and better solution. First of all, I don´t like Google Mail. It has all the features I need (and dozens more which I don´t care about)  but I don´t like it. And I wanted my mails on my server. Nowhere else. Ritlabs – my favourite desktop e-mail client provider still has no web solution, only a portable version of their famous mail client The Bat. Not good for me, I need a web based solution.

I found a very good overview for webmail solutions at this site and believe me – I tried them all.

I had 4 assumptions for a PHP / MySQL / Apache based webmail solution:

  • easy to configure and install (web based, no hacking through 10 different config files)
  • secure (no register globals, safe mode, etc.)
  • multiple mail accounts per user
  • light and fast

AfterLogics WebMail Pro was the only solution that fullfilled 3 of my 4 assumptions. The one it lacked is that it only runs with PHP Safe Mode Off (hmm, not good but anyway…). All other products on the list had major flaws. Some didn´t run the installer or did anything at all (like Roundcube), some required to disable every single PHP security enhancement (like Hastymail) and others were way to difficult to configure (like Squirremail, or IMP out of the Horde Framework).

WebMail Pro has a very good installer (you only need to upload the files to your server, chmod one directory) that does everything on its own. It´s well explained and lets you test every single setting of your upcoming webmail solution. If you´re fast then installation needs about 2 minutes of time.

And the best thing is – normally you have to invest a lot of money for that solution (149$ for 25 user license). But if you keep it under 25 users and a single server install the pro version is for free. How great is that ? There´s also a light version available but in it you can´t add multiple mail accounts to a user. For all you IIS and .NET freakz there´s also am ASP.NET version available.

So – if you´re looking for great webmail solution – check it out !

All images and copyright


Not long after writing this article Webmail Pro confronted me with the first bug. I couldn´t attach a file to an e-mail. It only presented me Error #2038 – unknown error.

Luckily Afterlogic has a support forum where Igor (Afterlogic support) quickly presented a solution. It turned out that this problem only occurs when you´re using Webmail Pro with Firefox on a SSL connection. The following solution will disable the flash uploader and use instead the html one.

Here´s the solution:

1.) Go to the root path of your Webmail Pro installation

2.) Locate webmail.php and open it

3.) Look for a line that looks like this // flashInstalled = FLASH_NOT_INSTALLED;

4.) Remove // from that line (uncomment it) and save the file

5.) You´re done. Now you can attach files.

6.) In case you can´t find that line in the webmail.php locate flash-detect.php and open it

7.) Look for a line that looks like this // flashInstalled = FLASH_NOT_INSTALLED;

8.) Remove // from that line (uncomment it) and save the file

9.) You´re done. Now you can attach file.

Update 2:

Alex had a problem with sending mails, so I thought the solution might be in common interest. The image below shows the settings you have to adjust in the adminpanel of Afterlogic Webmail. The shown settings are for POP3 only, not IMAP. In my case the servers are those from 1&1.

Photo Gallery back online

After some days of downtime, the Photo Gallery is back online.

It now uses a very advanced version of MiniGal (MG2) called kh_Mod (current version 0.3.2.). If you are looking for a really lightweight photo gallery tool then kh_Mod is the perfect pick for you. It doesn´t require a database server – though it supports mySQL -, it´s really easy to install, has a rich admin interface and is easy to use. It´s based on PHP – give it a try. It´s worth your time.

admin_mg2_01(main screen of the admin interface)

Version 0.3.2. has a small bug concerning the PHP memory management. There´s a bugfix available from the author which will be included in release 0.3.3. In the meantime you can download it directly from the author´s site (just replace the file in the package with the one in the include directoy of your installation) :

The latest release (0.3.2.) of kh_mod is here :

(Thanks to Klemens for the great support !)