node.jsgithubpencilblueuberspace

How to install a nodejs cms like pencilblue on uberspace


I would like to have the pencilblue nodejs cms with mongodb installed on my uberspace account. Which steps do I have to take?


Solution

  • As I found it hard figuring out how to do it, here is how I finally succeeded. Most of it is relevant for nodeJS installations other than pencilblue as well.

    First you need to create an account on uberspace.de.

    Open your terminal and login into your uberspace console with ssh:

    ssh {account}@{server}.uberspace.de
    

    Enter the password you created with the creation of the account.

    Create the service directory:

    uberspace-setup-svscan
    

    Create the mongo database:

    uberspace-setup-mongodb
    

    Create folder for database data:

    mkdir data
    cd data
    mkdir db
    

    Start db:

    mongod --dbpath data/db/
    

    You will get some login data. I suggest you write it down somewhere:

    Hostname: localhost
    Portnum#: {dbPort}
    Username: {account}_mongoadmin
    Password: {dbPassword}
    

    To connect to the db via shell you may use:

    mongo admin --port {dbPort} -u {account}_mongoadmin -p)
    

    Configure npm:

    cat > ~/.npmrc <<__EOF__
    prefix = $HOME
    umask = 077
    __EOF__
    

    Install pencilblue-cli:

    npm install pencilblue-cli
    

    Change to html-folder and create a .htaccess file (you could do this with your ftp-client as well):

    RewriteEngine On
    RewriteRule ^(.*) http://localhost:8080/$1 [P]
    

    Now if you want to use github: Create a new repository on github.

    Open a new terminal window and clone pencilblue cms in a local folder on your machine:

    git clone git@github.com:pencilblue/pencilblue.git pencilblue
    cd pencilblue
    git remote set-url origin git@github.com:{yourGitName}/{yourRepoName}.git
    git add .
    git commit -m "Initial commit."
    

    Setup ssh on uberspace: Go back to your uberspace console.

    ssh-keygen -t rsa -b 4096 -C "{yourEmailAddress}"
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa
    cat ~/.ssh/id_rsa.pub
    

    Copy the whole key that is printed out and paste it in github under settings/SSH keys.

    Clone the new repo in uberspace console:

    git clone git@github.com:{yourGitName}/{yourRepoName}.git cms
    cd cms
    

    Create a config.js either with vim config.js or upload it with ftp:

    module.exports = {
        "siteName": "{yourSiteName}",
        "siteRoot": "http://{account}.{server}.uberspace.de/",
        "sitePort": {
            8080
        },
        "logging": {
            "level": "info"
        },
        "db": {
            "type": "mongo",
            "servers": [
                "mongodb://{account}_mongoadmin:{dbPassword}@127.0.0.1:{dbPort}/"
            ],
            "name": "admin",
            "writeConcern": 1
        },
        "cache": {
            "fake": false,
            "host": "localhost",
            "port": 6379
        },
        "settings": {
            "use_memory": false,
            "use_cache": false
        },
        "templates": {
            "use_memory": true,
            "use_cache": false
        },
        "plugins": {
            "caching": {
                "use_memory": false,
                "use_cache": false
            }
        },
        "registry": {
            "type": "mongo"
        },
        "session": {
            "storage": "mongo"
        },
        "media": {
            "provider": "mongo",
            "max_upload_size": 6291456
        },
        "cluster": {
            "workers": 1,
            "self_managed": true
        },
        "siteIP": "0.0.0.0"
    };
    

    Install node_modules:

    npm install
    

    Create a service that starts the server:

    uberspace-setup-service pbservice node ~/cms/pencilblue.js
    

    Start the service:

    svc -u ~/service/pbservice
    

    Now you can go to the page on http://{account}.{server}.uberspace.de

    (To start the service (hint: u = up):

    svc -u ~/service/pbservice
    

    To stop the service (hint: d = down):

    svc -d ~/service/pbservice
    

    To reload the service (hint: h = HUP):

    svc -h ~/service/pbservice
    

    To restart the service (hint: du = down, up):

    svc -du ~/service/pbservice
    

    To remove the service:

    cd ~/service/pbservice
    rm ~/service/pbservice
    svc -dx . log
    rm -rf ~/etc/run-pbservice)