-
Notifications
You must be signed in to change notification settings - Fork 3
Setting up the server
Install the necessary packages, and then setup and start the database server.
# Ubuntu
sudo apt-get install mariadb-server libmariadbclient-dev python-dev
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# OpenSUSE
sudo zypper install libmariadb-devel
# All
sudo mysql_secure_installation
sudo systemctl enable mariadb
Create database and user, and make sure to change name/username/password for production.
sudo mysql -u root -p
CREATE DATABASE cosmos_website_test CHARACTER SET UTF8;
CREATE USER cosmos_website_tester@localhost IDENTIFIED BY '2020123';
GRANT ALL PRIVILEGES ON cosmos_website_test.* TO cosmos_website_tester@localhost;
FLUSH PRIVILEGES;
exit
git clone https://github.com/bcvandendool/Cosmos.git
cd Cosmos
Create and activate the virtual environment
python3 -m venv .venv
source .venv/bin/activate
Update pip and install the python requirements
pip install --upgrade pip
pip install -r requirements.txt
Copy the secrets file from server/secrets.json to /etc/secrets.json, and fill in the credentials. Make sure they are kept secret and are different from the default credentials in the file.
Create and apply migrations to the database, this sets up the initial database structure.
python manage.py migrate
Create an admin user
python manage.py createsuperuser
Check if setting up the database worked
python manage.py runserver 0.0.0.0:8000
Copy the systemd service and socket and reload the services
sudo cp server/cosmos-website.* /etc/systemd/system/
sudo systemctl daemon-reload
Copy sudoers file to give the automatic deployment user permission to run the service
sudo cp server/deployerperm /etc/sudoers.d/
Copy and symlink the Nginx config file and then enable and start it
sudo cp server/nginx-cosmosweb /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/nginx-cosmosweb /etc/nginx/sites-enabled
sudo systemctl --now enable nginx
Copy the shell script that is used for automated git deployment
cp server/update.sh ..
Finally enable and start the server
sudo systemctl --now enable cosmos-website.socket