There are two ways to install the store, both are mutually exclusive (means: don’t mix and match). If you are looking for a development setup, proceed to Development Installation, otherwise continue.
This guide will use Ubuntu 16.04, Apache and PostgreSQL to set up the app store. You can of course also use different distributions and web-servers, however we will not be able to support you.
First you want to switch your machine to an up to date Node.js version and install Yarn:
curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add - echo "deb https://deb.nodesource.com/node_8.x xenial main" | sudo tee /etc/apt/sources.list.d/nodesource.list echo "deb-src https://deb.nodesource.com/node_8.x xenial main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then install the following libraries:
sudo apt-get update sudo apt-get install python3-venv python3-wheel libxslt-dev libxml2-dev libz-dev libpq-dev build-essential python3-dev python3-setuptools git gettext libssl-dev libffi-dev nodejs yarn
Then install the database:
sudo apt-get install postgresql
echo "listen_address = '127.0.0.1'" | sudo tee -a /etc/postgresql/9.5/main/pg_ident.conf sudo systemctl restart postgresql.service
and create a user and database:
sudo -s su - postgres psql CREATE USER nextcloudappstore WITH PASSWORD 'password'; CREATE DATABASE nextcloudappstore OWNER nextcloudappstore; \q exit exit
Use your own password instead of the password example!
App Store Setup¶
Before you begin to set up the App Store, make sure that your locales are set up correctly. You can fix your locales by running:
export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" sudo dpkg-reconfigure locales
Afterwards change into your preferred target folder, clone the repository using git and change into it:
cd /path/to/target git clone https://github.com/nextcloud/appstore.git cd appstore
Afterwards set up a new virtual environment by running the following command:
python3 -m venv venv
This will create a local virtual environment in the venv folder. You only need to do this once in the beginning.
Then activate it:
The above command changes your shell settings for the current session only, so once you launch a new terminal you need to run the command again to register all the paths.
Keep in mind that you need to have the virtual environment activated for all the following commands
Installing Required Libraries¶
Next install the required libraries:
pip install --upgrade wheel pip install --upgrade pip pip install -r requirements/base.txt pip install -r requirements/production.txt
Adjusting Default Settings¶
To get your instance running in production you need to create your production settings file in nextcloudappstore/settings/production.py which overwrites and enhances the settings defined in nextcloudappstore/settings/base.py. The production settings file is excluded from version control and should contain at least something like the following:
Then set the file as the active settings file:
Absolutely make sure to generate a new SECRET_KEY value! Use the following command for instance to generate a token:
env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 64; echo
For more settings, check the settings documentation.
Creating the Database Schema¶
After all settings are adjusted, create the database schema by running the following command:
python manage.py migrate
Creating an Admin User¶
To create the initial admin user and verify his email, run the following command:
python manage.py createsuperuser --username admin --email firstname.lastname@example.org python manage.py verifyemail --username admin --email email@example.com
The first command will ask for the password.
Loading Initial Data¶
To pre-populate the database with categories and other data run the following command:
python manage.py loaddata nextcloudappstore/**/fixtures/*.json
To import all translations run:
python manage.py compilemessages python manage.py importdbtranslations
Building the Frontend¶
To build the frontend run:
yarn install yarn run build
Placing Static Content¶
sudo mkdir -p /var/www/production-domain.com/static/ sudo mkdir -p /var/www/production-domain.com/media/
Then copy the files into the folders by executing the following commands:
sudo chown -R $(whoami):users /var/www python manage.py collectstatic sudo chown -R www-data:www-data /var/www
This will place the contents inside the folder configured under the key STATIC_ROOT and MEDIA_ROOT inside your nextcloudappstore/settings/production.py
Configuring the Web-Server¶
First install Apache and mod_wsgi:
sudo apt-get install apache2 libapache2-mod-wsgi-py3
Then adjust the config in /etc/apache2/sites-enabled/default.conf and add the following configuration to your VirtualHost section:
<VirtualHost *:80> WSGIDaemonProcess apps python-home=/path/to/appstore/venv python-path=/path/to/appstore WSGIProcessGroup apps WSGIScriptAlias / /path/to/appstore/nextcloudappstore/wsgi.py WSGIPassAuthorization On Alias /static/ /var/www/production-domain.com/static/ Alias /schema/apps/info.xsd /path/to/appstore/nextcloudappstore/api/v1/release/info.xsd Alias /schema/apps/database.xsd /path/to/appstore/nextcloudappstore/api/v1/release/database.xsd <Directory /path/to/appstore/nextcloudappstore> <Files wsgi.py> Require all granted </Files> </Directory> <Directory /path/to/appstore/nextcloudappstore/api/v1/release> <Files info.xsd> Require all granted </Files> <Files database.xsd> Require all granted </Files> </Directory> <Directory /var/www/production-domain.com/static/> Require all granted AllowOverride None </Directory> <Directory /var/www/production-domain.com/media/> Require all granted AllowOverride None </Directory> </VirtualHost>
Your configuration will look different depending on where you place your static files and if you enable SSL. This is just a very minimal non HTTPS example.
Finally restart Apache:
sudo systemctl restart apache2
Depending on where you have configured the log file location, you need to give your web server access to it. By default the logfile is in the main directory which also contains the manage.py and README.rst.
First create the log file:
Then give your web server access to it:
sudo chown www-data:www-data appstore.log
Afterwards restart your web server:
sudo systemctl restart apache2
Keeping Up To Date¶
Updating an instance is scripted in scripts/maintenance/update.sh. Depending on your distribution you will have to adjust the scripts contents.
For Ubuntu you can run the provided script:
git pull --rebase origin master sudo chown -R $(whoami):users /var/www bash scripts/maintenance/update.sh apache sudo chown -R www-data:www-data /var/www
The above commands assume that your static content is located in /var/www
By default monitoring the application via New Relic is supported by simply placing a file called newrelic.ini into the base folder (the folder that also contains the manage.py file).