% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math} % this also loads fontspec
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
  % xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
  \usepackage{selnolig}  % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
  pdftitle={setting-up-a-pylowiki-site},
  hidelinks,
  pdfcreator={LaTeX via pandoc}}

\title{setting-up-a-pylowiki-site}
\author{}
\date{}

\begin{document}
\maketitle

\hypertarget{setting-up-a-pylowiki-site}{%
\section{setting-up-a-pylowiki-site}\label{setting-up-a-pylowiki-site}}

Setting up a pylowiki site
\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots..

This page will outline the steps needed to setup a production pylowiki
site.

If you are interested in running a demo or local version of pylowiki,
check out the
\texttt{minimal\ pylowiki\ setup\ instructions\ \textless{}/pylowiki\#installation-and-setup\textgreater{}}\_.

In this tutorial we will be configuring pylowiki to run:

\begin{itemize}
\tightlist
\item
  on ubuntu linux
\item
  as a wsgi application
\item
  with an apache2 webserver
\item
  in a python virtualenv
\item
  with a mysql database backend
\end{itemize}

.. contents::

\hypertarget{get-the-pylowiki-sourcecode}{%
\section{Get the Pylowiki
sourcecode}\label{get-the-pylowiki-sourcecode}}

The pylowiki sourcecode is hosted at bitbucket.org. You will need
mecurial (hg) revision control to download the source.

For debian or ubuntu

.. code-block:: shell

\begin{verbatim}
sudo apt-get install mercurial
\end{verbatim}

Once you have mercurial you need to clone the pylowiki sourcecode

.. code-block:: shell

\begin{verbatim}
hg clone http://bitbucket.org/russellballestrini/pylowiki

mv pylowiki mysite
\end{verbatim}

Now you should have the sourcecode in local filesystem. You might want
to come up with a workflow to maintain your changes and still accept
revisions from the upstream pylowiki repository. I'll leave that up to
you.

\hypertarget{fix-file-permissions}{%
\section{Fix file permissions}\label{fix-file-permissions}}

The web server account only needs access to a few directories. All the
other files may be owned by your id.

Run the following commands from the root of your Pylowiki project
directory to correct permissions.

.. code-block:: apache

mkdir egg-cache data

sudo chgrp -R www-data pylowiki/public/attachment sudo chmod -R 774
pylowiki/public/attachment

sudo chgrp -R www-data egg-cache sudo chmod -R 774 egg-cache

sudo chgrp -R www-data data sudo chmod -R 774 data

\hypertarget{get-a-pylons-virtual-environment}{%
\section{Get a Pylons virtual
environment}\label{get-a-pylons-virtual-environment}}

Official Pylons setup notes:
http://pylonshq.com/docs/en/1.0/gettingstarted/

.. code-block:: apache

wget http://www.pylonshq.com/download/1.0/go-pylons.py

python go-pylons.py virtpy

To enable the virtual environment run:

.. code-block:: apache

source virtpy/bin/activate

\hypertarget{install-your-pylowiki-application}{%
\section{Install your Pylowiki
application}\label{install-your-pylowiki-application}}

Make sure your currently inside your virtual python environment. Your
shell should look like this:

.. code-block:: php

(virtpy)user@host\$ python setup.py develop

Notice the (virtpy)? The above command will install Pylowiki and all its
dependencies into your virtual pythons site-lib.

\hypertarget{configure-pylowiki---prod.ini}{%
\section{Configure Pylowiki -
prod.ini}\label{configure-pylowiki---prod.ini}}

The following command should be run in the root of your pylowiki
project. This will create a configuration ini named prod.ini:

.. code-block:: php

(virtpy)user@host\$ paster make-config Pylowiki prod.ini

Open prod.ini for editing and make changes to reflect your environment.
Database settings, public wiki registration, all the tweak-able settings
are declared in the ini.

\hypertarget{prepare-mysql-database}{%
\section{Prepare mySQL Database}\label{prepare-mysql-database}}

Login to mySQL as root.

.. code-block:: mysql

mysql -u root -p

mysql\textgreater{}

CREATE DATABASE mysite

GRANT ALL PRIVILEGES ON mysite.* TO username@localhost IDENTIFIED BY
`passw0rd' WITH GRANT OPTION

Now make sure the prod.ini reflects these database settings:

.. code-block:: ini

sqlalchemy.url = mysql://username:password@127.0.0.1/mysite?charset=utf8
sqlalchemy.pool\_recycle = 3600

Now we can let Pylowiki create all the database tables by issuing the
following command:

.. code-block:: php

(virtpy)user@host\$ paster setup-app prod.ini

\hypertarget{configure-mod_wsgi-dispatch-file}{%
\section{Configure mod\_wsgi dispatch
file}\label{configure-mod_wsgi-dispatch-file}}

First step is to create the mod\_wsgi dispatch file.

From the root directory of the Pylowiki project, create a
\emph{dispatch.wsgi} file with the following content:

.. code-block:: python

\# Add the virtual Python environment site-packages directory to the
path import sys sys.stdout = sys.stderr

import site
site.addsitedir(`/absolute/path/to/virtpy/lib/python2.6/site-packages')

\# Avoid
\texttt{{[}Errno\ 13{]}\ Permission\ denied:\ \textquotesingle{}/var/www/.python-eggs\textquotesingle{}}
messages import os os.environ{[}`PYTHON\_EGG\_CACHE'{]} =
`/absolute/path/to/pylowiki/egg-cache'

\# Load the Pylons application from paste.deploy import loadapp
application = loadapp(`config:/absolute/path/to/pylowiki/prod.ini')

\hypertarget{configure-apache2-virtualhost}{%
\section{Configure apache2
virtualhost}\label{configure-apache2-virtualhost}}

Create a domain file under /etc/apache2/sites-enabled.

.. code-block:: apache

sudo vi 002-mysite

\#mysite.net

\#pylons embeded mod\_wsgi \textless VirtualHost *:80\textgreater{}
ServerName www.mysite.net ServerAlias mysite.net ServerAdmin
admin@mysite.com

\begin{verbatim}
# ReWrite URL to WWW
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mysite.net
    RewriteRule (.*) http://www.mysite.net$1 [R=301,L]

    # Log Files
    ErrorLog /var/log/apache2/error-mysite.log
    CustomLog /var/log/apache2/access-mysite.log combined

    # Setup mod_wsgi
    WSGIScriptAlias / /absolute/path/to/pylowiki/dispatch.wsgi
\end{verbatim}

Restart the apache2 service:

.. code-block:: apache

sudo service apache2 restart

\hypertarget{foxhop-oct-08-2010-0323-pm}{%
\subsection{foxhop --- Oct 08, 2010 03:23
pm}\label{foxhop-oct-08-2010-0323-pm}}

Please contribute to this installation documentation.

\end{document}
