서버준비 -> 방화벽 설정 -> Python설치 -> 가상환경 설정 -> 코드 배포 및 실행
cd <ssh key 가 있는 폴더 경로 이동>
ssh -i ssh-key-2024-09-23.key opc@193.xxx.xxx.xxx
git command not found 오류 발생.sudo dnf install git -y
git clone https://github.com/<github ID>/<배포할repository>.git
프로젝트에서 필요한 Python 을 구축하기 위해 python 을 설치.
sudo dnf install curl gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y
wget https://www.python.org/ftp/python/3.12.5/Python-3.12.5.tar.xz
tar -xf Python-3.12.5.tar.xz
cd Python-3.12.5/
./configure --enable-optimizations
make -j 2
sudo make altinstall
python3.12 -V
cd ai_assistant
python3.12 -m venv .myenv
source .myenv/bin/activate
touch .env
nano .env

pip install load_dotenv openai fastapi uvicorn
sudo firewall-cmd --zone=public --permanent --add-port=8000/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-all # 포트가 잘 열렸는지 확인
uvicorn main:app --reload --host 0.0.0.0 --port 8000
만일 위의 초기 설치같은 것들이 필요 없고, 모든 설정이 완료가 되어있는 상태에서 다시 연결 한다면 서버 재연결은 너무나 간단해진다.
cd <ssh key 가 있는 폴더 경로 이동>
ssh -i ssh-key-2024-09-23.key opc@193.***.***.***
cd ai_assistant
source .myenv/bin/activate
nohup uvicorn main:app --reload --host 0.0.0.0 --port 8000 &
서버를 백그라운드로 실행하고 싶다면 nohup을 붙여주고 그것이 아니라면 빼고 진행.