====== Safemode Hack ====== The [[config#safemodehack|safemodehack]] Option tries to solve bug [[bug>179]] but is not thoroughly tested yet. Any feedback is welcome. ===== When to use this hack ===== 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: - safe_mode = On - safe_mode_gid = Off 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. ===== Usage ===== 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 [[config#safemodehack|safemodehack]], 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.) ==== Which value to use for the root option ==== When DokuWiki tries to create a directory it strips the root part from the path before creating it over 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 [[man>chroot|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 [[man>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: 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'; ===== Notes ===== * My ISP has both these safe_mode settings (see [[http://mcode1.free.fr|one of my sites]] for php_info), and I create pages with no need for the hack. It may depend on other variables too ([[mailto:dw-safe@mmichel.freesurf.fr|mathiasm]]). * //Possible Answer:// The main difference between my non working settings and those of your ISP is that in your case PHP is run as CGI (Server API: CGI) where as in my case PHP is set up as Apache2 module (Server API: Apache 2.0 Handler). Might that be the cause that makes your installation work despite the safe_mode settings? * **I did a "mkdir 1 2 3 4 5 6 7 8 9 0 a b c d e f" in data/cache and chmoded all these to 777. This seems to be a workaround, too.** * This is not really a solution, because DokuWiki needs to create subdirectories for [[namespaces]] as well, with the above method you'll still not be able to create new namespaces * **If you don't need new namespaces, this is a workaround!** * Even if you use the Safemode Hack, [[wiki:tips:disabled_functions|disabled php functions]] ((check the ''disable_functions'' value in [[phpfn>phpinfo]] output)) could break php output. * The safemodehack may only work if you have the possibility of using the ftp service. I tried it with only webdavs available. Neither the ftp-hack nor a similar webdav configuration worked. So I'll have to try something else. ===== FAQ ===== * **What file do you add this to?** - kzaugg, ingo * It would be ''conf/local.php''. Or just go to the Configuration Manager, which offers a great GUI for changing settings of DokuWiki. --- //[[Robertus0617@gmail.com|Roberto Ciang]] 2006-12-30 11:28// ===== Problems ===== * I think that the code needs do be implemented on recentlog too... The changes.log dir cant be accessed by wiki when on safe_mode... So Recent Changes does not works.... ---- ==== [Solved] Still can't work and even can't create directory ==== >>>I have tried modifying all the permissions of directories to 777 when I didn't use the safamodehack. And then I found this hack. After setting up the host, username and password and deleting a cache directory via FTP, now my problem gets worse:-/ Creating directory /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4 failed Creating directory /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4 failed Creating directory /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4 failed Writing /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4/427864c0a094a68eca1f586be8f3e854.i failed Creating directory /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4 failed Writing /www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/htdocs/data/cache/4/427864c0a094a68eca1f586be8f3e854.xhtml failed I saw only "/" in my FTP, so I have left the root field blank. Any further advice? --- //[[Robertus0617@gmail.com|Roberto Ciang]] 2006-12-14 02:58// >>Hurray! I have find the answer very accidentally! Thank God!^_^ Now I know although I can **cd** to ''/'' in my FTP host, but I still need to fill the absolute path, and I have finally found the exact path to fill: it should be ''/www/110mb.com/m/i/l/c/h/f/l/a/milchflasche/**htdoc**'', down to the ''/htdoc'' level, and **the final slash must be dropped**!!! I'm not sure if the right format of the path differs site to site, but at least this works for me now!:-o Now I can start using my site! Thank God! I love you! >> >>If my finding is applicable to other users, maybe you can update the tutorials above:-)--- //[[Robertus0617@gmail.com|Roberto Ciang]] 2006-12-20 01:50// >Oh no:-| I found that although DokuWiki can now create the folders and cache files, but whenever editing a page, the result always goes to the start page, which means that I can't create any pages other than ''start.txt''! No other people testing this issue? --- //[[Robertus0617@gmail.com|Roberto Ciang]] 2006-12-20 23:11// > >Dear kzaugg and ingo, I have replied to your question above. And please tell me if you make this hack work! Because I still fail to do it... --- //[[Robertus0617@gmail.com|Roberto Ciang]] 2006-12-30 11:28// Okay, today my hosting has had my safe mode off, and after that the same problem occurs, so it was not fault of safemodehack. After some testing and turning off the nice URL feature, I can now create new pages correctly. So people using safemodehack, don't worry anymore! Just try it!--- //[[Robertus0617@gmail.com|Roberto Ciang]] 2007-01-19 03:00// I get the same error with Roberto's. After I configured and enabled safemodehack as explained here, the number of error messages has increased, just like Roberto's. Could you please help? --- //[[ryu@divit.org|Ryu Kun]] 2007-05-12 01:27// Is there any safety issues in changing the cache subdirectories permissions to 777? --- //Kristofer// ==== French ISP : "Free" problem ==== This ISP has disabled rmdir() function ... it simply silently does nothing. So there is a problem with the io_lock() because directories are never deleted by io_unlock(). "safemodehack" is a bit strong because it seems to be used for cache data too, and it's not necessary. So I just "return" in io_lock() and io_unlock(), and it seems to work. >> hi, I try to use Dokuwiki hosted by "Free" and I have exactly this problem, >> But I do not understand your workaround ? what do you mean with "//I just "return" //" ? >> [[kiekeunreusche@free.fr|Kiekeun Reusche]]\\ >>>> >>>> Ok, I found all the details here: [[http://forum.dokuwiki.org/post/1733]]