Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/notanexus.git
# Install

This document describes how to install nginx and php-fpm on Arch Linux. While
other combinations of operating systems, web servers and PHP systems are
possible, only instructions for this setup are provided.

## Requirements

Install the following software:

* Web server (e.g., Apache or nginx)
* PHP integration (e.g., php-fpm)

For example, on Arch Linux:

``` bash
pacman -S nginx php-fpm
```

## Web server

The web server's root directory is presumed to be `/srv/http`.

### nginx

If using nginx:

1. Edit  `/etc/nginx/nginx.conf`.
1. Replace the `server` section with the contents of `config/nginx.conf`.

Change the root directory as needed.

Redirect PDF files to the editor:

``` nginx
  location ~* ^/docs/(.*\.pdf)$ {
    rewrite ^/docs/(.*\.pdf)$ /editor.php?filename=$1 last;
  }

  location ~* \.(pdf)$ {
    expires -1;
    add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
  }
```

### Apache

If using Apache:

1. Copy `config/htaccess` into the same directory as `editor.php`.
1. Rename `htaccess` to `.htaccess`.

You may need to merge the contents if a `.htaccess` file already exists.

## Directory

The editor script must have permissions to write to a data directory. The
data directory is given relative to the editor script. For example, if the
editor script is in `/srv/http/notanexus/editor.php`, then issue the
following commands:

``` bash
export NN_DIR=/srv/http/notanexus/nn
mkdir -p ${NN_DIR}
chmod 777 ${NN_DIR}
```

You will also need to make sure the directory is writable by the user running
the web service:

``` bash
sudo chgrp http ${NN_DIR} && sudo chmod g+w ${NN_DIR}
```

The data directory is configured.

## Restart

Restart both nginx and php-fpm. For example, on Arch Linux:

``` bash
systemctl restart nginx.service 
systemctl restart php-fpm.service
```

## Verify

Verify the installation is correct:

1. Create `/srv/http/phpinfo.php`.
1. Insert the following line: `<?php phpinfo(); ?>`
1. Save the file.
1. Browse to: http://localhost/phpinfo.php

Resolve any errors and try again.