DokuWiki

It's better when it's simple

User Tools

Site Tools


install:apache

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
install:apache [2016-01-31 19:32] – [Nice URLs using the .htaccess setting] 97.116.172.130install:apache [2023-10-27 13:40] (current) 80.125.1.180
Line 1: Line 1:
 ====== Apache ====== ====== Apache ======
  
-  - Create ''/etc/dokuwiki/apache.conf'' +[[https://httpd.apache.org/|Apache]] is the most widely used webserver with DokuWiki. Most hosting providers offering PHP hosting will also use Apache.
-  - Link <code>ll /etc/apache2/sites-available/ +
-lrwxrwxrwx 1 root root   25 Apr  5  2014 dokuwiki.conf -> /etc/dokuwiki/apache.conf </code> according to [[install:debian#apache]] +
-  - Enable the site with ''a2ensite dokuwiki'' +
-  - Restart / Reload apache +
-  - Setup [[:security|Security]]+
  
-===== /etc/dokuwiki/apache.conf ===== 
  
-  * change ''Alias'' and ''Allow from localhost 127.0.0.1 ::1'' to your needs+===== Installation =====
  
-<code> +Basically all Linux distributions offer an Apache package for easy installation. Please refer to your distribution's documentation on how to install software packages.
-AliasMatch ^/dokuwiki/sites/[^/]+$      /usr/share/dokuwiki/ +
-AliasMatch ^/dokuwiki/sites/[^/]+/(.*)$ /usr/share/dokuwiki/$1 +
-Alias      /dokuwiki                    /usr/share/dokuwiki/+
  
-<Directory /usr/share/dokuwiki/+Windows user can pick installation packages from various [[https://httpd.apache.org/docs/current/platform/windows.html#down|third party vendors]]A good alternative is also our [[install:dokuwiki_on_a_stick|DokuWiki on a Stick]].
-Options +FollowSymLinks +
-AllowOverride All +
-order allow,deny +
- Allow from localhost 127.0.0.1 ::1+
  
-        <IfModule mod_rewrite.c>+FIXME MacOS?
  
-                # Uncomment to implement server-side URL rewriting +===== Adding PHP support =====
-                # (cf. <http://www.dokuwiki.org/config:userewrite>). +
-                        # Do *not* mix that with multisite! +
-                #RewriteEngine on +
-                #RewriteBase /dokuwiki +
-                #RewriteRule ^lib                      - [L] +
-                #RewriteRule ^doku.php                 - [L] +
-                #RewriteRule ^feed.php                 - [L] +
-                #RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L] +
-                #RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1 [QSA,L] +
-                #RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2 [QSA,L] +
-                #RewriteRule ^$                        doku.php  [L] +
-                #RewriteRule (.*)                      doku.php?id=$1  [QSA,L] +
-        </IfModule> +
-</Directory>+
  
-<Directory /usr/share/dokuwiki/bin> +PHP can be added through mod_php or fpm.
-        Require all denied +
-</Directory>+
  
-<Directory /var/lib/dokuwiki/data+FIXME add info 
-        Require all denied + 
-</Directory>+===== Enabling .htaccess Support ===== 
 + 
 +[[wp>.htaccess]] 
 + 
 +FIXME add info 
 + 
 +See also: [[https://stackoverflow.com/questions/8551740/centos-htaccess-not-being-read|Stackoverflow: htaccess not being read]]. 
 + 
 +===== Rewriting for nicer URLs ===== 
 + 
 +To enable [[:rewrite|URL rewriting]] you first need to enable the [[https://httpd.apache.org/docs/current/mod/mod_rewrite.html|mod_rewrite]] module. On most Linux distributions this can be done by calling: 
 + 
 +  sudo a2enmod rewrite 
 +  sudo apache2ctl restart 
 + 
 +Rewrite rules can then be configured on a per vhost base or via a ''.htaccess'' file. The latter is the more common use - see above on how to enable ''.htaccess'' files. 
 + 
 +Dokuwiki comes with a distribution copy of the [[wp>.htaccess]]-file called ''.htaccess.dist'', simply rename the file to ''.htaccess'' and edit it to uncomment the appropriate lines. 
 + 
 +Here is an example how the rewrite rules should look like. 
 + 
 +<code apache> 
 +RewriteEngine on 
 + 
 +RewriteBase /dokuwiki 
 + 
 +RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L] 
 +RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L] 
 +RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L] 
 +RewriteRule ^$                        doku.php  [L] 
 +RewriteCond %{REQUEST_FILENAME}       !-f 
 +RewriteCond %{REQUEST_FILENAME}       !-d 
 +RewriteRule (.*)                      doku.php?id=$1  [B,QSA,L] 
 +RewriteRule ^index.php$               doku.php
 </code> </code>
  
 +Please note that the line ''RewriteBase /dokuwiki'' may not be needed at all. If you use it, you need to replace the ''/dokuwiki'' path with whatever directory you use in your URL to get to the wiki.  If your wiki appears at the top level of the domain (e.g. http://example.com points to the start page of the wiki) then use ''RewriteBase /''.
 +
 +B flag is required from apache 2.4.56 in order to avoid error ''AH10411: Rewritten query string contains control characters or spaces'' 
 +
 +==== Apachectl status broken ====
 +
 +Dokuwiki rewrite rules can affect the //apachectl status// command and make it return a DokuWiki 404 page instead of the server-status page. You can fix that by either adding an exception to the rewrite rules
 +
 +<code apache>
 +RewriteCond %{REQUEST_URI} !^/server-status$
 +</code>
 +
 +or creating an empty server-status file in dokuwiki root folder where doku.php is located.
 +
 +See forum post [[http://forum.dokuwiki.org/post/32858|Apachectl status is broken with dokuwiki]]
  
-====== Nice URLs using the .htaccess setting ====== 
-Dokuwiki comes with a distribution copy of the [[wp>.htaccess]]-file called .htaccess.dist. In the package manager installation, this file will be found in ''/etc/dokuwiki''; in the standard Dokuwiki installation it will be found in your top-level dokuwiki directory.  Copy this file to .htaccess.  Then uncomment all of the commented-out lines except for the https and and xmlrpc entries; you may want to enable these features at a later time but leave them alone initially. Commented lines begin with a hash (number sign), as in:  
-     #RewriteEngine on 
-Remove the hash to uncomment the line: 
-      RewriteEngine on 
  
-Uncommenting the lines will create a set of substitutions which the web server will make in order to format nice urls.  +==== See Also ====
  
-The next thing you need to do is to enable apache's rewrite module.  Again from the command line: 
-      sudo a2enmod rewrite 
-This will update the configuration files; then you must restart the server: 
-       sudo service apache2 restart 
-It should be noted that if ever the ''service'' command does not work, you can do the same with this command: 
-     sudo /etc/init.d/apache2 restart 
  
-You must always use ''sudo'' with these commands because they require root user access.+  * [[https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules | Tips for debugging .htaccess rewrite rules]]
  
install/apache.1454265178.txt.gz · Last modified: 2016-01-31 19:32 by 97.116.172.130

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki