View difference between Paste ID: zFfLuMV6 and T9NeTnJF
SHOW: | | - or go back to the newest paste.
1-
====
1+
Title: Throat Install Guide, base Alpine Linux 3.10 multi-db
2-
Assume basic installation of Alpine Linux, openssh server installed and setup, a non-root user created.
2+
3-
====
3+
###
4
### Assume basic installation of Alpine Linux, openssh server installed and setup, a non-root user created and added to /etc/sudoers, bash installed
5-
su -
5+
###
6-
apk add --no-cache git bash build-base libffi-dev openssl-dev bzip2-dev zlib-dev readline-dev sqlite-dev curl bash bash-doc bash-completion redis npm mariadb mariadb-client mariadb-connector-c-dev jpeg-dev exiv2-dev boost-dev libxml2-dev libxslt-dev freetype-dev
6+
7
## Switch to root and  install dependencies
8
sudo su -
9
apk add --no-cache git bash build-base libffi-dev openssl-dev bzip2-dev zlib-dev readline-dev sqlite-dev curl bash bash-doc bash-completion redis npm jpeg-dev exiv2-dev boost-dev libxml2-dev libxslt-dev freetype-dev
10
11-
echo 'export PATH="/home/app/.pyenv/bin:$PATH"' >> ~/.bashrc
11+
## This is needed for the pip stage later on
12-
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
12+
ln -s /usr/lib/libboost_python37.so /usr/lib/libboost_python3.so
13-
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
13+
14-
bash
14+
## Create user under which throat is installed and switch to it.
15-
pyenv install 3.5.7
15+
16-
pyenv virtualenv 3.5.7 app
16+
17
18
## Setup pyenv
19
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
20
echo 'export PATH="/home/app/.pyenv/bin:$PATH"' >> ~/.profile
21
echo 'eval "$(pyenv init -)"' >> ~/.profile
22
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.profile
23
exit
24
25
### Database-related setup, pick your poison
26
27
##
28
## [M] For MySQL/MariaDB:
29
##
30-
mysqladmin -u root password "P@ssword"
30+
apk add --no-cache mariadb mariadb-client mariadb-connector-c-dev
31
mysql_install_db --user=mysql --datadir=/var/lib/mysql
32
rc-service mariadb start
33
mysqladmin -u root password "Pass1234"
34-
CREATE USER 'throat'@localhost IDENTIFIED BY 'P@ssword';
34+
35
mysql -u root -p
36
CREATE DATABASE throat;
37
CREATE USER 'throat'@localhost IDENTIFIED BY 'Pass1234';
38
GRANT ALL PRIVILEGES ON throat.* TO 'throat'@localhost;
39
exit
40
## [M] end
41
42-
bash
42+
##
43
## [P] For Postgresql:
44
##
45
apk add --no-cache postgresql postgresql-client postgresql-dev
46-
#set DB_USER to throat
46+
sudo su - postgres
47-
#set DB_PASSWD to P@ssword
47+
psql
48-
#set DB_NAME to throat (or whatever was created, default is phuks)
48+
49
CREATE USER throat PASSWORD 'Pass1234';
50-
cd scripts
50+
GRANT ALL PRIVILEGES ON DATABASE throat TO throat;
51-
./install.py
51+
52-
cd ..
52+
## [P] end
53
54-
#socketio.run(app, debug=True, host='0.0.0.0')
54+
##
55
## [S] For SQLite:
56-
# to run: ./wsgi.py
56+
##
57-
# find IP of your machine, visit: http://<ip address>:5000
57+
58-
# username: admin, password: adminadmin
58+
apk add --no-cache sqlite
59
60
## [S] end
61
62
## Start redis and add to startup
63
rc-service redis start
64
rc-update add redis default
65
66
## Switch back to app and install python and set virtualenv
67
su - app
68
pyenv install 3.6.8
69
pyenv virtualenv 3.6.8 app
70
71
## Download throat, build css, assign dir to aforementioned virtualenv
72
git clone https://phab.phuks.co/source/throat.git
73
cd throat
74
npm install
75
npm run build
76
pyenv local app
77
78
## Upgrade pip, get requirements
79
pip install --upgrade pip
80
pip install -r requirements.txt
81
82
##
83
## [S] For SQLite:
84
##
85
sqlite3 throat.db
86
.quit
87
## [S] end
88
89
90
## Create and modify config
91
cp example.config.py config.py
92
nano config.py
93
94
##
95
## Database connection configuration
96
##
97
98
# [M] For MySQL/MariaDB:
99
DATABASE = {
100
    'host': 'localhost',
101
    'name': 'throat',
102
    'engine': 'MySQLDatabase',
103
    'charset': 'utf8mb4',
104
    'user': 'throat',
105
    'password': 'Pass1234',
106
}
107
# [M] end
108
109
# [P] For Postgresql:
110
DATABASE = {
111
    'host': 'localhost',
112
    'name': 'throat',
113
    'engine': 'PostgresqlDatabase',
114
    'user': 'throat',
115
    'password': 'Pass1234',
116
    'autorollback': True
117
}
118
# [P] end
119
120
# [S] For SQLite:
121
DATABASE = {
122
    'name': '/home/app/throat/throat.db',
123
    'engine': 'SqliteDatabase',
124
}
125
# [S] end
126
127
#----------
128
129
## Setup database
130
scripts/migrate.py
131
132
## to be able to access it from outside localhost...
133
nano wsgi.py
134
#add ", host='0.0.0.0'" to "socketio.run(app, debug=True)" inside parentheses
135
 
136
## to run: ./wsgi.py
137
## find IP of your machine (ifconfig), visit: http://<ip address>:5000
138
139
## Create an account for admin, close wsgi, then run:
140
scripts/admins.py --add admin
141
142
## To add created subs to defaults:
143
scripts/defaults.py -a subname