consolidate INSTALL.md with generic steps, INSTALL-x platform-specific

pull/282/head
Marius 2023-03-21 11:02:54 +02:00
rodzic 6fe6d2ce47
commit 2c0cd1976a
4 zmienionych plików z 242 dodań i 309 usunięć

Wyświetl plik

@ -0,0 +1,219 @@
# Installation on other platforms
> This is a standalone, distribution-specific version of `INSTALL.md`. You do not need to read or follow the original file, but can refer to it for generic steps like setting up SSH keys (which are assumed to be common knowledge here)
## Dependencies
Before running `piku` for the first time, you need to install the following Python packages at the system level:
### Raspbian Jessie, Debian 8, Ubuntu 16.04
```bash
sudo apt-get install git python3-virtualenv python3-pip
sudo pip3 install -U click
```
### Raspbian Wheezy
```bash
sudo apt-get install git python3
sudo easy_install3 -U pip3
sudo pip3 install -U click virtualenv
```
These may or may not be installed already (`click` usually isn't). For Raspbian Wheezy this is the preferred approach, since current `apt` packages are fairly outdated.
## Set up the `piku` user, Set up SSH access
See INSTALL.md
## uWSGI Installation (Debian Linux variants, any architecture)
[uWSGI][uwsgi] can be installed in a variety of fashions. These instructions cover both pre-packaged and source installs depending on your system.
### Raspbian Jessie, Debian 8
> **Warning**
>
> These OS releases are no longer supported and these instructions are kept for reference purposes only.
In Raspbian Jessie, Debian 8 and other `systemd` distributions where [uWSGI][uwsgi] is already available pre-compiled (but split into a number of plugins), do the following:
```bash
# At the time of this writing, this installs uwsgi 2.0.7 on Raspbian Jessie.
# You can also install uwsgi-plugins-all if you want to get runtime support for other languages
sudo apt-get install uwsgi uwsgi-plugin-python3
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# disable the standard uwsgi startup script
sudo systemctl disable uwsgi
# add our own startup script
sudo cp /tmp/uwsgi-piku.service /etc/systemd/system/
sudo systemctl enable uwsgi-piku
sudo systemctl start uwsgi-piku
# check it's running
sudo systemctl status uwsgi-piku.service
```
**Important Note:** Make sure you run `piku.py setup` as outlined above before starting the service.
Also, please note that `uwsgi-piku.service`, as provided, creates a `/run/uwsgi-piku` directory for it to place socket files and sundry. This is not actually used at the moment, since the `uwsgi` socket file is placed inside the `piku` user directory for consistency across OS distributions. This will be cleaned up in a later release.
### Raspbian Wheezy
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
Since Raspbian Wheezy is a fairly old distribution by now, its `uwsgi-*` packages are completely outdated (and depend on Python 2.6), so we have to compile and install our own version, as well as using an old-style `init` script to have it start automatically upon boot.
```bash
sudo apt-get install build-essential python-dev libpcre3-dev
# At the time of this writing, this installs 2.0.12
sudo pip install uwsgi
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# set up our init script
sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku
sudo chmod +x /etc/init.d/uwsgi-piku
sudo update-rc.d uwsgi-piku defaults
sudo service uwsgi-piku start
```
**Important Note:** Make sure you run `python3 piku.py setup` as outlined above before starting the service.
### Ubuntu 14.04 LTS
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
This is a mix of both the above, and should change soon when we get 16.04. If you have trouble, install [uWSGI][uwsgi] via `pip` instead.
```bash
# At the time of this writing, this installs uwsgi 1.9.17 on Ubuntu 14.04 LTS.
# You can also install uwsgi-plugins-all if you want to get runtime support for other languages
sudo apt-get install uwsgi uwsgi-plugin-python3
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# set up our init script
sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku
sudo chmod +x /etc/init.d/uwsgi-piku
sudo update-rc.d uwsgi-piku defaults
sudo service uwsgi-piku start
```
## nginx Installation (Raspbian 8, Ubuntu 16.04)
> **Warning**
>
> These OS releases are no longer supported and these instructions are kept for reference purposes only.
*PLEASE NOTE:* There is a bug in `nginx` 1.6.2 under Raspbian 8 that causes it to try to allocate around a gigabyte of RAM when using SSL with SPDY. I seriously recommend using Ubuntu instead, if you can, or disabling SSL altogether.
```bash
sudo apt-get install nginx
# Set up nginx to pick up our config files
sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default
# Set up systemd.path to reload nginx upon config changes
sudo cp ./piku-nginx.{path, service} /etc/systemd/system/
sudo systemctl enable piku-nginx.{path,service}
sudo systemctl start piku-nginx.path
# Check the status of piku-nginx.service
systemctl status piku-nginx.path # should return `Active: active (waiting)`
# Restart NGINX
sudo systemctl restart nginx
```
## Java 8 Installation (All Debian Linux variants, on Raspberry Pi)
> **Warning**
>
> OpenJDK 8 is no longer shipping with most distributions and these instructions are kept for reference purposes only.
To be able to deploy Java apps, we're going to need to install Java (and, since we're going to be doing so on ARM, it's best to use Oracle's runtime). To do that, we're going to use the `webupd8team` PPA, which has a (cross-platform) Java installer.
First, get rid of OpenJDK and import the PPA key:
```bash
sudo apt-get remove openjdk*
sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886
```
### Raspbian Jessie
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
For Jessie, we're going to use the `trusty` version of the installer:
```bash
sudo tee /etc/apt/sources.list.d/webupd8team.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
^D
```
### Ubuntu 16.04 for ARM
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
For Xenial, we're going to use its own version:
```bash
sudo tee /etc/apt/sources.list.d/webupd8team.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
^D
```
Now perform the actual install:
```bash
sudo apt-get update
sudo apt-get install oracle-java8-installer oracle-java8-set-default
```
## Go Installation (All Debian Linux variants, on Raspberry Pi)
> This is **EXPERIMENTAL** and may not work at all.
### Raspbian Wheezy/Jessie
> **Warning**
>
> Wheezy and Jessie are no longer supported and these instructions are kept for reference purposes only.
Since Raspbian's Go compiler is version 1.0.2, we need something more up-to-date.
1. Get an [ARM 6 binary tarball][goarm]
2. Unpack it under the `piku` user like such:
```bash
sudo su - piku
tar -zxvf /tmp/go1.5.3.linux-arm.tar.gz
# remove unnecessary files
rm -rf go/api go/blog go/doc go/misc go/test
```
3. Give it a temporary `GOPATH` and install `godep`:
```bash
sudo su - piku
GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get github.com/tools/godep
# temporary workaround until this is fixed in godep or Go 1.7(?)
GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get golang.org/x/sys/unix
```
_TODO: complete this._
[goarm]: http://dave.cheney.net/unofficial-arm-tarballs
[uwsgi]: https://github.com/unbit/uwsgi
[cygwin]: http://www.cygwin.com

Wyświetl plik

@ -39,41 +39,9 @@ sudo apt-get install -y build-essential certbot git \
uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-tornado-python \
uwsgi-plugin-lua5.1 uwsgi-plugin-lua5.2 uwsgi-plugin-luajit
```
## Setting up the `piku` user
## Set up the `piku` user, Set up SSH access
`piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group). This user (`piku`) _is not supposed to login to your system_. Instead, you'll interact with `piku` via SSH, and set things up by using `su`.
To create the `piku` user account, enter the following commands:
```bash
# pick a username
export PAAS_USERNAME=piku
# create it
sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data $PAAS_USERNAME
```
You will have to copy your ssh public key to the raspberry pi from your main system. If you already have `ssh`d into your newly installed pi you can do the following:
```bash
# copy your public key to /tmp (I'm assuming it's the first entry in authorized_keys)
head -1 ~/.ssh/authorized_keys > /tmp/pubkey
# install piku and have it set up SSH keys and default files
sudo su - $PAAS_USERNAME -c "wget https://raw.githubusercontent.com/piku/piku/master/piku.py && python3 ~/piku.py setup && python3 ~/piku.py setup:ssh /tmp/pubkey"
rm /tmp/pubkey
```
The `setup` output should be something like this:
```
Creating '/home/piku/.piku/apps'.
Creating '/home/piku/.piku/repos'.
Creating '/home/piku/.piku/envs'.
Creating '/home/piku/.piku/uwsgi'.
Creating '/home/piku/.piku/uwsgi-available'.
Creating '/home/piku/.piku/uwsgi-enabled'.
Creating '/home/piku/.piku/logs'.
Setting '/home/piku/piku.py' as executable.
```
See INSTALL.md
## uWSGI Configuration

Wyświetl plik

@ -17,39 +17,10 @@ sudo apt-get install -y build-essential certbot git \
uwsgi uwsgi-plugin-asyncio-python3 uwsgi-plugin-gevent-python \
uwsgi-plugin-python uwsgi-plugin-python3 uwsgi-plugin-tornado-python
```
## Setting up the `piku` user
`piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group), enter the following commands:
## Set up the `piku` user, Set up SSH access
```bash
# pick a username
export PAAS_USERNAME=piku
# create it
sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data $PAAS_USERNAME
```
This user _is not supposed to login to your system_. Instead, you'll interact with `piku` via SSH, and set things up by using `su`:
```bash
# copy your public key to /tmp (I'm assuming it's the first entry in authorized_keys)
head -1 ~/.ssh/authorized_keys > /tmp/pubkey
# install piku and have it set up SSH keys and default files
sudo su - $PAAS_USERNAME -c "wget https://raw.githubusercontent.com/piku/piku/master/piku.py && python3 ~/piku.py setup && python3 ~/piku.py setup:ssh /tmp/pubkey"
rm /tmp/pubkey
```
The `setup` output should be something like this:
```
Creating '/home/piku/.piku/apps'.
Creating '/home/piku/.piku/repos'.
Creating '/home/piku/.piku/envs'.
Creating '/home/piku/.piku/uwsgi'.
Creating '/home/piku/.piku/uwsgi-available'.
Creating '/home/piku/.piku/uwsgi-enabled'.
Creating '/home/piku/.piku/logs'.
Setting '/home/piku/piku.py' as executable.
```
See INSTALL.md
## uWSGI Configuration

Wyświetl plik

@ -1,72 +1,34 @@
# Installation
As of June 2018, these documents are being split off into distribution-specific files in the same folder. If you are running `piku` on specific Linux versions, feel free to contribute your own instructions.
`piku` requires `Python 3`, [uWSGI][uwsgi], SSH, and a Linux distribution that runs `systemd`, such as Raspbian Jessie/Debian 8+/Ubuntu/Fedora/CentOS.
> Please use distro-specific instructions whenever possible, since there have been recent improvements in `uwsgi` packaging that greatly simplify installation.
There are 3 ways to install piku on a server:
Also, `piku` now **requires Python 3** and a Linux distribution that runs `systemd`, such as Raspbian Jessie/Debian 8+/Ubuntu
1. Manually: Follow INSTALL-x.md for which ever platform. If you are running `piku` on specific Linux versions, feel free to contribute your own instructions.
These generic installation notes should cover most Debian Linux variants (on any architecture). Very minor changes should be required to deploy on RHEL variants like CentOS, and there is specific emphasis on Raspbian because that's the typical deployment target.
2. Use cloud-init to do it automatically at VPS build time: https://github.com/piku/cloud-init
You can, however, run `piku` on any POSIX-like environment where you have Python, [uWSGI][uwsgi] and SSH.
3. Use piku-bootstrap to do it once your box is already provisioned: https://github.com/piku/piku-bootstrap
For installation, you only require `root`/`sudo` access and the following files:
# Generic steps (referenced from INSTALL-x)
* `piku.py`
* `uwsgi-piku.service`
* `piku-nginx.path`
* `piku-nginx.service`
* `nginx-default.dist`
Copy them across to the machine you'll be using as a server before you get started with the rest.
## Setting up the `piku` user (Debian Linux, any architecture)
## Set up the `piku` user
`piku` requires a separate user account to run. To create a new user with the right group membership (we're using the built-in `www-data` group because it's generally thought of as a less-privileged group), enter the following command:
```bash
sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data piku
# pick a username
export PAAS_USERNAME=piku
# create it
sudo adduser --disabled-password --gecos 'PaaS access' --ingroup www-data $PAAS_USERNAME
# copy & setup piku.py
sudo su - $PAAS_USERNAME -c "wget https://raw.githubusercontent.com/piku/piku/master/piku.py && python3 ~/piku.py setup"
rm /tmp/pubkey
```
This user _is not supposed to login to your system_. Instead, you'll interact with `piku` via SSH, and set things up by using `su`:
The `setup` output should be something like this:
```bash
sudo su - piku
mkdir ~/.ssh
chmod 700 ~/.ssh
# now copy the piku script to this user account
cp /tmp/piku.py ~/piku.py
```
## Dependencies
Before running `piku` for the first time, you need to install the following Python packages at the system level:
### Raspbian Jessie, Debian 8, Ubuntu 16.04
```bash
sudo apt-get install git python3-virtualenv python3-pip
sudo pip3 install -U click
```
### Raspbian Wheezy
```bash
sudo apt-get install git python3
sudo easy_install3 -U pip3
sudo pip3 install -U click virtualenv
```
These may or may not be installed already (`click` usually isn't). For Raspbian Wheezy this is the preferred approach, since current `apt` packages are fairly outdated.
## Initialization
To set everything up, type `python piku.py setup`:
```bash
sudo su - piku
python3 piku.py setup
Creating '/home/piku/.piku/apps'.
Creating '/home/piku/.piku/repos'.
Creating '/home/piku/.piku/envs'.
@ -77,7 +39,8 @@ Creating '/home/piku/.piku/logs'.
Setting '/home/piku/piku.py' as executable.
```
## Setting up SSH access
## Set up SSH access
If you don't have an SSH public key (or never used one before), you need to create one. The following instructions assume you're running some form of UNIX on your own machine (Windows users should check the documentation for their SSH client, unless you have [Cygwin][cygwin] installed).
@ -101,8 +64,6 @@ The key's randomart image is:
+-----------------+
```
## Adding the key to `piku`
Copy the resulting `id_rsa.pub` (or equivalent, just make sure it's the _public_ file) to your `piku` server and do the following:
```bash
@ -123,7 +84,7 @@ command="FINGERPRINT=85:29:07:cb:de:ad:be:ef:42:65:00:c8:d2:6b:9e:ff NAME=defaul
This line is what enables you to SSH (and perform `git` over SSH operations) to the `piku` user without a password, verifying your identity via your public key, restricting what can be done remotely and passing on to `piku` itself the commands you'll be issuing.
## Testing
## Test
From your machine, do:
@ -156,193 +117,7 @@ Commands:
Connection to pi.lan closed.
```
And that's it, you're set. Now to configure [uWSGI][uwsgi], which is what `piku` relies upon to manage your apps at runtime.
## uWSGI Installation (Debian Linux variants, any architecture)
[uWSGI][uwsgi] can be installed in a variety of fashions. These instructions cover both pre-packaged and source installs depending on your system.
### Raspbian Jessie, Debian 8
> **Warning**
>
> These OS releases are no longer supported and these instructions are kept for reference purposes only.
In Raspbian Jessie, Debian 8 and other `systemd` distributions where [uWSGI][uwsgi] is already available pre-compiled (but split into a number of plugins), do the following:
```bash
# At the time of this writing, this installs uwsgi 2.0.7 on Raspbian Jessie.
# You can also install uwsgi-plugins-all if you want to get runtime support for other languages
sudo apt-get install uwsgi uwsgi-plugin-python3
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# disable the standard uwsgi startup script
sudo systemctl disable uwsgi
# add our own startup script
sudo cp /tmp/uwsgi-piku.service /etc/systemd/system/
sudo systemctl enable uwsgi-piku
sudo systemctl start uwsgi-piku
# check it's running
sudo systemctl status uwsgi-piku.service
```
**Important Note:** Make sure you run `piku.py setup` as outlined above before starting the service.
Also, please note that `uwsgi-piku.service`, as provided, creates a `/run/uwsgi-piku` directory for it to place socket files and sundry. This is not actually used at the moment, since the `uwsgi` socket file is placed inside the `piku` user directory for consistency across OS distributions. This will be cleaned up in a later release.
### Raspbian Wheezy
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
Since Raspbian Wheezy is a fairly old distribution by now, its `uwsgi-*` packages are completely outdated (and depend on Python 2.6), so we have to compile and install our own version, as well as using an old-style `init` script to have it start automatically upon boot.
```bash
sudo apt-get install build-essential python-dev libpcre3-dev
# At the time of this writing, this installs 2.0.12
sudo pip install uwsgi
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# set up our init script
sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku
sudo chmod +x /etc/init.d/uwsgi-piku
sudo update-rc.d uwsgi-piku defaults
sudo service uwsgi-piku start
```
**Important Note:** Make sure you run `python3 piku.py setup` as outlined above before starting the service.
### Ubuntu 14.04 LTS
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
This is a mix of both the above, and should change soon when we get 16.04. If you have trouble, install [uWSGI][uwsgi] via `pip` instead.
```bash
# At the time of this writing, this installs uwsgi 1.9.17 on Ubuntu 14.04 LTS.
# You can also install uwsgi-plugins-all if you want to get runtime support for other languages
sudo apt-get install uwsgi uwsgi-plugin-python3
# refer to our executable using a link, in case there are more versions installed
sudo ln -s `which uwsgi` /usr/local/bin/uwsgi-piku
# set up our init script
sudo cp /tmp/uwsgi-piku.dist /etc/init.d/uwsgi-piku
sudo chmod +x /etc/init.d/uwsgi-piku
sudo update-rc.d uwsgi-piku defaults
sudo service uwsgi-piku start
```
## nginx Installation (Raspbian 8, Ubuntu 16.04)
> **Warning**
>
> These OS releases are no longer supported and these instructions are kept for reference purposes only.
*PLEASE NOTE:* There is a bug in `nginx` 1.6.2 under Raspbian 8 that causes it to try to allocate around a gigabyte of RAM when using SSL with SPDY. I seriously recommend using Ubuntu instead, if you can, or disabling SSL altogether.
```bash
sudo apt-get install nginx
# Set up nginx to pick up our config files
sudo cp /tmp/nginx.default.dist /etc/nginx/sites-available/default
# Set up systemd.path to reload nginx upon config changes
sudo cp ./piku-nginx.{path, service} /etc/systemd/system/
sudo systemctl enable piku-nginx.{path,service}
sudo systemctl start piku-nginx.path
# Check the status of piku-nginx.service
systemctl status piku-nginx.path # should return `Active: active (waiting)`
# Restart NGINX
sudo systemctl restart nginx
```
## Java 8 Installation (All Debian Linux variants, on Raspberry Pi)
> **Warning**
>
> OpenJDK 8 is no longer shipping with most distributions and these instructions are kept for reference purposes only.
To be able to deploy Java apps, we're going to need to install Java (and, since we're going to be doing so on ARM, it's best to use Oracle's runtime). To do that, we're going to use the `webupd8team` PPA, which has a (cross-platform) Java installer.
First, get rid of OpenJDK and import the PPA key:
```bash
sudo apt-get remove openjdk*
sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886
```
### Raspbian Jessie
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
For Jessie, we're going to use the `trusty` version of the installer:
```bash
sudo tee /etc/apt/sources.list.d/webupd8team.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
^D
```
### Ubuntu 16.04 for ARM
> **Warning**
>
> This OS release is no longer supported and these instructions are kept for reference purposes only.
For Xenial, we're going to use its own version:
```bash
sudo tee /etc/apt/sources.list.d/webupd8team.list
deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main
^D
```
Now perform the actual install:
```bash
sudo apt-get update
sudo apt-get install oracle-java8-installer oracle-java8-set-default
```
## Go Installation (All Debian Linux variants, on Raspberry Pi)
> This is **EXPERIMENTAL** and may not work at all.
### Raspbian Wheezy/Jessie
> **Warning**
>
> Wheezy and Jessie are no longer supported and these instructions are kept for reference purposes only.
Since Raspbian's Go compiler is version 1.0.2, we need something more up-to-date.
1. Get an [ARM 6 binary tarball][goarm]
2. Unpack it under the `piku` user like such:
```bash
sudo su - piku
tar -zxvf /tmp/go1.5.3.linux-arm.tar.gz
# remove unnecessary files
rm -rf go/api go/blog go/doc go/misc go/test
```
3. Give it a temporary `GOPATH` and install `godep`:
```bash
sudo su - piku
GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get github.com/tools/godep
# temporary workaround until this is fixed in godep or Go 1.7(?)
GOROOT=$HOME/go GOPATH=$HOME/gopath PATH=$PATH:$HOME/go/bin go get golang.org/x/sys/unix
```
_TODO: complete this._
[goarm]: http://dave.cheney.net/unofficial-arm-tarballs
[uwsgi]: https://github.com/unbit/uwsgi
[cygwin]: http://www.cygwin.com