Manual

Pre-requisites

  • Visual C 2017 (*only Windows Users*): must install the Microsoft Visual C Compiler for Python Downloadable from here.

  • Python 2.7+: downloadable from python.org.

    Windows Users : If you are developing on Windows, make sure that Python is included in your system’s PATH environment variable. You can follow instructions here to set your PATH variable.

  • Git: downloadable from git-scm.org.

Windows Users : If you are developing on Windows, we recommend that you use a Windows 10 machine. Also, note that if you choose the Manual or Docker installation mode, you should also have administrative privileges on the Windows box so you can authorize the installation and running of the required executables.

Try it out

  • Verify the python installation (applicable only if you decided to use the Manual install option).

    • Run the following command from your terminal.

      bash python --version

      You should see the version of python displayed.

  • Verify git installation

    • Run the following command from your terminal.

      bash git --version

      You should see the version of git installed.

Couchbase Server

In this lesson, you will install and launch version 6.0.1 of Couchbase Server.

  • Download and install V6.0.1 of Couchbase Server. Follow the instructions specified in the appropriate platform specific install guide to install the same.

  • On the setup wizard, create an Administrator account with the user Administrator and password as password.

    createadminuser

  • As you follow the download instructions and setup wizard, make sure you keep all the services (data, query, and index) selected.

    cbs services
  • Install the sample bucket named travel-sample because it contains the data used in this tutorial. You can add the bucket from the "Sample Buckets" tab in the "Settings" menu in the admin console.

    sample bucket
  • Create an RBAC user named admin with password password and Application Access to the travel-sample bucket. You can do this from the "Security" menu. These credentials will be used by the Sync Gateway to access the documents in this bucket.
    add rbac

    RBAC user
  • Create a Full text search index on travel-sample bucket called 'hotels'. You can do this from the "Search" menu. Just go with default index settings.

    add fts

    fts

Try it out

  • Launch Couchbase Server (if not already runnning)

  • Log into the "Admin Console" (http://localhost:8091) with appropriate Administrator credentials you created during installation

  • Select the "Buckets" option from the menu on the left

  • Verify that you have around 31,000 documents in your travel-sample bucket

Sync Gateway

In this section, you will install and launch version 2.5 of Sync Gateway.

  • Install Sync Gateway 2.5 from here on your platform of choice

  • The Sync Gateway will have to be launched with the config file named sync-gateway-config-travelsample.json that you should have downloaded as part of the Travel Mobile App install. The config file will be located in /path/to/mobile-travel-sample.

  • Open the sync-gateway-config-travelsample.json and confirm that the RBAC user credentials configured on the Couchbase Server are used by Sync Gateway for accessing the bucket

    "username": "admin",
    "password": "password",
  • Launch the Sync Gateway.

    macOS

    $ cd /path/to/couchbase-sync-gateway/bin
    $ ./sync_gateway /path/to/mobile-travel-sample/sync-gateway-config-travelsample.json

    Windows

    By default, the Sync Gateway service will install with serviceconfig.json as the configuration file at C:\Program%20Files\Couchbase\Sync%20Gateway\serviceconfig.json.

    The Sync Gateway will have to be launched with the config file named sync-gateway-config-travelsample.json that you should have downloaded as part of the Travel Mobile App install. The config file will be located in C:/path/to/mobile-travel-sample.

    Open the sync-gateway-config-travelsample.json and confirm that the RBAC user credentials configured on the Couchbase Server are used by Sync Gateway for accessing the bucket.

    "username": "admin",
    "password": "password",
  • Stop the Sync Gateway service (since it was launched with the default version of config file). To stop the service, you can use the Services application (Control Panel -→ Admin Tools -→ Services).

  • Replace the serviceconfig.json file located at C:FilesGateway with the sync-gateway-config-travelsample.json that you downloaded.

    $ copy c:/path/to/mobile-travel-sample/sync-gateway-config-travelsample.json "C:\Program Files\Couchbase\Sync Gateway\serviceconfig.json"
  • Start the Sync Gateway service with the new version of serviceconfig.json file. To start the service, you can use the Services application (Control Panel -→ Admin Tools -→ Services).

Try it out

  • Access this URL http://localhost:4984 in your browser

  • Verify that you get JSON response similar to one below json {"couchdb":"Welcome","vendor":{"name":"Couchbase Sync Gateway","version":"2.5"},"version":"Couchbase Sync Gateway/2.5.0(271;bf3ddf6) EE"}

Python Backend

We will use the Python version of the Travel Sample.

Windows Users

  • The instructions in this section are for Windows users. Scroll to "Other Platforms" section for instructions for other platforms.

    Install the Couchbase Python SDK Installer. This can be downloaded from Pypi website. Scroll to the section which lists the relevant installers and select the installer corresponding to appropriate version of Python that you have installed on your machine.

    win py installer

  • Clone the 5.0 branch of Travel Sample web app repo

    $ git clone -b 5.0 https://github.com/couchbaselabs/try-cb-python.git
  • Verify the pip installation. If you are developing on Windows, pip.exe will be found in the "Scripts" sub directory under the Python installation directory. Add the path to the "Scripts" folder to the system’s PATH environment variable. You can follow instructions here to set your PATH variable. Verify that pip is recognized by typing the following in the cmd terminal. You should see the help menu.

    pip
  • The application uses several Python libraries that need to be installed, these are listed in requirements.txt and can be automatically loaded using the pip command.

    cd c:\path\to\try-cb-python
    pip install -r requirements.txt
  • Update travel.py to reflect the username and password that you have used when installing Couchbase Server. This defaults to "Administrator" and "password".

    DEFAULT_USER = "Administrator"
    PASSWORD = 'password'
  • Now launch the Travel Web App

    $ python travel.py
    $ Running on http://localhost:8080/ (Press CTRL+C to quit)

    You may see an alert similar to one below requesting access to run the app. Make sure you select the "Allow access" option. python run 1

Other Platforms

  • PREREQUISITE : First, install libcouchbase Core C SDK used by the Python SDK.

  • Follow instructions here to install libcouchbase on your platform of choice.

  • Clone the 5.0 branch of the Travel Sample web app repo.

    $ git clone -b 5.0 https://github.com/couchbaselabs/try-cb-python.git
    $ cd try-cb-python
  • We will run the Travel Web App in a Python virtual environment. First, check if virtualenv is installed on your system.

    $ virtualenv --version
  • If virtualenv is not installed , you can use apt-get or pip to install it.

    $ sudo pip install virtualenv
  • Specify the folder for your virtual environment.

    $ virtualenv .
  • Activate your environment. You should see a prompt as shown below.

    $ source bin/activate
    (try-cb-python) $
  • The application uses several Python libraries that need to be installed, this are listed in requirements.txt and can be automatically loaded using the pip command

    pip install -r requirements.txt
  • Update travel.py to reflect the username and password that you have used when installing Couchbase Server. This defaults to "Administrator" and "password".

    DEFAULT_USER = "Administrator"
    PASSWORD = 'password'
  • Now launch the Travel Web App

    $ python travel.py
    $ Running on http://localhost:8080/ (Press CTRL+C to quit)

Try it out

  • Open http://localhost:8080/ in your web browser

  • Verify that you see the login screen of the Travel Sample Web App as shown below try cb login