Adding a contributions/setup subdir in github

May I suggest to add a directory contributions in github. One subdir
I’d like to see would be setup

The following could be an /contributions/setup/ubuntu-debian-nginx-setup.md
(sorry formatting code comes from redmine, hope it fits eitherway):


h1. invoiceplane system setup on Debian/Ubuntu styled OS using nginx and php5-fpm

Preceeding: You should already have set up a working https nginx plain and php5-fpm installation. You server should answer a request from browsers with at least a default page.

* Download invoiceplane from https://invoiceplane.com/downloads and store it in /usr/local/src
* The following steps will show how setup the database, the filesystem and nginx

h3. DB Basic Setup on MariaDB/MySQL

<pre>
#!/bin/bash

# Modify db, username, password and localhost to your needs:
DBHOST=localhost
APPHOST=`hostname -f`
DBNAME=invoiceplane
USERNAME=invoiceplane
PASSWORD="your_safe_password for the db"

echo "CREATE DATABASE ${DBNAME}; GRANT ALL ON ${DBNAME}.\* TO ${USERNAME}@${APPHOST} IDENTIFIED BY '${PASSWORD}';" | mysql -h${DBHOST} -p

echo "use the following data for the install later:
DB host: $DBHOST
DB name: $DBNAME
DB user: $USERNAME
DB pass: $PASSWORD"

</pre>

h3. Filesystem

<pre>
#!/bin/bash

FOR_VERSION="v1.4.3"
APP_DIR=/usr/local/share/invoiceplane
VAR_DIR=/var/lib/`basename ${APP_DIR}`

mkdir ${APP_DIR}-${FOR_VERSION}
[ -L ${APP_DIR} ] && rm ${APP_DIR}
ln -s ${APP_DIR}-${FOR_VERSION} ${APP_DIR}

cd $APP_DIR
unzip /usr/local/src/invoiceplane-${FOR_VERSION}.zip

# create the www writable directory
mkdir -p $VAR_DIR

# dir/files with could be modified, you may leave out application/views (imho it's vaiable data)
for d in assets uploads application/logs application/views application/helpers/mpdf/tmp; do
    dir=${d%/*}
    [ "$dir" == "$d" ] || mkdir -p $VAR_DIR/$dir
    # move to writable dir
    mv /usr/local/share/invoiceplane/$d /var/lib/invoiceplane/$dir
    # link back to invoiceplane
    ln -s /var/lib/invoiceplane/$d ${APP_DIR}/$d
done
chmod -R o-rwx $VAR_DIR
chown www-data:root $VAR_DIR

mkdir /etc/invoiceplane
mv $APP_DIR/application/config/database.php /etc/invoiceplane/
ln -s /etc/invoiceplane/database.php $APP_DIR/application/config/database.php
chmod g+w /etc/invoiceplane/database.php
chgrp www-data /etc/invoiceplane/database.php
</pre>

h3. Nginx

<pre>
#!/bin/bash

# modify the browser sub directory for invoiceplane to your needs
SUB_DIRECTORY="/invoiceplane"

cat << EOT > /etc/invoiceplane/invoiceplane.nginx
        # start INVOICEPLANE: secure setup
# uncomment following if installation was made successfully
#        location /${SUB_DIRECTORY}/setup {
#                return 301 /${SUB_DIRECTORY}/;
#        }
        location /${SUB_DIRECTORY}/system {
                deny all;
        }
        location /${SUB_DIRECTORY}/application {
                deny all;
        }
        location /${SUB_DIRECTORY}/application/cache {
                deny all;
        }
        location /${SUB_DIRECTORY}/uploads/archive {
                deny all;
        }
        # start INVOICEPLANE: redirect
        location /${SUB_DIRECTORY} {
                root /usr/local/share/invoiceplane;
                try_files \$uri /${SUB_DIRECTORY}/index.php/\$uri;
        }
        # end INVOICEPLANE: redirect + setup
EOT

echo "Put a stanca to your /etc/nginx/default or own config file, like:

     include /etc/invoiceplane/invoiceplane.nginx;
"
</pre>

> service nginx restart

h3. Setup invoiceplane in your browser

Follow the description on https://wiki.invoiceplane.com/en/1.0/getting-started/installation and begin with Step 4.

h3. Post setup step

> chmod g-w /etc/invoiceplane/database.php

Edit /etc/invoiceplane/invoiceplane.nginx and remove the comment marks of the part  location /${YOUR_SUB_DIRECTORY}/setup"

> service nginx reload
1 Like

Good idea for IP 2