This tries to solve bug 179 where DokuWiki can not write to directories it created itself.
On some hosts with restrictive settings there are limitations on PHP's filesystem functions, e.g. mkdir() etc. To be more specific, the settings are:
A first indication for the need of the SafeMode Hack is the encounter of error messages like this:
Writing ....../data/cache/9/9243162ecf6295fc6a1c487ca46c20fe.i failed
The directory …./data/cache/9/ will exist (check this!) but it will not be writable by DokuWiki. This is a typical symptom of the safe mode restriction. DokuWiki can't write to directories created by it self.
To enable it, set safemodehack to 1 and enter your FTP credentials into the config file. (i.e. conf/local.php Or just go to the Configuration Manager, which offers a great GUI for changing settings of DokuWiki.)
If you have already tried running DokuWiki without the Safemodehack Option, you have to remove the subdirectories of /data/cache to have them recreated with the correct UID in order for everything to work.
Example Config:
$conf['safemodehack'] = 1; $conf['ftp']['host'] = 'localhost'; $conf['ftp']['port'] = '21'; $conf['ftp']['user'] = 'user'; $conf['ftp']['pass'] = 'password'; $conf['ftp']['root'] = '/home/user';
You may need to relax the directory permissions as well to make sure the webserver is allowed to write to the new directories.
(That's right, the safemodehack alone did not solve the problem. I had to change the ['dmode'] option from 0755 to 0777. After that I did not get any more warnings.)
When DokuWiki tries to create a directory it strips the root part from the path before creating it over FTP. To do so it needs some info about the environment it will find at your FTP-server.
Imagine you installed DokuWiki in /home/user/htdocs/dokuwiki with /home/user/htdocs/dokuwiki/data as datadir. When you log in with FTP you are chrooted to '/home/user', which means creating a directory /foo through FTP will really result in
a directory /home/user/foo on the server. To tell DokuWiki about this you need to set $conf['ftp']['root'] to /home/user/.
So if DokuWiki tries to create the directory /home/user/htdocs/dokuwiki/data/mynamespace the safemode hack strips the root part resulting in htdocs/dokuwiki/data/mynamespace this directory then will be created via FTP.
If your FTP Server doesn't use any chroot (eg. you can cd up to / of the WebServer) you can leave the root option empty.
To find the place where your are chrooted to on a webhost you first have to find out the absolute path in which DokuWiki resides. This is usually something like /srv/www/htdocs/your-ftp-username/html/dokuwiki, but you can find it out, by e.g. checking the PHP environment using this short script:
<?php phpinfo(); ?>
This will print the webserver's PHP settings on the screen where you will find all the details. When you have the absolute path, log into your FTP account and compare what you see there with this path. Try moving to upper directories until it you reach the top. Now look which part of the absolute path you can see. If you are chrooted you probably can only see the html directory.
So, if for example the username for your webspace is web123, and if you are chrooted to /srv/www/htdocs/web123, you have to set the root value to:
$conf['ftp']['root'] = '/srv/www/htdocs/web123';
there is a problem, I've encountered on my ISP and i ask myself, if this is a general issue: calling the fullpath-function on the given root directory returns false because file_exists() called on this directory returns false too. This results in failing to create directories via FTP. As a workaround I have inserted return realpath($path); at the beginning of fullpath(), what is working for me, but I don't use symbolic links or stuff. Another way would be to omit the fullpath()-call in the io_mkdir_p() function (inc/io.php) and expect the user to set a valid full path as ftp-root.
— Benny Wegner 2008/07/14 01:55
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported