Translations of this page?:

Apache2 for DokuWiki

This page aims to collect all the tips, tricks and general comments about configuring Apache 2.0.x for DokuWiki. Each section is split in Windows and Linux, for those cases where settings are different.

mod_rewrite

This section describes the steps necessary to enable Apache Module mod_rewrite, which “beautifies” the URLs used in a DokuWiki site by removing the doku.php?id= part. The httpd.conf file must set the module for Apache2 to load. Find the line

# LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it. The result of this change must be this:

LoadModule rewrite_module modules/mod_rewrite.so

Once the rewrite is working, you'll want to make all the links inside the wiki look “beautiful”! In conf/dokuwiki.php, you need to change the following to 1:

/* Advanced Options */
$conf['userewrite']  = 1;                //this makes nice URLs but you need to enable it in .htaccess first 0|1

To turn on $conf['userslah'] you'll want the newest version (>2005-02-18a - possibly not yet available) and to configure $conf['baseurl'] to be the sub-directory the doku.php file is in off your doc root. ie wiki.example.com/subdir/doku.php (bold part).

Windows

:!: A backslash is appended to the full domain string, and before the DokuWiki's needed string that points to the target.

There's no known fix, yet. – 2004.11.03.

The provided .htaccess as shown below is working fine with Apache 2.0.49 on Windows XP Pro SP2. — Andreas Gohr 03.11.2004 20:06
But it's not working with Apache 2.0.5x on Windows 2000 or Windows XP. — José Carlos Monteiro 04.11.2004 11:46
On Windows XP with Apache 2.0.52 it works fine, can you please upload httpd.conf file so I can look at potential problems you might have? Here's my Apache2 2.0.52 config for WinXP and diff from default one — Eugene 'HMage' Bujak 04.11.2004 17:18
You don't use VirtualHosts. Could that be the reason for these issues in my environment? I've loaded WebDAV modules for Subversion but besides that there's not many changes from a default httpd.conf file. It seems the only major change is indeed using VirtualHosts in Apache2 for Windows. – 2004.11.04.
Strange I tried to use the rewrite rules and go page not found (I was trying to edit the start page). I am using Apache 2.0.49. I have set up an Alias /dokuwiki/ “c:/some path to dokuwiki”. I already had the mod_rewrite line uncommented. I have enabled the userwrite rule config option and uncommented the rewrite lines in the .htaccess file in the root of the dokuwiki stuff. Despite all of that it doesn't work and I am very puzzled why its not working. – 2004.11.12 Robert McGovern
On Windows XP SP2 with Apache 2.0.5x it still does not work for me. Here is my config, its seperated into multiple files because I use TSW. Download conf.rar2005.04.13

Linux

Under Linux, the current .htaccess file works fine:

## Comment these rules in if you want to have nice URLs
RewriteEngine on
RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

Don't forget to comment the AllowOverride None in <Directory>

Actually, I needed to specify Options FollowSymLinks and AllowOverride AuthConfig FileInfo Limit in <Directory> (Apache 2.2)

Don't forget Options FollowSymLinks in <Directory> too

I still get a 404 file not found error when I enable this, the rewrite module was on in apache already, I've set the thing in dokuwiki.php to 1, and uncommented the rules in .htaccess…what am I missing? 7.01.2005

PHP Engine On/Off

This is necessary to prevent unauthorized users to upload unknown code that could then be executed and perform unknown/unwanted operations without any security measure. Edit, or if the file doesn't exist then create, .htaccess in media/ folder, to have the following content.

Windows

:?: Setting php_value is not possible under Windows?
Yes, but only if PHP is loaded as an Apache Module. – 2004.11.08.

:!: Use RemoveType with all registered PHP file extensions. Consult Apache manual for how to use RemoveType. This is better, because PHP parser does not load at all, and things became faster. Anyway, it is recommended to do so in any directory, which is web-accessible, but php scripts aren't expected to run. - 2007-12-14

This feature is not available when using PHP as CGI module. — Eugene 'HMage' Bujak 07.11.2004 11:18MSK

To load PHP as an Apache Module, comment out the lines that enable PHP in CGI-mode:

# Comment: This line is not necessary, since the file php.exe will not handle .php files.
#ScriptAlias /php/ "<Path_to_PHP>"

# Comment: These lines are not necessary, since PHP extensions will be handled by PHP Apache Module.
# Action application/x-httpd-php "/php/php.exe"
# Action application/x-httpd-php3 "/php/php.exe"
# Action application/x-httpd-phtml "/php/php.exe"

And add this line to the list of Aapche Modules to load:

LoadModule php4_module "<Path_to_PHP>/sapi/php4apache2.dll"

Note: Replace <Path_to_PHP> with your own full path string to the PHP executable.

I needed two more steps to make it work, J. Siekmeyer, 08nov04:

  • copy the ”<Path_to_PHP>\php4ts.dll” to the ”<Path_to_PHP>/sapi” directory
  • append a line “AddModule mod_php4.c” after the all the other “AddModule” lines in the httpd.conf

Linux

Under Linux, the current .htaccess file works fine:

# disable PHP parsing for this directory
php_value engine off
AddType text/plain .php .phtml .php3 .html .htm .shtml

Virtual Host

Instead of having the entry URL pointing to http://www.<domain>.<tld>/dokuwiki one can use the Apache2 Virtual Hosts feature to use an URL pointing to http://wiki.<domain>.<tld>. Just edit the httpd.conf file and add the following lines to the end of it:

<VirtualHost *>
    ServerAdmin <webmaster>@<domain>.<tld>
    DocumentRoot <path_to_dokuwiki>
    ServerName wiki.<domain>.<tld>
    ErrorLog <path_to_apache2>/logs/wiki.<domain>.<tld>-error.log
    CustomLog <path_to_apache2>/logs/wiki.<domain>.<tld>-common.log common
</VirtualHost>

Notes:

  • Replace <domain>.<tld> with your own domain. For example mydomain.com.
  • Replace <path_to_dokuwiki> with your own full path to the dokuwiki top-folder.
  • Replace <path_to_apache2> with your own full path to the apache2 sub-folders (where logs/ is located).

Windows

:!: This causes the stylesheet style.css not to be loaded, and the site presentation is disrupted. There's no known fix, yet. – 2004.11.03.The releases after version 2005-01-16 have this bug fixed. – 2005.02.07.

I couldn't test this but it should work. Please give some more info - what does the Apache errorlog say? — Andreas Gohr 03.11.2004 20:12
Part of the problem is in this log:
127.0.1.4 - - [02/Nov/2004:11:50:20 +0000] "GET / HTTP/1.1" 200 13792
127.0.1.4 - - [02/Nov/2004:11:50:21 +0000] "GET /%5C/style.css HTTP/1.1" 404 411
127.0.1.4 - - [02/Nov/2004:11:50:21 +0000] "GET /%5C/print.css HTTP/1.1" 404 411
127.0.1.4 - - [02/Nov/2004:11:50:21 +0000] "GET /%5C/script.js HTTP/1.1" 404 411

But pointing to a DokuWiki installation other than on root of virtual host causes this log:

127.0.1.4 - - [02/Nov/2004:11:46:10 +0000] "GET /mywiki/doku.php?do=login&id=homepage HTTP/1.1" 200 10055
127.0.1.4 - - [02/Nov/2004:11:46:10 +0000] "GET /mywiki/style.css HTTP/1.1" 304 -
127.0.1.4 - - [02/Nov/2004:11:46:10 +0000] "GET /mywiki/print.css HTTP/1.1" 304 -
127.0.1.4 - - [02/Nov/2004:11:46:11 +0000] "GET /mywiki/script.js HTTP/1.1" 304 -

This second one, works fine. This first one doesn't, because of the backslash, code %5C, which I don't know why is being prefixed to the wiki string path. Some examples of Virtual Hosts are:

  • For the first case: http://wiki.mylocaldomain.lan/
  • For the second case:
    • http://wiki.mylocaldomain.lan/mywiki/
    • http://dev.mylocaldomain.lan/dokuwiki/

José Carlos Monteiro 04.11.2004 11:50

Linux

Under Linux, no other changes are necessary, and the stylesheet style.css is loaded just fine.

Windows Problems

I usually can not test DokuWiki on a Windows and/or Apache2 system so there may always be bugs I'm not aware of. When you report bugs please leave an email address or contact me directly per mail so I can contact you for questions. I did test the mod_rewrite and the PHP value setting functions mentioned above on my girlfriends laptop and they did work for me. So anybody having problems: please contact me. — Andreas Gohr 03.11.2004 20:14

Andi, this page wasn't so much to call your attention, rather more to discuss these issues with other active users of DokuWiki. That's why it's on a discussion namespace rather than on a bug “namespace”. You've been more than helpful, and I'm sure you have better and bigger things to do then to help me solve these Apache2 on Windows minor glitches. In any case, know that (speaking for myself) I do appreciate your great support, always. Thanks. — José Carlos Monteiro 04.11.2004 11:59
 
wiki/discussion/apache2.txt · Last modified: 2008/02/16 19:43 by 80.60.101.134
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate