PYTHONAPP
Jump to navigation
Jump to search
Karaoke app Deployment
Prerequisite Check
- ssh into the server
- verify what is installed
apache2 -v python3 --version mysql --version which certbot
- if certbot isn't installed
sudo apt update sudo apt install certbot python3-certbot-apache -y
- Install Python venv if needed:
sudo apt install python3-venv python3-pip -y
Create the App Directory
sudo mkdir -p /var/www/html/myapp cd /var/www/html/myapp
Upload App Files
- Upload the .env file (hidden, so it won't be picked up by scp -r)
If you don't see .env in Finder, press Cmd+Shift+. to toggle hidden files.
Set up the Python Environment
cd /var/www/html/myapp python3 -m venv venv source venv/bin/activate pip install flask pymysql cryptography gunicorn DBUtils deactivate
The cryptography package is required for MySQL caching_sha2_password auth.
Configure the Database
Open phpMyAdmin in your browser. Make sure the user in your .env file has privileges on the karaoke database. If not, in phpMyAdmin run:
GRANT ALL PRIVILEGES ON dbasename.* TO 'YourUser'@'localhost'; FLUSH PRIVILEGES;
Verify your .env file on the server has the correct values:
cat /var/www/html/rb222/.env
It should contain
DB_HOST=localhost DB_USER=YourUser DB_PASS=YourPassword DB_NAME=dbasename SECRET_KEY=some-random-string HOST_NAME= name for the host side PORT=3001
Important: Use a different port from any other apps you have running. I'm using 3001 here — pick whatever's free.
Test App Manually
cd /var/www/html/myapp source venv/bin/activate python3 app.py