Social Web Blog




Social Web installation instructions on linux (2024-06-15):
[![IMAGE ALT TEXT](http://img.youtube.com/vi/GbQWyLRDmE0/0.jpg)](http://www.youtube.com/watch?v=GbQWyLRDmE0 "youtube.com 10:59 Social Web installation") # requirements - Windows or Mac PC with a Terminal app - Linux web hosting provider (virtual server w/2GB memory) - About 15 minutes # create virtual linux server Our test installation uses Linode.com Linux web hosting provider Details: Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-94-generic x86_64) You can use the built-in domain name, it looks like this: 173-255-253-78.ip.linodeusercontent.com # set up a domain name (optional) use your own domain name (example): coolposts.net or use a subdomain (example): lisa.coolposts.net To use your domain name, find the Manage DNS Settings for your domain name. Get the Public IP address for your Linux virtual server, it looks like this: 173.255.253.78 Go to Manage DNS Settings and add an "A" record (see subdomain example below) | Record Type | Name | IP Address | | A | lisa | 173.255.253.78 | # install app (open a Terminal app on a Mac or Windows and connect by typing "ssh root@[your domain name]" and hit [return] key example:) ``` ssh root@173-255-253-78.ip.linodeusercontent.com ``` (add a new user account to the linux server for the app to run under) (set password for new user account) ``` adduser socialweb ``` (allow new user account to do limited server admin activity) ``` usermod -aG sudo socialweb ``` (commands to enable firewall) ``` ufw allow ssh ufw allow http ufw allow https ufw enable ``` (switch to app user account) ``` su socialweb ``` (two commands to update and install linux server software) (enter password of new user account) ``` sudo apt update sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools unzip ``` (install python virtual environment) ``` sudo apt install python3-venv ``` (download socialweb app to /home/socialweb directory) ``` cd $HOME; wget https://socialweb.cloud/swc.zip -P ~/ ``` (unzip files to "mysite" folder in home directory) ``` unzip ~/*zip -d ~/ ``` (copy the example config file) ``` cp ~/mysite/config.py.example ~/mysite/config.py ``` (use pico text editor to change the domain name in the config file) ``` pico ~/mysite/config.py ``` (use arrow keys to change domain, host, chainfile and keyfile and then use CONTROL-X to save changes and exit pico) ``` MYDOMAIN = '173-255-253-78.ip.linodeusercontent.com' HOST = '173.255.253.78' CHAINFILE = '/home/socialweb/fullchain.pem' KEYFILE = '/home/socialweb/privkey.pem' ``` (use the following keyboard commands to save your changes in pico and exit) ``` [CONTROL]-[X] [Y KEY] [RETURN KEY] ``` (create a python virtual environment for the code to run in) ``` python3 -m venv ~/socialwebenv ``` (enable/activate python virtual environment for installing software packages) ``` source ~/socialwebenv/bin/activate ``` (install software dependencies for app) ``` pip install -r ~/mysite/requirements.txt ``` (use pico text editor to create and edit system service file) ``` sudo pico /etc/systemd/system/socialweb.service ``` (CHANGE THE IP ADDRESS in the data below this, and then copy/paste into pico, and then use CONTROL-X to save changes and exit pico) ``` After=network.target [Service] User=socialweb Group=socialweb WorkingDirectory=/home/socialweb/mysite Environment="PATH=/home/socialweb/socialwebenv/bin" ExecStart=/usr/bin/authbind --deep /home/socialweb/socialwebenv/bin/gunicorn --reload --worker-class eventlet -w 1 --certfile=/home/socialweb/fullchain.pem --keyfile=/home/socialweb/privkey.pem --bind 173.255.253.78:443 --log-file=/home/socialweb/applog.txt app:app [Install] WantedBy=multi-user.target ``` (use the following keyboard commands to save your changes in pico and exit the text editor) ``` [CONTROL]-[X] [Y KEY] [RETURN KEY] ``` (reload system files) ``` sudo systemctl daemon-reload ``` (install certbot for getting an SSL certificate) ``` sudo apt-get install certbot ``` (request a certificate from certbot) (type email address) (press Y key to agree) (press N key to decline) (type or paste domain name, for example: 173-255-253-78.ip.linodeusercontent.com) ``` sudo certbot certonly --standalone ``` (CHANGE THE DOMAIN NAME in these commands to copy SSL certs to /home/socialweb directory and set permissions on files) ``` sudo cp /etc/letsencrypt/live/173-255-253-78.ip.linodeusercontent.com/privkey.pem /home/socialweb sudo cp /etc/letsencrypt/live/173-255-253-78.ip.linodeusercontent.com/fullchain.pem /home/socialweb sudo chown socialweb /home/socialweb/*pem ``` (allow gunicorn binary to use port privileged 443 port by non-root user account) ``` sudo apt-get install authbind sudo touch /etc/authbind/byport/80 sudo touch /etc/authbind/byport/443 sudo chmod 777 /etc/authbind/byport/80 sudo chmod 777 /etc/authbind/byport/443 ``` (start app) ``` sudo service socialweb start ``` (re-start app and tail log file) ``` sudo service socialweb restart; tail -f $HOME/*.txt ```