Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > d8544620e4ac7bee48ddb48c85d55709 > files > 558

ikiwiki-3.20190228-1.mga7.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>dot cgi</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../style.css" type="text/css" />

<link rel="stylesheet" href="../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../index.html">ikiwiki</a>/ 

<a href="../tips.html">tips</a>/ 

</span>
<span class="title">
dot cgi

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p>It's common to name the <a href="../cgi.html">cgi</a> "ikiwiki.cgi", and put it somewhere
like <code>~/public_html/ikiwiki.cgi</code>, or <code>/var/www/wiki/ikiwiki.cgi</code>.</p>

<p>If you do that, you may find that when trying to edit a page in your wiki,
you see the raw contents of the ikiwiki.cgi program. Or get a permission
denied problem.</p>

<p>This is because web servers are generally not configured to run cgi scripts
unless they're in <code>/usr/lib/cgi-bin/</code>. While you can put ikiwiki.cgi in
there if you like, it's better to configure your web server to 
run <code>.cgi</code>  programs from anywhere.</p>

<p>These instructions are for Debian systems, but the basic
configuration changes should work anywhere.</p>

<div class="toc">
	<ol>
		<li class="L2"><a href="#index1h2">apache 2</a>
		</li>
		<li class="L2"><a href="#index2h2">lighttpd</a>
		</li>
		<li class="L2"><a href="#index3h2">nginx</a>
		</li>
		<li class="L2"><a href="#index4h2">boa</a>
		</li>
	</ol>
</div>

<h2><a name="index1h2"></a>apache 2</h2>

<ul>
<li><p>Make sure the cgi module is loaded. (Ie, <code>a2enmod cgi</code>).
Note that the cgid module will not work.</p></li>
<li><p>Edit /etc/apache2/apache2.conf (or /etc/apache2/mods-available/mime.conf)
and add a line like this:</p>

<p>AddHandler cgi-script .cgi</p></li>
<li><p>Find the "Options" line for the directory where you've put the
ikiwiki.cgi, and add "ExecCGI" to the list of options. For example, if
ikiwiki.cgi is in /var/www/, edit <code>/etc/apache2/sites-enabled/000-default</code>
and add it to the "Options" line in the "Directory /var/www/" stanza.
Or, if you've put it in a <code>~/public_html</code>, edit
<code>/etc/apache2/mods-available/userdir.conf</code>.</p></li>
<li><p>If your wiki is in <code>~/public_html</code> and does not appear when you enter the URL given by the installer, check that you have 
the userdir mod enabled (there should be simlinks to userdir.load and userdir.conf in /etc/apache2/modes-enabled).  If not,
run <code>a2enmod userdir</code> and reload apache2.</p></li>
<li><p>You may also want to enable the <a href="../plugins/404.html">404</a> plugin.
To make apache use it, the apache config file will need a further
modification to make it use ikiwiki's CGI as the apache 404 handler.
Something like this, with the path adjusted to where you've put the CGI:</p>

<p>ErrorDocument 404 /cgi-bin/ikiwiki.cgi</p></li>
<li><p>On Fedora (and RHEL, CentOS, and derivatives) you may need to change CGI mode from <code>06755</code> to <code>755</code> as suid/sgid bit is prohibited by <code>suexec</code>. (<a href="https://bugzilla.redhat.com/show_bug.cgi?id=1341658">Bug 1341568</a>)</p></li>
</ul>

<h2><a name="index2h2"></a>lighttpd</h2>

<p>Here is how to enable cgi on <a href="http://www.lighttpd.net/">lighttpd</a> and
configure it in order to execute ikiwiki.cgi wherever it is located. </p>

<ul>
<li><p>Activate cgi by linking <code>/etc/lighttpd/conf-available/10-cgi.conf</code> into <code>/etc/lighttpd/conf-enabled</code> (<a href="http://trac.lighttpd.net/trac/wiki/Docs%3AModCGI">doc</a>). </p></li>
<li><p>Create <code>/etc/lighttpd/conf-available/90-ikiwiki-cgi.conf</code> and add a line like this:</p>

<p>cgi.assign = ( "ikiwiki.cgi"  =&gt; "", )</p></li>
<li><p>Activate ikiwiki-cgi by linking <code>/etc/lighttpd/conf-available/90-ikiwiki-cgi.conf</code> into <code>/etc/lighttpd/conf-enabled</code>. </p></li>
<li><p>Restart lighttpd server with something like <code>/etc/init.d/lighttpd restart</code>.</p></li>
</ul>

<p>Note that the first part enables cgi server wide but depending on default
configuration, it may be not enough. The second part creates a specific
rule that allow <code>ikiwiki.cgi</code> to be executed.</p>

<p><strong>Warning:</strong> I only use this lighttpd configuration on my development
server (offline). I am not sure of how secure this approach is.
If you have any thought about it, feel free to let me know.</p>

<h2><a name="index3h2"></a>nginx</h2>

<p>To run CGI under nginx, you need to use a FastCGI wrapper. The wrapper must be started somehow just like any other FastCGI program. You can use launchd on OSX.</p>

<p>In Linux, you will need the spawn-fcgi and fcgiwrap packages and start
them with:</p>

<pre><code>spawn-fcgi -s /tmp/fcgi.socket -n -- /usr/sbin/fcgiwrap
</code></pre>

<p>This needs to be ran as your user. It can be added to <code>inittab</code> or
made into a startup script in <code>init.d</code>. You may also need to make this file writable by the webserver, if that's running as a different user, e.g.:</p>

<pre><code>chmod a+w /tmp/fcgi.socket
</code></pre>

<p>If you have <a href="https://en.wikipedia.org/wiki/Systemd">systemd</a>, you may use a service file like so:</p>

<p>Edit/create a service file (in Debian it would be: <code>sudo vim /lib/systemd/system/ikiwiki.service</code></p>

<p>Content of <code>ikiwiki.service</code>:</p>

<pre><code>[Unit]
Description=Ikiwiki fcgi socket wrap
After=network.target

[Service]
Type=simple
User=www-data
Group=www-data
ExecStart=/usr/bin/spawn-fcgi -s /tmp/fcgi.socket -n -- /usr/sbin/fcgiwrap

[Install]
WantedBy=multi-user.target
</code></pre>

<p>Then run:</p>

<pre><code># This enables the service at startup
sudo systemctl enable ikiwiki.service
# This attempts to start the service
sudo systemctl start ikiwiki.service
</code></pre>

<p>Then you need an nginx config plugged in that wrapper. Here's an
example virtual host configuration:</p>

<pre><code>server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

    root /home/anarcat/public_html/wiki.reseaulibre.ca/;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name wiki.reseaulibre.ca;

    location / {
            try_files &#036;uri &#036;uri/ /index.html;
    }
    location /ikiwiki.cgi {
            fastcgi_pass  unix:/tmp/fcgi.socket;
            fastcgi_index ikiwiki.cgi;
            fastcgi_param SCRIPT_FILENAME   /home/anarcat/public_html/ikiwiki.cgi;
            fastcgi_param  DOCUMENT_ROOT      /home/anarcat/public_html/wiki.reseaulibre.ca;
            include /etc/nginx/fastcgi_params;
    }
}
</code></pre>

<p>Also, note that the <code>/tmp/fcgi.socket</code> file needs to be writable by the webserver. I am also unsure as to the security of this setup, as I am using this only on my dev server. Needless to say that <span class="createlink">real fastcgi support</span> would be great. <img src="../smileys/smile4.png" alt=";)" /> --<span class="createlink">anarcat</span></p>

<p>2016-09-23 <span class="createlink">alexjj</span>: On Debian Jessie creating the fcgi ikiwiki.service is not necessary. Install fcgiwrap, it'll auto start the fcgiwrap systemd service and then add the parameters in the virtual host:</p>

<pre><code>    location / {
            try_files &#036;uri &#036;uri/ =404;
    }

    # Max size of file upload
    client_max_body_size 10m;

    location ~ .cgi {
            #gzip off is recommended in /usr/share/doc/fcgiwrap/README.Debian
            gzip off;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
            include /etc/nginx/fastcgi_params;
    }
</code></pre>

<p>Here's a <a href="./nginx.html">complete site.conf</a> for nginx if that helps.</p>

<h2><a name="index4h2"></a>boa</h2>

<p>Edit /etc/boa/boa.conf and make sure the following line is not commented:</p>

<pre><code>AddType application/x-httpd-cgi cgi
</code></pre>

</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">






<div id="backlinks">
Links:

<a href="./laptop_wiki_with_git.html">laptop wiki with git</a>

<a href="../setup.html">setup</a>


</div>






<div class="pagedate">
Last edited <span class="date">Tue Feb 26 23:01:54 2019</span>
<!-- Created <span class="date">Tue Jan 13 01:01:03 2009</span> -->
</div>

</div>


<!-- from ikiwiki -->
</div>

</div>

</body>
</html>