a b/INSTALL.md
1
2
Qiita installation 
3
==================
4
5
Qiita is pip installable, but depends on specific versions of python and non-python packages that must be installed first. We strongly recommend using virtual environments; a popular solution to manage them is [miniconda](http://conda.pydata.org/miniconda.html), a lightweight version of the virtual environment, python distribution, and package manager anaconda. These instructions will be based on miniconda.
6
7
## Install and setup miniconda
8
9
Download the appropriate installer [here](https://repo.anaconda.com/miniconda/) corresponding to your operating system and execute it.
10
11
Next, ensure conda is up-to-date.
12
13
```bash
14
conda update conda
15
```
16
17
### Create a conda environment for Qiita
18
19
Setup a virtual environment in conda named `qiita` by executing the following:
20
21
```bash
22
conda config --add channels conda-forge
23
conda create -q --yes -n qiita python=3.9 pip libgfortran numpy nginx cython redis
24
```
25
26
### Brief introduction to managing conda environments
27
28
Though these instructions use the newly created `qiita` conda environment, the concepts apply to managing conda environments in general.
29
30
Activate your newly created virtual environment for qiita whenever you want to run or develop for it:
31
32
```bash
33
source activate qiita
34
```
35
36
After activating your new environment, you should see this kind of output when you run `which python`, indicating that the `python` command now refers to the python binary in your new virtual environment, rather than a previous global default such as `/usr/bin/python`. For example, assuming you installed miniconda in `/Users/your_username/`:
37
38
```
39
$ which python
40
/Users/your_username/miniconda2/envs/qiita/bin/python
41
(qiita)
42
```
43
44
If you don't see this output, your `$PATH` variable was setup incorrectly or you haven't restarted your shell. Consult the [conda documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html).
45
46
As long as you are in the active qiita environment, commands such as `pip install` or `python` will refer to and be contained within this virtual environment.
47
48
When you want to deactivate your current conda environment, e.g. to return to a different project or back to your global python and pip packages, run:
49
50
```bash
51
source deactivate
52
```
53
54
55
Install the non-python dependencies
56
-----------------------------------
57
58
* [PostgreSQL](http://www.postgresql.org/download/) (currently using v13)
59
* [redis-server](http://redis.io) (we have tested most extensively with 2.8.17)
60
* [webdis] (https://github.com/nicolasff/webdis) (latest version should be fine but we have tested the most with 9ee6fe2 - Feb 6, 2016)
61
62
There are several options to install these dependencies depending on your needs:
63
64
- **We suggest installing the exact versions in these instructions by following the instructions of the provided links and making them globally available in your machine. However, this might interfere with other apps that might require different versions.** 
65
- Alternatively, you could install them via conda. However, the conda repository may not have the exact versions of these dependencies that you want.
66
- You could setup a full development environment with [Vagrant](https://www.vagrantup.com/), and continue using conda under it to primarily manage python dependencies. Note that we don't cover Vagrant in these instructions.
67
68
### PostgreSQL installation on Linux
69
The following instructions have been adapted from [this site](https://computingforgeeks.com/how-to-install-postgresql-13-on-ubuntu/) and tested on Ubuntu v20.04.4 for Postgres v13.
70
71
First, ensure that you have updated packages and reboot the system with:
72
```bash
73
sudo apt update && sudo apt -y full-upgrade
74
[ -f /var/run/reboot-required ] && sudo reboot -f
75
```
76
You can reboot the system with `sudo reboot` in case any packages were updated.
77
78
Next, we need to add the Postgres repository to our system:
79
```bash
80
sudo apt update
81
sudo apt install curl gpg gnupg2 software-properties-common apt-transport-https lsb-release ca-certificates git
82
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
83
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list
84
```
85
Adding the repository has added many different packages, which allows us to now install Postgres v13 with the following commands:
86
```bash
87
sudo apt update
88
sudo apt install postgresql-13 postgresql-client-13
89
```
90
Now, we need to reconfigure the `pg_hba.conf` file and change all occurrences of `md5` and `peer` to `trust`. You can access the file with:
91
```bash
92
sudo vim /etc/postgresql/13/main/pg_hba.conf
93
```
94
To make sure all changes have been reflected, restart the Postgres server:
95
```bash
96
sudo service postgresql restart
97
```
98
Installing Postgres is now complete. Note that you will need to start the Postgres server every time you start the Qiita server. You can do this with the following command:
99
```bash
100
sudo service postgresql start
101
```
102
### PostgreSQL installation on Mac OS X
103
104
For Mac OS X, it is strongly encourage to install Postgres through the [Postgres.app](https://postgresapp.com/downloads.html). We recommend using Postgres.app versions 9.5 or 13, as instructions were tested most extensively with these versions.
105
106
You'll then need to ensure that the postgres binaries (for example, ``psql``) are in your executable search path (``$PATH`` environment variable). If you are using Postgres.app on OS X, you can do this by running the following, though you may have to replace`~/.bash_profile`with `~/.zshrc` if you're using zshell rather than the built-in bash, and you may have to change the version number `Versions/9.3/` to the exact one that you are installing:
107
108
```bash
109
echo 'export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin/"' >> ~/.bash_profile
110
source ~/.bash_profile
111
```
112
113
### Redis-server installation using Homebrew (Mac OS X, Linux)
114
115
Assuming you have [homebrew](http://brew.sh) installed, you can install the latest version of the redis-server as follows:
116
117
```bash
118
brew update
119
brew install homebrew/versions/redis28
120
```
121
### Redis-server installation using apt-get (Linux)
122
123
Alternatively, you can sudo install redis:
124
```bash
125
sudo apt-get install redis-server
126
```
127
128
### webdis
129
130
Note that this package is OPTIONAL and this is the only package that assumes that Qiita is already installed (due to library dependencies). Also, that the general suggestion is to have 2 redis servers running, one for webdis/redbiom and the other for Qiita. The reason for multiple redis servers is so that the redbiom cache can be flushed without impacting the operation of the qiita server itself.
131
132
The following instructions install, compile and pre-populates the redbiom redis DB so we assume that redis is running on the default port and that Qiita is fully installed as the redbiom package is installed with Qiita.
133
134
```
135
git clone https://github.com/nicolasff/webdis
136
pushd webdis
137
make
138
./webdis &
139
popd
140
# note that this assumes that Qiita is already installed
141
fp=`python -c 'import qiita_db; print qiita_db.__file__'`
142
qdbd=`dirname $fp`
143
redbiom admin scripts-writable
144
redbiom admin create-context --name "qiita-test" --description "qiita-test context"
145
redbiom admin load-sample-metadata --metadata ${qdbd}/support_files/test_data/templates/1_19700101-000000.txt
146
redbiom admin load-sample-metadata-search --metadata ${qdbd}/support_files/test_data/templates/1_19700101-000000.txt
147
redbiom admin load-sample-data --table ${qdbd}/support_files/test_data/processed_data/1_study_1001_closed_reference_otu_table.biom --context qiita-test --tag 1
148
```
149
150
Install Qiita development version and its python dependencies
151
-------------------------------------------------------------
152
153
Clone the git repository with the development version of Qiita into your current directory:
154
155
```bash
156
git clone https://github.com/qiita-spots/qiita.git
157
```
158
159
Navigate to the cloned directory and ensure your conda environment is active:
160
161
```bash
162
cd qiita
163
source activate qiita
164
```
165
If you are using Ubuntu or a Windows Subsystem for Linux (WSL), you will need to ensure that you have a C++ compiler and that development libraries and include files for PostgreSQL are available. Type `cc` into your system to ensure that it doesn't result in `program not found`. If you use the the GNU Compiler Collection, make sure to have `gcc` and `g++` available. The following commands will install a C++ compiler and  `libpq-dev`:
166
```bash
167
sudo apt install gcc g++             # alternatively, you can install clang instead
168
sudo apt-get install libpq-dev
169
```
170
Install Qiita (this occurs through setuptools' `setup.py` file in the qiita directory):
171
172
```bash
173
pip install . --no-binary redbiom
174
```
175
Note that if you get any errors or warnings with 'certifi', you can add the `--ignore-installed` tag to the command above.
176
177
At this point, Qiita will be installed and the system will start. However,
178
you will need to install plugins in order to process any kind of data. For a list
179
of available plugins, visit the [Qiita Spots](https://github.com/qiita-spots)
180
github organization. Each of the plugins have their own installation instructions, we
181
suggest looking at each individual .github/workflows/qiita-plugin-ci.yml file to see detailed installation
182
instructions. Note that the most common plugins are:
183
- [qtp-biom](https://github.com/qiita-spots/qtp-biom)
184
- [qtp-sequencing](https://github.com/qiita-spots/qtp-sequencing)
185
- [qp-target-gene](https://github.com/qiita-spots/qp-target-gene)
186
187
## Configure Qiita
188
189
After these commands are executed, you will need to:
190
191
Move the Qiita sample configuration file to a different directory by executing:
192
193
```bash
194
 cp ./qiita_core/support_files/config_test.cfg ~/.qiita_config_test.cfg
195
```
196
197
Note that you will need to change `BASE_URL = https://localhost:8383` to `BASE_URL = https://localhost:21174` in the new copy of the configuration file if you are not using NGINX. Additionally, you will also need to change all URLs that start with `/home/runner/work/qiita/qiita/...` into wherever your qiita directory is (e.g. `/home/<username>/qiita/...`).
198
199
200
Set your `QIITA_CONFIG_FP` environment variable to point to that file (into `.bashrc` if using bash; `.zshrc` if using zshell):
201
202
```bash
203
  echo "export QIITA_CONFIG_FP=$HOME/.qiita_config_test.cfg" >> ~/.bashrc
204
  source ~/.bashrc
205
  # Re-enable conda environment for qiita
206
  source activate qiita
207
```
208
209
If you are working on Mac OS X or WSL, you will need to start the redis server with the following command before making a test environment:
210
```bash
211
redis-server --daemonize yes --port 7777
212
```
213
Next, make a test environment:
214
215
```bash
216
qiita-env make --no-load-ontologies
217
```
218
219
Finally, redbiom relies on the REDBIOM_HOST environment variable to set the URL to query. By default is set to Qiita redbiom public repository. To change it you could do:
220
221
```bash
222
export REDBIOM_HOST=http://my_host.com:7379
223
```
224
225
## Configure NGINX and supervisor
226
227
[NGINX](https://www.nginx.com/) is not a requirement for Qiita development but it's highly recommended for deploys as this will allow us
228
to have multiple workers. Note that we are already installing [NGINX](https://www.nginx.com/) within the Qiita conda environment; also,
229
that Qiita comes with an example [NGINX](https://www.nginx.com/)  config file: `qiita_pet/nginx_example.conf`, which is used in the Travis builds.
230
231
Now, [supervisor](https://github.com/Supervisor/supervisor) will allow us to start all the workers we want based on its configuration file; and we
232
need that both the [NGINX](https://www.nginx.com/) and [supervisor](https://github.com/Supervisor/supervisor) config files to match. For our Travis
233
testing we are creating 3 workers: 21174 for master and 21175-6 as a regular workers.
234
235
If you are using [NGINX](https://www.nginx.com/) via conda, you are going to need to create the NGINX folder within the environment; thus run:
236
237
```bash
238
mkdir -p ${CONDA_PREFIX}/var/run/nginx/
239
```
240
241
Note that the shipped nginx version from conda, does **not** contain the mod_zip module: https://github.com/evanmiller/mod_zip
242
This leads to unexpected behaviour when generating a download link for anonymous artefact sharing, i.e. Qiita returns a flat file listing artifact filepaths instead of generating a ZIP archive that contains those files. You need to compile nginx with the additional mod_zip module yourself. (I've invested multiple hours to realize that the configure routine does not properly link shared libraries to the nginx binary. Try adding `--with-ld-opt=" -Wl,-rpath,/home/foo/lib "` to the `./auto/configure` call.)
243
244
## Start Qiita
245
246
Start postgres (instructions vary depending on operating system and install method).
247
248
Next, start redis server (the command may differ depending on your operating system and install location):
249
250
```bash
251
redis-server --port 7777
252
```
253
254
Start the qiita server:
255
256
```bash
257
# this builds documentation before starting the server
258
# alternatively: qiita pet webserver --no-build-docs start
259
qiita pet webserver start
260
```
261
262
If all the above commands executed correctly, you should be able to access Qiita by going in your browser to https://localhost:21174 if you are not using NGINX, or https://localhost:8383 if you are using NGINX, to login use `test@foo.bar` and `password` as the credentials. (Login as `admin@foo.bar` with `password` to see admin functionality. In the future, we will have a *single user mode* that will allow you to use a local Qiita server without logging in. You can track progress on this on issue [#920](https://github.com/biocore/qiita/issues/920).)
263
264
265
266
# Frequently Asked Questions and Troubleshooting
267
268
### `Error: database "qiita_test" already exists`
269
270
This usually happens after an incomplete run of the qiita-env setup procedure. Drop the postgres table named `qiita_test` and retry setting up qiita-env as per instructions above:
271
272
```bash
273
 $ psql
274
 DROP DATABASE qiita_test;\q
275
 # now re-run qiita-env make --no-load-ontologies
276
```
277
## Operating-system specific troubleshooting
278
279
### Ubuntu
280
281
#### `fe_sendauth: no password supplied`
282
283
If you get a traceback similar to this one when starting up Qiita
284
```python
285
File "/home/jorge/code/qiita/scripts/qiita-env", line 71, in make
286
  make_environment(load_ontologies, download_reference, add_demo_user)
287
File "/home/jorge/code/qiita/qiita_db/sql_connection.py", line 120, in __init__
288
  self._open_connection()
289
File "/home/jorge/code/qiita/qiita_db/sql_connection.py", line 155, in _open_connection
290
  raise RuntimeError("Cannot connect to database: %s" % str(e))
291
RuntimeError: Cannot connect to database: fe_sendauth: no password supplied
292
```
293
294
it can be solved by setting a password for the database (replace `postgres` with the actual name of the database qiita is configured to use):
295
296
```
297
$ psql postgres
298
ALTER USER postgres PASSWORD 'supersecurepassword';
299
\q
300
```
301
302
It might be necessary to restart postgresql: `sudo service postgresql restart`.
303
304
Furthermore, the `pg_hba.conf` file can be modified to change authentication type for local users to trust (rather than, e.g., md5) but we haven't tested this solution.
305
306
#### `Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.`
307
308
Run the following. Note that for older ubuntu versions (< 14), these commands may install an older version of postgres (< 9.3) which may cause trouble. Ensure you're downloading and installing postgresql 9.3 via a different apt repository as per [instructions here](https://www.postgresql.org/download/linux/ubuntu/).
309
310
```bash
311
sudo apt-get update
312
sudo apt-get install postgresql
313
sudo apt-get install postgresql-contrib
314
sudo apt-get install libpq-dev
315
```
316
317
#### ` c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory`
318
319
Missing dependency. Run the following and then re-run whatever command failed earlier:
320
321
```bash
322
sudo apt-get install -y libffi-dev
323
```
324
325
#### `from PyQt4 import QtCore, QtGui ImportError: libSM.so.6: cannot open shared object file: No such file or directory`
326
327
```bash
328
 sudo apt-get install -y python-qt4
329
```
330
331
#### `ERROR:  could not open extension control file "/usr/share/postgresql/9.3/extension/uuid-ossp.control": No such file or directory`
332
333
```bash
334
sudo apt-get install postgresql-contrib
335
# or: sudo apt-get install postgresql-contrib-9.3 depending on your OS and apt repository versions
336
```
337
338
### Apple Silicon Mac (M1/M2)
339
340
#### `no such file or directory` or `fatal error: file not found`
341
342
M1 and M2 macs have a new feature where homebrew is not installed to the path `usr/local/bin` like Intel Macs are, but to `opt/homebrew/bin`. This is because of reasons including security concerns with the old path, potential conflicts with installing to `/usr/local/bin`, and the fact that other package managers have been using `/opt/<manager_name>` for a while now. To fix this, ensure that homebrew libraries are being searched for in the `opt/homebrew/lib` path.
343
344
## General Troubleshooting
345
346
Please note that the following notes are related to dependencies that Qiita does not maintain. As such, we strongly suggest you consult their official documentation to resolve issues. We cannot guarantee the accuracy of the suggestions below.
347
348
### xcode
349
350
If running on OS X you should make sure that the Xcode and the Xcode command line tools are installed.
351
352
### postgres
353
354
If you are using Postgres.app 9.3 on OSX, a database user will be created with your system username. If you want to use this user account, change the `USER` and `ADMIN_USER` settings to your username under the `[postgres]` section of your Qiita config file.
355
356
### conda
357
358
If you are getting an error message running `conda create`, complaining about missing packages, then you might have to locate the appropriate conda channels and re-run `conda create` with the `--channel` flag:
359
360
For example, if `libgfortran` is missing:
361
362
```
363
# Install anaconda-client to search repositories
364
conda install anaconda-client
365
366
# Now search for missing package
367
anaconda search -t conda libgfortran
368
Using Anaconda Cloud api site https://api.anaconda.org
369
Run 'anaconda show <USER/PACKAGE>' to get more details:
370
Packages:
371
     Name                      |  Version | Package Types   | Platforms
372
     ------------------------- |   ------ | --------------- | ---------------
373
     OpenMDAO/libgfortran      |    4.8.3 | conda           | linux-32, osx-64
374
     aetrial/libgfortran       |          | conda           | linux-64
375
     ....etc....
376
```
377
378
Install the appropriate channel name that corresponds to your platform. For example, for Mac OS X 64-bit this would be:
379
380
`conda install --channel https://conda.anaconda.org/OpenMDAO libgfortran`
381
382
Now you can re-run your `conda create` command:
383
384
`conda create [previous parameters go here] --channel OpenMDAO/libgfortran`
385
386
### python
387
388
As a general rule of thumb you will want to have an updated version of Python 3.6.
389
390
H5PY is known to cause a few problems, however their [installation
391
instructions](http://docs.h5py.org/en/latest/build.html) are a great resource
392
to troubleshoot your system in case any of the steps above fail.
393
394
### matplotlib
395
396
In the event that you get `_tkinter.TclError: no display name and no $DISPLAY environment variable` error while trying to generate figures that rely on matplotlib, you should create a matplotlib rc file. This configuration file should have `backend : agg`. For more information you should visit the [matplotlib configuration](http://matplotlib.org/users/customizing.html) and [troubleshooting](http://matplotlib.org/faq/troubleshooting_faq.html#locating-matplotlib-config-dir) page.
397
398
## Generating certs for individual Qiita installations
399
400
Qiita comes with a set of certs used for continuous integration (CI) tests. These certs are located in qiita_core/support_files/ and are not the certs used in production Qiita; they are for development use ONLY. When installing Qiita for development purposes you may wish to generate a set of certs and keys for your own use.
401
dd
402
403
### Generate a new root CA private key and certificate:
404
405
`openssl req -x509 -sha256 -days 356 -nodes -newkey rsa:2048 -subj "/CN=localhost/C=US/L=San Diego" -keyout ci_rootca.key -out ci_rootca.crt`
406
407
### Generate a new server private key:
408
409
`openssl genrsa -out ci_server.key 2048`
410
411
### Copy the following to a new file named csr.conf and modify to suit your needs
412
413
```
414
[ req ]
415
default_bits = 2048
416
prompt = no
417
default_md = sha256
418
req_extensions = req_ext
419
distinguished_name = dn
420
421
[ dn ]
422
C = US
423
ST = California
424
L = San Diego
425
O = UCSD
426
OU = Knight Lab
427
CN = localhost
428
429
[ req_ext ]
430
subjectAltName = @alt_names
431
432
[ alt_names ]
433
DNS.1 = localhost
434
IP.1 = 127.0.0.1
435
```
436
437
### Generate a certificate signing request
438
439
`openssl req -new -key ci_server.key -out ci_server.csr -config csr.conf`
440
441
### Copy the following to a new file named cert.conf and modify to suit your needs
442
443
```
444
authorityKeyIdentifier=keyid,issuer
445
basicConstraints=CA:FALSE
446
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
447
subjectAltName = @alt_names
448
449
[alt_names]
450
DNS.1 = localhost
451
```
452
453
### Generate a new signed server.crt to use with your server.key
454
455
`openssl x509 -req -in ci_server.csr -CA ci_rootca.crt -CAkey ci_rootca.key -CAcreateserial -out ci_server.crt -days 365 -sha256 -extfile cert.conf`
456
457
### (Optional) Updating certifi package used by requests and urllib3 packages
458
The contents of server.crt can be appended to certifi package's CA cache after which the CA cert won't need to be passed to QiitaClient objects and the like.
459
460
### Start python interactively and get location of cacert.pem
461
462
```
463
import certifi
464
certifi.where()
465
'/Users/qiita_user/miniconda3/lib/python3.9/site-packages/certifi/cacert.pem'
466
```
467
468
### Append ci_rootca.crt to cacert.pem
469
470
`cat ci_rootca.crt >> '/Users/qiita_user/miniconda3/lib/python3.9/site-packages/certifi/cacert.pem'`