Git Product home page Git Product logo

np's Introduction

PhoGraphe

Small picture gallery that highlight rare links between pictures. Each picture is tagged and two pictures are linked if and only if only few pictures contains the same common tags (basically). The software uses Vue for the frontend with VisJS-network to display the network, Rust WASM for frontend computations and Django for the backend.


Prerequisites

  • Static image hosting with SFTP access (see How to Setup a SFTP user)
  • Python Django for the backend
  • Mysql Database or any other database supported by Django
  • VueJS for the frontend

Deployment

Rust computations

Install Rust and wasm-pack

curl https://sh.rustup.rs -sSf | sh
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Frontend

  1. Install and build the application
npm install
npm build
  1. Create a symbolic link to serve the application
sudo ln -s  dist /var/www/<your domain>

Backend - basics

  1. Clone the source code
git clone https://github.com/Marc-AntoineA/NP.git
  1. Install virtual env and the Python requirements
cd backend
sudo apt-get install python3-venv
python3 -m venv python_env
  1. Activate the virtual environment
source python_env/bin/activate
deactivate # to deactivate the environent
  1. Install the requirements
pip install requirements.txt
  1. Edit the backend/settings.py
DATABASES = {
    'default': {
      'ENGINE': 'django.db.backends.mysql',
      'NAME': 'phographebase',
      'USER': 'phographeuser',
      'PASSWORD': '',
      'HOST': 'localhost',
      'PORT': '1433'
    }
}
  1. Make migrations
python manage.py makemigrations
python manage.py migrate
  1. Create a superuser
python manage.py createsuperuser
  1. Start the server (testing purpose)
python manage.py runserver 0.0.0.0:8000

The 0.0.0.0:8000 allows access to the server from outside.

Backend - mod_wsgi

  1. Install mod_wsgi

  2. Install mod_xsendfile

sudo apt-get install libapache2-mod-xsendfile
sudo e2enmod xsendfile

Conf files

Start

Helps

Setup a static apache2 hosting

  1. Create the directory into your /var/www repository.
mkdir <url>

Setup a Mysql Database

  1. Install and login into Mysql
  2. Create the dabase and setup the user with read and write and only local access (if deployed on the same server than the backend)
CREATE DATABASE phographebase;
CREATE USER 'phouser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON prographebase. * TO 'phographeuser'@'localhost';
FLUSH PRIVILEGES;
  1. Setup the connection with Django

Setup sftp User

To create the user <username> from the group <user-group> to have access only to /var/www/<domain> with the password you wants.

  1. Setup the user
sudo apt-get install openssh-server
sudo groupadd <user-group>
sudo useradd -g <user-group> -d /var/www/<domain>/ -s /sbin/nologin <username>

Warning If -s /sbin/nologin doesn't exist, use /usr/sbin/nologin

  1. Setup your password
sudo passwd <username>
  1. Test if everything is fine
cat /etc/passwd | grep <username>

You should see something like

<username>:x:1002:1002::/var/www/<domain>/:/sbin/nologin
  1. uae

Nope Add permisions chown -R sftpuser: /data/dirstatinfo/csvfiles

Configure ssh protocole $ vim /etc/ssh/sshd_config

Subsystem sftp internal-sftp Match Group ChrootDirectory /path/to/files ForceCommand internal-sftp

Enable Chroot setsebool -P ssh_chroot_rw_homedirs=1

Restart the ssh service /etc/init.d/sshd restart

Be careful, the Chroot is on the main folder and the chown to the local user in the subfolders

np's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.