CINXE.COM

install:nginx [DokuWiki]

<!DOCTYPE html> <html lang="en" dir="ltr" class="no-js"> <head> <meta charset="utf-8" /> <title>install:nginx [DokuWiki]</title> <meta name="generator" content="DokuWiki"/> <meta name="theme-color" content="#008800"/> <meta name="robots" content="index,follow"/> <meta name="keywords" content="install,nginx"/> <link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="DokuWiki"/> <link rel="start" href="/"/> <link rel="contents" href="/install:nginx?do=index" title="Sitemap"/> <link rel="manifest" href="/lib/exe/manifest.php" crossorigin="use-credentials"/> <link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/feed.php"/> <link rel="alternate" type="application/rss+xml" title="Current namespace" href="/feed.php?mode=list&amp;ns=install"/> <link rel="edit" title="Edit this page" href="/install:nginx?do=edit"/> <link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/install:nginx"/> <link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/install:nginx"/> <link rel="canonical" href="https://www.dokuwiki.org/install:nginx"/> <link rel="stylesheet" href="/lib/exe/css.php?t=dokuwiki&amp;tseed=7ae64dbeb6443493d1676fcfa66176f2"/> <link rel="alternate" hreflang="ja" href="https://www.dokuwiki.org/ja:install:nginx"/> <link rel="alternate" hreflang="pt-br" href="https://www.dokuwiki.org/pt-br:install:nginx"/> <link rel="alternate" hreflang="x-default" href="https://www.dokuwiki.org/install:nginx"/> <script >var NS='install';var JSINFO = {"plugins":{"edittable":{"default columnwidth":""}},"id":"install:nginx","namespace":"install","ACT":"show","useHeadingNavigation":0,"useHeadingContent":0};(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" defer="defer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.14.1/jquery-ui.min.js" defer="defer"></script> <script src="/lib/exe/js.php?t=dokuwiki&amp;tseed=7ae64dbeb6443493d1676fcfa66176f2&amp;lang=en" defer="defer"></script> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link rel="shortcut icon" href="/lib/tpl/dokuwiki/images/favicon.ico" /> <link rel="apple-touch-icon" href="/lib/tpl/dokuwiki/images/apple-touch-icon.png" /> <meta name="verify-v1" content="OVxl3gsCv2MhZqh1cBQyl0JytWXSwXMjyvwc+4w3WtA=" /> <meta name="google-site-verification" content="YhTVK69hW94ZXUtc2zSLPxTkZKbZIn0zK67mz5WQB-E" /> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-83791-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-83791-1', { 'anonymize_ip': true }); </script> </head> <body> <div id="dokuwiki__site"><div id="dokuwiki__top" class="site dokuwiki mode_show tpl_dokuwiki showSidebar hasSidebar"> <!-- ********** HEADER ********** --> <header id="dokuwiki__header"><div class="pad group"> <div class="headings group"> <ul class="a11y skip"> <li><a href="#dokuwiki__content">skip to content</a></li> </ul> <h1 class="logo"><a href="/start" accesskey="h" title="Home [h]"><img src="/lib/tpl/dokuwiki/images/logo.png" width="64" height="64" alt="" /><span>DokuWiki</span></a></h1> <p class="claim">It's better when it's simple</p> </div> <div class="tools group"> <!-- USER TOOLS --> <div id="dokuwiki__usertools"> <h3 class="a11y">User Tools</h3> <ul> <li class="action login"><a href="/install:nginx?do=login&amp;sectok=" title="Log In" rel="nofollow"><span>Log In</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10 17.25V14H3v-4h7V6.75L15.25 12 10 17.25M8 2h9a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-4h2v4h9V4H8v4H6V4a2 2 0 0 1 2-2z"/></svg></a></li> </ul> </div> <!-- SITE TOOLS --> <div id="dokuwiki__sitetools"> <h3 class="a11y">Site Tools</h3> <form action="/start" method="get" role="search" class="search doku_form" id="dw__search" accept-charset="utf-8"><input type="hidden" name="do" value="search" /><input type="hidden" name="id" value="install:nginx" /><div class="no"><input name="q" type="text" class="edit" title="[F]" accesskey="f" placeholder="Search" autocomplete="on" id="qsearch__in" value="" /><button value="1" type="submit" title="Search">Search</button><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form> <div class="mobileTools"> <form action="/doku.php" method="get" accept-charset="utf-8"><div class="no"><input type="hidden" name="id" value="install:nginx" /><select name="do" class="edit quickselect" title="Tools"><option value="">Tools</option><optgroup label="Page Tools"><option value="edit">Edit this page</option><option value="revisions">Old revisions</option><option value="backlink">Backlinks</option></optgroup><optgroup label="Site Tools"><option value="recent">Recent Changes</option><option value="media">Media Manager</option><option value="index">Sitemap</option></optgroup><optgroup label="User Tools"><option value="login">Log In</option></optgroup></select><button type="submit">&gt;</button></div></form> </div> <ul> <li class="action recent"><a href="/install:nginx?do=recent" title="Recent Changes [r]" rel="nofollow" accesskey="r">Recent Changes</a></li><li class="action media"><a href="/install:nginx?do=media&amp;ns=install" title="Media Manager" rel="nofollow">Media Manager</a></li><li class="action index"><a href="/install:nginx?do=index" title="Sitemap [x]" rel="nofollow" accesskey="x">Sitemap</a></li> </ul> </div> </div> <!-- BREADCRUMBS --> <div class="breadcrumbs"> <div class="trace"><span class="bchead">Trace:</span> <span class="bcsep">•</span> <span class="curid"><bdi><a href="/install:nginx" class="breadcrumbs" title="install:nginx">nginx</a></bdi></span></div> </div> <hr class="a11y" /> </div></header><!-- /header --> <div class="wrapper group"> <!-- ********** ASIDE ********** --> <nav id="dokuwiki__aside" aria-label="Sidebar"><div class="pad aside include group"> <h3 class="toggle">Sidebar</h3> <div class="content"><div class="group"> <div class="plugin_translation is-dropdown"><span class="title">Translations of this page<sup><a href="/localization" class="wikilink1" title="localization" data-wiki-id="localization">?</a></sup>: </span><ul><li class="span"><span class="wikilink1" title="English">English (en)</span></li><li class="a"><a class="wikilink2" title="|العربية" href="/ar:install:nginx">|العربية (ar)</a></li><li class="a"><a class="wikilink2" title="Català" href="/ca:install:nginx">Català (ca)</a></li><li class="a"><a class="wikilink2" title="Česky" href="/cs:install:nginx">Česky (cs)</a></li><li class="a"><a class="wikilink2" title="Dansk" href="/da:install:nginx">Dansk (da)</a></li><li class="a"><a class="wikilink2" title="Deutsch" href="/de:install:nginx">Deutsch (de)</a></li><li class="a"><a class="wikilink2" title="Ελληνικά" href="/el:install:nginx">Ελληνικά (el)</a></li><li class="a"><a class="wikilink2" title="Esperanto" href="/eo:install:nginx">Esperanto (eo)</a></li><li class="a"><a class="wikilink2" title="Español" href="/es:install:nginx">Español (es)</a></li><li class="a"><a class="wikilink2" title="فارسی" href="/fa:install:nginx">فارسی (fa)</a></li><li class="a"><a class="wikilink2" title="Français" href="/fr:install:nginx">Français (fr)</a></li><li class="a"><a class="wikilink2" title="עברית" href="/he:install:nginx">עברית (he)</a></li><li class="a"><a class="wikilink2" title="Magyar" href="/hu:install:nginx">Magyar (hu)</a></li><li class="a"><a class="wikilink2" title="Italiano" href="/it:install:nginx">Italiano (it)</a></li><li class="a"><a class="wikilink1" title="日本語" href="/ja:install:nginx">日本語 (ja)</a></li><li class="a"><a class="wikilink2" title="한국어" href="/ko:install:nginx">한국어 (ko)</a></li><li class="a"><a class="wikilink2" title="Lietuvių Kalba" href="/lt:install:nginx">Lietuvių Kalba (lt)</a></li><li class="a"><a class="wikilink2" title="Nederlands" href="/nl:install:nginx">Nederlands (nl)</a></li><li class="a"><a class="wikilink2" title="Norsk" href="/no:install:nginx">Norsk (no)</a></li><li class="a"><a class="wikilink2" title="Polski" href="/pl:install:nginx">Polski (pl)</a></li><li class="a"><a class="wikilink1" title="Português" href="/pt-br:install:nginx">Português (pt-br)</a></li><li class="a"><a class="wikilink2" title="Română" href="/ro:install:nginx">Română (ro)</a></li><li class="a"><a class="wikilink2" title="Русский" href="/ru:install:nginx">Русский (ru)</a></li><li class="a"><a class="wikilink2" title="Српски Језик" href="/sr:install:nginx">Српски Језик (sr)</a></li><li class="a"><a class="wikilink2" title="Svenska" href="/sv:install:nginx">Svenska (sv)</a></li><li class="a"><a class="wikilink2" title="ไทย" href="/th:install:nginx">ไทย (th)</a></li><li class="a"><a class="wikilink2" title="Українська" href="/uk:install:nginx">Українська (uk)</a></li><li class="a"><a class="wikilink2" title="中文" href="/zh:install:nginx">中文 (zh)</a></li><li class="a"><a class="wikilink2" title="繁體中文" href="/zh-tw:install:nginx">繁體中文 (zh-tw)</a></li></ul></div> <p> <strong>Learn about DokuWiki</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/features" class="wikilink1" title="features" data-wiki-id="features">Features</a> &amp; <a href="/blogroll" class="wikilink1" title="blogroll" data-wiki-id="blogroll">reviews</a> </div> </li> <li class="level1"><div class="li"> <a href="/install" class="wikilink1" title="install" data-wiki-id="install">Installation guide</a></div> </li> <li class="level1"><div class="li"> <a href="/manual" class="wikilink1" title="manual" data-wiki-id="manual">User manual</a> &amp; <a href="/wiki:syntax" class="wikilink1" title="wiki:syntax" data-wiki-id="wiki:syntax">syntax</a></div> </li> <li class="level1"><div class="li"> <a href="/changes" class="wikilink1" title="changes" data-wiki-id="changes">Release notes</a></div> </li> <li class="level1"><div class="li"> <a href="/faq" class="wikilink1" title="faq" data-wiki-id="faq">FAQ</a></div> </li> </ul> <p> <strong>Advanced Use</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/extensions" class="wikilink1" title="extensions" data-wiki-id="extensions">Extensions</a></div> </li> <li class="level1"><div class="li"> <a href="/development" class="wikilink1" title="development" data-wiki-id="development">Development manual</a></div> </li> </ul> <p> <strong>Corporate Use</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/faq:support" class="wikilink1" title="faq:support" data-wiki-id="faq:support">Get support</a></div> </li> <li class="level1"><div class="li"> <a href="/donate" class="wikilink1" title="donate" data-wiki-id="donate">Donations</a></div> </li> </ul> <p> <strong>Our Community</strong> </p> <ul> <li class="level1"><div class="li"> <a href="/teams:getting_involved" class="wikilink1" title="teams:getting_involved" data-wiki-id="teams:getting_involved">Get involved</a></div> </li> <li class="level1"><div class="li"> <a href="/dokuinstall" class="wikilink1" title="dokuinstall" data-wiki-id="dokuinstall">Users</a></div> </li> <li class="level1"><div class="li"> <a href="http://forum.dokuwiki.org" class="urlextern" title="http://forum.dokuwiki.org">User forum</a></div> </li> <li class="level1"><div class="li"> <a href="/mailinglist" class="wikilink1" title="mailinglist" data-wiki-id="mailinglist">Development mailinglist</a></div> </li> </ul> <hr /> <p> Follow us on <a href="https://phpc.social/@dokuwiki" class="urlextern" title="https://phpc.social/@dokuwiki">Mastodon</a> and other <a href="/social" class="wikilink1" title="social" data-wiki-id="social">social networks</a>. </p> <p> <a href="/privacy" class="wikilink1" title="privacy" data-wiki-id="privacy">Our Privacy Policy</a> </p> </div></div> </div></nav><!-- /aside --> <!-- ********** CONTENT ********** --> <main id="dokuwiki__content"><div class="pad group"> <div class="pageId"><span>install:nginx</span></div> <div class="page group"> <!-- wikipage start --> <!-- TOC START --> <div id="dw__toc" class="dw__toc"> <h3 class="toggle">Table of Contents</h3> <div> <ul class="toc"> <li class="level1"><div class="li"><a href="#nginx">Nginx</a></div> <ul class="toc"> <li class="level2"><div class="li"><a href="#basic_knowledge">Basic knowledge</a></div> <ul class="toc"> <li class="level3"><div class="li"><a href="#nginx1">Nginx</a></div></li> <li class="level3"><div class="li"><a href="#php-fpm">PHP-FPM</a></div></li> <li class="level3"><div class="li"><a href="#distribution_specifics">Distribution specifics</a></div></li> <li class="level3"><div class="li"><a href="#troubleshooting">Troubleshooting</a></div></li> </ul> </li> <li class="level2"><div class="li"><a href="#recipe_example">Recipe / Example</a></div></li> </ul></li> </ul> </div> </div> <!-- TOC END --> <h1 class="sectionedit1" id="nginx">Nginx</h1> <div class="level1"> <p> Nginx here is used as a webserver for serving static (html, jpg) and dynamic content (php). </p> <blockquote><div class="no"> <img src="/lib/images/smileys/fixme.svg" class="icon smiley" alt="FIXME" /><br/> Windows part is untested - remove or add information?<br/> ADD Content for PHP/PHP-FPM<br/> Recipe needs some testing, optimization and documentation<br/> Compare recipe to <a href="https://web.archive.org/web/20240214213649/https://www.nginx.com/resources/wiki/start/topics/recipes/dokuwiki/" class="urlextern" title="https://web.archive.org/web/20240214213649/https://www.nginx.com/resources/wiki/start/topics/recipes/dokuwiki/">nginx.com/.../dokuwiki</a><br/> * <abbr title="Uniform Resource Locator">URL</abbr> rewriting for mode “.htaccess”<br/> * X-Accel handling - further research<br/> WIP - feel free to change</div></blockquote> </div> <div class="secedit editbutton_section editbutton_1"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Nginx] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="nginx" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="1-537" /><button type="submit" title="Nginx">Edit</button></div></form></div> <h2 class="sectionedit2" id="basic_knowledge">Basic knowledge</h2> <div class="level2"> <p> How to install Nginx and where to find configuration files. </p> </div> <div class="secedit editbutton_section editbutton_2"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Basic knowledge] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="basic_knowledge" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="538-627" /><button type="submit" title="Basic knowledge">Edit</button></div></form></div> <h3 class="sectionedit3" id="nginx1">Nginx</h3> <div class="level3"> <pre class="code bash"><span class="co0"># Installation of Nginx</span> &nbsp; $ apk add nginx <span class="co0"># Alpine Linux</span> $ <span class="kw2">sudo</span> <span class="kw2">apt-get install</span> nginx <span class="co0"># Debian / Ubuntu</span></pre> <p> <strong>Configuration</strong><br/> </p> <p> In most Linux distributions the base configuration takes place in the file <code>/etc/nginx/nginx.conf</code>, but the further configuration is located in subdirectories. </p> <p> So <strong>we focus on putting the “recipe” - configuration file in a subdirectory</strong> under <code>./http.d/</code> (Alpine Linux) or <code>./sites-enabled/</code> (Ubuntu, Debian). The configuration file should be named like <code>filename.conf</code>. </p> <pre class="code bash"><span class="co0"># Create / edit configuration file</span> &nbsp; <span class="co0"># Alpine Linux</span> <span class="kw2">nano</span> <span class="sy0">/</span>etc<span class="sy0">/</span>nginx<span class="sy0">/</span>http.d<span class="sy0">/</span>dokuwiki.conf <span class="kw2">vi</span> <span class="sy0">/</span>etc<span class="sy0">/</span>nginx<span class="sy0">/</span>http.d<span class="sy0">/</span>dokuwiki.conf <span class="co0"># [ESC] :q</span> &nbsp; <span class="co0"># Debian / Ubuntu</span> <span class="kw2">nano</span> <span class="sy0">/</span>etc<span class="sy0">/</span>nginx<span class="sy0">/</span>sites-available<span class="sy0">/</span>dokuwiki.conf <span class="kw2">ln</span> <span class="re5">-s</span> <span class="sy0">/</span>etc<span class="sy0">/</span>nginx<span class="sy0">/</span>sites-available<span class="sy0">/</span>dokuwiki.conf <span class="sy0">/</span>etc<span class="sy0">/</span>nginx<span class="sy0">/</span>sites-enabled<span class="sy0">/</span></pre> <p> If we change the configuration, it is necessary to reload it or to restart the nginx - server. </p> <pre class="code bash"><span class="co0"># Reload configuration</span> &nbsp; systemctl reload nginx <span class="co0"># systemd (Debian, Ubuntu)</span> &nbsp; service nginx reload <span class="co0"># some other (Alpine Linux)</span> lbu commit <span class="co0"># Alpine Linux specific</span></pre> </div> <div class="secedit editbutton_section editbutton_3"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Nginx] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="nginx1" /><input type="hidden" name="codeblockOffset" value="0" /><input type="hidden" name="range" value="628-1785" /><button type="submit" title="Nginx">Edit</button></div></form></div> <h3 class="sectionedit4" id="php-fpm">PHP-FPM</h3> <div class="level3"> <p> PHP-FPM needs to be installed to run dokuwiki. It might be a good idea to <a href="/install:php" class="wikilink1" title="install:php" data-wiki-id="install:php">install and configure</a> it first. Nginx uses php-fpm to serve dynamic content. </p> <ul> <li class="level1"><div class="li"> TODO Explanation fo difference between (F)CGI and FPM.</div> </li> <li class="level1"><div class="li"> No need to explain how to set up FPM</div> </li> </ul> </div> <div class="secedit editbutton_section editbutton_4"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[PHP-FPM] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="php-fpm" /><input type="hidden" name="codeblockOffset" value="3" /><input type="hidden" name="range" value="1786-2074" /><button type="submit" title="PHP-FPM">Edit</button></div></form></div> <h3 class="sectionedit5" id="distribution_specifics">Distribution specifics</h3> <div class="level3"> <p> <strong>Windows</strong> <br/> If dokuwiki is extracted to the directory <code>E:\www\dokuwiki</code> the root directive in the server part of the nginx-configuration has to be <code>root E:\www\dokuwiki;</code>. </p> <pre class="code bash"><span class="co0"># Start PHP FastCGI</span> RunHiddenConsole.exe E:\appl\php-5.2.9-<span class="nu0">2</span>-Win32\php-cgi.exe <span class="re5">-b</span> 127.0.0.1:<span class="nu0">9000</span> &nbsp; <span class="co0"># Start NginX</span> <span class="kw3">cd</span> <span class="sy0">/</span>d D:\nginx-0.8.39 <span class="sy0">&amp;&amp;</span> start nginx.exe</pre> </div> <div class="secedit editbutton_section editbutton_5"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Distribution specifics] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="distribution_specifics" /><input type="hidden" name="codeblockOffset" value="3" /><input type="hidden" name="range" value="2075-2463" /><button type="submit" title="Distribution specifics">Edit</button></div></form></div> <h3 class="sectionedit6" id="troubleshooting">Troubleshooting</h3> <div class="level3"> <ul> <li class="level1"><div class="li"> If you encounter a 502 Gateway issue, the socket configuration might be incorrect</div> </li> <li class="level1"><div class="li"> Reload or restart Nginx to apply the new configuration</div> </li> <li class="level1"><div class="li"> On the initial setup you won&#039;t be able to start unless you comment the deny to the “install.php” file.</div> </li> </ul> </div> <div class="secedit editbutton_section editbutton_6"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Troubleshooting] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="troubleshooting" /><input type="hidden" name="codeblockOffset" value="4" /><input type="hidden" name="range" value="2464-2746" /><button type="submit" title="Troubleshooting">Edit</button></div></form></div> <h2 class="sectionedit7" id="recipe_example">Recipe / Example</h2> <div class="level2"> <p> This is an example with a full configuration for Dokuwiki under Nginx. You can simply copy paste and change the parts to your liking. </p> <p> <img src="/lib/images/smileys/exclaim.svg" class="icon smiley" alt=":!:" /> On the initial setup you won&#039;t be able to start unless you comment the deny to the “install.php” file. </p> <dl class="code"> <dt><a href="/_export/code/install:nginx?codeblock=4" title="Download Snippet" class="mediafile mf_conf">dokuwiki.conf</a></dt> <dd><pre class="code nginx"><span class="co1"># Example Nginx - configuration file for Dokuwiki from </span> <span class="co1"># https://www.dokuwiki.org/install:nginx</span> &nbsp; &nbsp; <span class="co1"># PHP Handler</span> <a href="http://wiki.nginx.org/NginxHttpUpstreamModule#upstream"><span class="kw4">upstream</span></a> php-handler <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#server"><span class="kw3">server</span></a> unix:/run/php-fpm82/fastcgi.sock<span class="sy0">;</span> <span class="co1"># Alpine Linux (socket)</span> <span class="co1"># server unix:/var/run/php/php-fpm.sock; # Debian/Ubuntu (socket)</span> <span class="co1"># server unix:/var/run/php/php8.1-fpm.sock; # Debian/Ubuntu (socket) (PHP-specific)</span> <span class="co1"># server 127.0.0.1:9000; # Distro independent</span> &nbsp; <span class="br0">&#125;</span> &nbsp; <span class="co1"># Redirect SSL/443 (optional - recommended)</span> <span class="co1">#server {</span> <span class="co1"># server_name default_server;</span> <span class="co1"># listen 80; # IPv4</span> <span class="co1"># listen [::]:80; # IPv6</span> <span class="co1"># return 301 https://$server_name$request_uri;</span> <span class="co1">#}</span> &nbsp; &nbsp; &nbsp; <span class="co1"># Actual configuration</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#server"><span class="kw3">server</span></a> <span class="br0">&#123;</span> &nbsp; <span class="co1"># BASICS ######### ######### ######### ######### ######### ######### ####### ###</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#server_name"><span class="kw3">server_name</span></a> default_server<span class="sy0">;</span> <span class="co1"># optional: your domain name</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#root"><span class="kw3">root</span></a> /var/www/dokuwiki<span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpIndexModule#index"><span class="kw15">index</span></a> doku.php<span class="sy0">;</span> &nbsp; <span class="co1"># NoSSL version (not recommended)</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#listen"><span class="kw3">listen</span></a> 80<span class="sy0">;</span> <span class="co1"># IPv4</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#listen"><span class="kw3">listen</span></a> <span class="br0">&#91;</span>::<span class="br0">&#93;</span>:80<span class="sy0">;</span> <span class="co1"># IPv6</span> &nbsp; <span class="co1"># SSL version (recommended)</span> <span class="co1"># listen 443 ssl; # IPv4</span> <span class="co1"># listen [::]:443 ssl; # IPv6</span> <span class="co1"># http2 on; # if supported, optional</span> &nbsp; <span class="co1"># ssl_certificate /etc/ssl/certs/***.crt;</span> <span class="co1"># ssl_certificate_key /etc/ssl/private/***.key;</span> &nbsp; <span class="co1"># Optional - further research recommended</span> <span class="co1"># ssl_seesion_timeout 5m;</span> <span class="co1"># ssl_ciphers &quot;HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES&quot;;</span> <span class="co1"># ssl_dhparam /etc/ssl/private/dhparam2048.pem;</span> <span class="co1"># openssl dhparam -outform pem -out /etc/nginx/ssl/dhparam2048.pem 2048</span> &nbsp; <span class="co1"># HEADERS ######### ######### ######### ######### ######### ######### ##########</span> <span class="co1"># Information &quot;leaks&quot;</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#server_tokens"><span class="kw3">server_tokens</span></a> off<span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_hide_header"><span class="kw11">fastcgi_hide_header</span></a> X-Powered_by<span class="sy0">;</span> &nbsp; <span class="co1"># TWEAKS ######### ######### ######### ######### ######### ######### ####### ##</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#client_max_body_size"><span class="kw3">client_max_body_size</span></a> 4M<span class="sy0">;</span> <span class="co1"># Maximum file upload size</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#client_body_buffer_size"><span class="kw3">client_body_buffer_size</span></a> 128k<span class="sy0">;</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="sy0">~</span> ^/lib.*\.<span class="br0">&#40;</span>js|css|gif|png|ico|jpg|jpeg|svg<span class="br0">&#41;</span>$ <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpHeadersModule#expires"><span class="kw14">expires</span></a> 365d<span class="sy0">;</span> <span class="co1"># browser caching</span> <span class="br0">&#125;</span> &nbsp; &nbsp; <span class="co1"># RESTRICT ACCESS ######### ######### ######### ######### ######### ######### ##</span> <span class="co1"># Reference: https://www.dokuwiki.org/security#deny_directory_access_in_nginx</span> <span class="co1"># TODO: Compare with this</span> &nbsp; &nbsp; <span class="co1"># Comment out while installing, then uncomment</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="sy0">~</span> /<span class="br0">&#40;</span>install.php<span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpAccessModule#deny"><span class="kw5">deny</span></a> all<span class="sy0">;</span> <span class="br0">&#125;</span> &nbsp; &nbsp; <span class="co1"># .ht - .htaccess, .htpasswd, .htdigest, .htanything</span> <span class="co1"># .git, .hg, .svn - Git, Mercurial, Subversion.</span> <span class="co1"># .vs - Visual Studio (Code)</span> <span class="co1"># All directories except lib.</span> <span class="co1"># All &quot;other&quot; files that you don't want to delete, but don't want public.</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="sy0">~</span> /<span class="br0">&#40;</span>\.ht|\.git|\.hg|\.svn|\.vs|data|conf|bin|inc|vendor|README|VERSION|SECURITY.md|COPYING|composer.json|composer.lock<span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="co1">#return 404; # https://www.dokuwiki.org/install:nginx?rev=1734102057#nginx_particulars</span> <a href="http://wiki.nginx.org/NginxHttpAccessModule#deny"><span class="kw5">deny</span></a> all<span class="sy0">;</span> <span class="co1"># Returns 403</span> <span class="br0">&#125;</span> &nbsp; <span class="co1">######################</span> <span class="co1"># (2024-08): Is this actually a default feature or does</span> <span class="co1"># this belong in a seperate section? Disable by default?</span> &nbsp; <span class="co1"># Support for X-Accel-Redirect</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="sy0">~</span> ^/data/ <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#internal"><span class="kw3">internal</span></a><span class="sy0">;</span> <span class="br0">&#125;</span> <span class="co1">########################</span> &nbsp; <span class="co1"># REDIRECT &amp; PHP ### ######### ######### ######### ######### ######### ######### </span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> / <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#try_files"><span class="kw3">try_files</span></a> <span class="re0">$uri</span> <span class="re0">$uri</span>/ <span class="re0">@dokuwiki</span><span class="sy0">;</span> &nbsp; <span class="co1"># This means; where $uri is 'path', if 'GET /path' doesnt exist, redirect</span> <span class="co1"># client to 'GET /path/' directory. If neither, goto @dokuwiki rules.</span> <span class="br0">&#125;</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="re0">@dokuwiki</span> <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpRewriteModule#rewrite"><span class="kw24">rewrite</span></a> ^/_media/<span class="br0">&#40;</span>.*<span class="br0">&#41;</span> /lib/exe/fetch.php?media<span class="sy0">=</span>$1 last<span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpRewriteModule#rewrite"><span class="kw24">rewrite</span></a> ^/_detail/<span class="br0">&#40;</span>.*<span class="br0">&#41;</span> /lib/exe/detail.php?media<span class="sy0">=</span>$1 last<span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpRewriteModule#rewrite"><span class="kw24">rewrite</span></a> ^/_export/<span class="br0">&#40;</span><span class="br0">&#91;</span>^/<span class="br0">&#93;</span>+<span class="br0">&#41;</span>/<span class="br0">&#40;</span>.*<span class="br0">&#41;</span> /doku.php?do<span class="sy0">=</span>export_$1&amp;id<span class="sy0">=</span>$2 last<span class="sy0">;</span> <span class="co1"># rewrite ^/tag/(.*) /doku.php?id=tag:$1&amp;do=showtag&amp;tag=tag:$1 last; #untested</span> <a href="http://wiki.nginx.org/NginxHttpRewriteModule#rewrite"><span class="kw24">rewrite</span></a> ^/<span class="br0">&#40;</span>.*<span class="br0">&#41;</span> /doku.php?id<span class="sy0">=</span>$1&amp;<span class="re0">$args</span> last<span class="sy0">;</span> &nbsp; <span class="co1"># rewrites &quot;doku.php/&quot; out of the URLs if you set the userewrite</span> <span class="co1"># setting to .htaccess in dokuwiki config page</span> <span class="br0">&#125;</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> <span class="sy0">~</span> \.php$ <span class="br0">&#123;</span> <a href="http://wiki.nginx.org/NginxHttpCoreModule#try_files"><span class="kw3">try_files</span></a> <span class="re0">$uri</span> <span class="re0">$uri</span>/ /doku.php<span class="sy0">;</span> &nbsp; <a href="http://wiki.nginx.org/CoreModule#include"><span class="kw1">include</span></a> fastcgi_params<span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_param"><span class="kw11">fastcgi_param</span></a> SCRIPT_FILENAME <span class="re0">$document_root</span><span class="re0">$fastcgi_script_name</span><span class="sy0">;</span> <a href="http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_param"><span class="kw11">fastcgi_param</span></a> REDIRECT_STATUS 200<span class="sy0">;</span> <span class="co1"># fastcgi_param HTTPS on; # optional ?! TODO</span> &nbsp; <a href="http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_pass"><span class="kw11">fastcgi_pass</span></a> php-handler<span class="sy0">;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> &nbsp; &nbsp; &nbsp; <span class="co1"># Credits</span> <span class="co1"># https://www.nginx.com/resources/wiki/start/topics/recipes/dokuwiki/</span> <span class="co1"># https://wiki.boetes.org/dokuwiki_on_nginx</span> <span class="co1"># http://blog.slucas.fr/blog/nginx-gzip-css-js</span></pre> </dd></dl> </div> <div class="secedit editbutton_section editbutton_7"><form class="button btn_secedit" method="post" action="/install:nginx"><div class="no"><input type="hidden" name="do" value="edit" /><input type="hidden" name="rev" value="1743844198" /><input type="hidden" name="summary" value="[Recipe / Example] " /><input type="hidden" name="target" value="section" /><input type="hidden" name="hid" value="recipe_example" /><input type="hidden" name="codeblockOffset" value="4" /><input type="hidden" name="range" value="2747-" /><button type="submit" title="Recipe / Example">Edit</button></div></form></div> <!-- wikipage stop --> </div> <div class="docInfo"><bdi>install/nginx.txt</bdi> · Last modified: <time datetime="2025-04-05T11:09:58+0200">2025-04-05 11:09</time> by <bdi>2a0c:5a82:e30f:df00:6e1f:f7ff:fe03:7b0d</bdi></div> <hr class="a11y" /> </div></main><!-- /content --> <!-- PAGE ACTIONS --> <nav id="dokuwiki__pagetools" aria-labelledby="dokuwiki__pagetools__heading"> <h3 class="a11y" id="dokuwiki__pagetools__heading">Page Tools</h3> <div class="tools"> <ul> <li class="edit"><a href="/install:nginx?do=edit" title="Edit this page [e]" rel="nofollow" accesskey="e"><span>Edit this page</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg></a></li><li class="revs"><a href="/install:nginx?do=revisions" title="Old revisions [o]" rel="nofollow" accesskey="o"><span>Old revisions</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M11 7v5.11l4.71 2.79.79-1.28-4-2.37V7m0-5C8.97 2 5.91 3.92 4.27 6.77L2 4.5V11h6.5L5.75 8.25C6.96 5.73 9.5 4 12.5 4a7.5 7.5 0 0 1 7.5 7.5 7.5 7.5 0 0 1-7.5 7.5c-3.27 0-6.03-2.09-7.06-5h-2.1c1.1 4.03 4.77 7 9.16 7 5.24 0 9.5-4.25 9.5-9.5A9.5 9.5 0 0 0 12.5 2z"/></svg></a></li><li class="backlink"><a href="/install:nginx?do=backlink" title="Backlinks" rel="nofollow"><span>Backlinks</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M10.59 13.41c.41.39.41 1.03 0 1.42-.39.39-1.03.39-1.42 0a5.003 5.003 0 0 1 0-7.07l3.54-3.54a5.003 5.003 0 0 1 7.07 0 5.003 5.003 0 0 1 0 7.07l-1.49 1.49c.01-.82-.12-1.64-.4-2.42l.47-.48a2.982 2.982 0 0 0 0-4.24 2.982 2.982 0 0 0-4.24 0l-3.53 3.53a2.982 2.982 0 0 0 0 4.24m2.82-4.24c.39-.39 1.03-.39 1.42 0a5.003 5.003 0 0 1 0 7.07l-3.54 3.54a5.003 5.003 0 0 1-7.07 0 5.003 5.003 0 0 1 0-7.07l1.49-1.49c-.01.82.12 1.64.4 2.43l-.47.47a2.982 2.982 0 0 0 0 4.24 2.982 2.982 0 0 0 4.24 0l3.53-3.53a2.982 2.982 0 0 0 0-4.24.973.973 0 0 1 0-1.42z"/></svg></a></li><li class="top"><a href="#dokuwiki__top" title="Back to top [t]" rel="nofollow" accesskey="t"><span>Back to top</span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"/></svg></a></li> </ul> </div> </nav> </div><!-- /wrapper --> <!-- ********** FOOTER ********** --> <footer id="dokuwiki__footer"><div class="pad"> <div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <bdi><a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en" rel="license" class="urlextern">CC Attribution-Share Alike 4.0 International</a></bdi></div> <div class="buttons"> <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en" rel="license"><img src="/lib/images/license/button/cc-by-sa.png" alt="CC Attribution-Share Alike 4.0 International" /></a> <a href="https://www.dokuwiki.org/donate" title="Donate" ><img src="/lib/tpl/dokuwiki/images/button-donate.gif" width="80" height="15" alt="Donate" /></a> <a href="https://php.net" title="Powered by PHP" ><img src="/lib/tpl/dokuwiki/images/button-php.gif" width="80" height="15" alt="Powered by PHP" /></a> <a href="//validator.w3.org/check/referer" title="Valid HTML5" ><img src="/lib/tpl/dokuwiki/images/button-html5.png" width="80" height="15" alt="Valid HTML5" /></a> <a href="//jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS" ><img src="/lib/tpl/dokuwiki/images/button-css.png" width="80" height="15" alt="Valid CSS" /></a> <a href="https://dokuwiki.org/" title="Driven by DokuWiki" ><img src="/lib/tpl/dokuwiki/images/button-dw.png" width="80" height="15" alt="Driven by DokuWiki" /></a> </div> <div style="margin-top: 2em; font-size:90%" class="dokuwiki"><div style="float:right"><a href="http://www.splitbrain.org/personal#imprint" style="float:right; text-decoration: none; color:#333">Imprint</a></div></div><!-- Include for DokuWiki site wide top bar --> <style type="text/css"> @media screen { body { padding-top: 30px; } #global__header { position: absolute; top: 0; left: 0; text-align: left; vertical-align: middle; line-height: 1.5; background-color: #333; box-shadow: 0 0 8px rgba(0,0,0,0.5); width: 100%; margin: 0; padding: 5px 20px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; white-space: nowrap; overflow: hidden; } #global__header h2 { position: absolute; left: -99999em; top: 0; overflow: hidden; display: inline; } #global__header ul, #global__header li { margin: 0; padding: 0; list-style: none; display: inline; line-height: 1.5; } #global__header a { color: #bbb; text-decoration: none; margin-right: 20px; font-size: 14px; font-weight: normal; } #global__header a:hover, #global__header a:active, #global__header a:focus { color: #fff; text-decoration: underline; } #global__header form { float: right; margin: 0 0 0 20px; } #global__header input { background-color: #333; background-image: none; border: 1px solid #bbb; color: #fff; box-shadow: none; border-radius: 2px; margin: 0; line-height: normal; padding: 1px 0 1px 0; height: auto; } #global__header input.button { border: none; color: #bbb; } #global__header input.button:hover, #global__header input.button:active, #global__header input.button:focus { color: #fff; text-decoration: underline; } } /* /@media */ @media only screen and (min-width: 601px) { /* changes specific for www.dokuwiki.org */ #dokuwiki__header { padding-top: 3em; } #dokuwiki__usertools { top: 3em; } /* changes specific for bugs.dokuwiki.org */ div#container div#showtask { top: 40px; } } /* /@media */ @media only screen and (max-width: 600px) { body { padding-top: 0; } #global__header { position: static; white-space: normal; overflow: auto; } #global__header form { float: none; display: block; margin: 0 0 .4em; } } /* /@media */ @media print { #global__header { display: none; } } /* /@media */ </style> <div id="global__header"> <h2>Global DokuWiki Links</h2> <form method="get" action="https://search.dokuwiki.org/" target="_top"> <input type="text" name="q" title="Search all DokuWiki sites at once" class="input" /> <input type="submit" title="Search all DokuWiki sites at once" value="Search" class="button" /> </form> <ul> <li><a href="https://download.dokuwiki.org" title="Download the latest release" target="_top">Download</a></li> <li><a href="https://www.dokuwiki.org" title="Read the DokuWiki documentation" target="_top">Wiki</a></li> <li><a href="https://forum.dokuwiki.org" title="Ask questions in the DokuWiki forum" target="_top">Forum</a></li> <li><a href="https://irc.dokuwiki.org" title="Check IRC chat logs or join the chat" target="_top">IRC</a></li> <li><a href="https://github.com/splitbrain/dokuwiki/issues" title="Report and track bugs" target="_top">Bugs</a></li> <li><a href="https://translate.dokuwiki.org/" title="Help translating the DokuWiki interface" target="_top">Translate</a></li> <li><a href="https://github.com/splitbrain/dokuwiki" title="Access the most recent git commits" target="_top">Git</a></li> <li><a href="https://xref.dokuwiki.org/reference/dokuwiki/" title="Cross-Reference of the DokuWiki source code" target="_top">XRef</a></li> <li><a href="https://codesearch.dokuwiki.org/" title="Search through the sources of DokuWiki, plugins and templates" target="_top">Code Search</a></li> </ul> </div> <!-- end of DokuWiki top bar include --> </div></footer><!-- /footer --> </div></div><!-- /site --> <div class="no"><img src="/lib/exe/taskrunner.php?id=install%3Anginx&amp;1744373059" width="2" height="1" alt="" /></div> <div id="screen__mode" class="no"></div></body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10