나는 이전에 MariaDB 서버를 오라클 클라우드를 이용하여 구축하였다.
라이믹스의 DB 서버는 해당 서버를 이용할 예정이다.
DB/사용자 생성 코드
CREATE DATABASE rhymix CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'rhymix'@'%' IDENTIFIED BY '비밀번호';
GRANT ALL PRIVILEGES ON rhymix.* TO 'rhymix'@'%';
FLUSH PRIVILEGES;
파일 설치
1. Rhymix 소스 다운로드
cd /home/ubuntu
git clone https://github.com/rhymix/rhymix.git
2. 폴더 이동
# rhymix 폴더가 바로 설치 경로
cd /home/ubuntu/rhymix
3. 퍼미션 설정
# ubuntu 계정이 홈 디렉토리 권한 있으므로 소유권은 그대로
mkdir files
chmod 755 files
# 웹서버가 www-data라면 접근 위해 group 추가 필요
sudo usermod -aG www-data ubuntu
files 폴더는 CMS 동작에 쓰기 권한 필요.
웹서버 및 PHP 설치
1. PHP 8.2 설치
sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
# PHP 8.2 및 필수 확장 설치
sudo apt install -y php8.2 php8.2-fpm php8.2-cli php8.2-mysql php8.2-mysqli php8.2-pdo php8.2-mbstring php8.2-xml php8.2-curl php8.2-gd php8.2-zip php8.2-opcache
현재 작성 기준 LTS는 PHP 8.2가 현재 안정화된 장기 지원 버전입니다.
2. Nginx 설치
sudo apt update
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx # 설치 및 실행 확인
3. Nginx 설정
Rhymix를 /home/ubuntu/rhymix에 설치했으므로 새 서버 블록(conf) 파일을 생성하는 방법이 가장 안전합니다.
sudo nano /etc/nginx/sites-available/rhymix
nano 대신 vi, vim, code 등 편한 편집기 사용 가능
4. 서버 블록 설정 예시
server {
listen 80;
server_name yourdomain.com; # 본인 도메인
root /home/ubuntu/rhymix; # 라이믹스 설치 경로
index index.php index.html;
client_max_body_size 32m;
include snippets/rhymix.conf; # 라이믹스 rewrite 규칙 인클루드
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include snippets/fastcgi-php.conf;
}
}
주의: 라이믹스 2.0부터는 rewrite 규칙에 location / { try_files ... } 블럭이 포함되어 있으므로 사이트 설정에 동일한 블럭을 추가하면 오류가 발생합니다.
최근 Ubuntu에서는 nginx와 관련된 잡다한 설정파일들은 /etc/nginx/snippets 폴더에 넣는 것이 관례입니다.
라이믹스에서 제공하는 rewrite 규칙 파일을 다운받아 이 폴더에 rhymix.conf라는 이름으로 넣습니다.
curl https://raw.githubusercontent.com/rhymix/rhymix/master/common/manual/server_config/rhymix-nginx.conf | sudo tee /etc/nginx/snippets/rhymix.conf > /dev/null
5. 설정 활성화
# sites-enabled로 심볼릭 링크 생성
sudo ln -s /etc/nginx/sites-available/rhymix /etc/nginx/sites-enabled/
# Nginx 설정 문법 확인
sudo nginx -t
# Nginx 재시작
sudo systemctl reload nginx
6. 방화벽 활성화 (OCI는 iptables 사용)
# 전체 확인
sudo iptables -L -n -v --line-numbers
# INPUT 체인만 확인
sudo iptables -L INPUT -n -v --line-numbers
# 방화벽 추가
sudo iptables -I INPUT 5 -p tcp -m state --state NEW --dport 80 -j ACCEPT
sudo iptables -I INPUT 6 -p tcp -m state --state NEW --dport 443 -j ACCEPT
라인넘버는 "reject-with icmp-host-prohibited" 위에다 해줘야한다. 본인 상황에 맞게 라인넘버를 입력하면 된다.
(선택사항) HTTPS 설정 (클라우드 플레어)
1. Certbot + Cloudflare 플러그인 설치
sudo apt update
sudo apt install -y certbot python3-certbot-nginx python3-certbot-dns-cloudflare
2. Cloudflare API 키 설정
Cloudflare API 토큰 생성
Cloudflare → My Profile → API Tokens Create Token 권한 설정:
Zone → DNS → Edit
Zone → Zone → Read 토큰 생성 후 복사
2-1. Cloudflare 자격 증명 파일 생성
sudo mkdir -p /etc/letsencrypt
sudo nano /etc/letsencrypt/cloudflare.ini
2-2. 다음 내용 입력
dns_cloudflare_api_token = YOUR_API_TOKEN_HERE
sudo chmod 600 /etc/letsencrypt/cloudflare.ini
600으로 해야 certbot이 읽을 수 있고, 다른 사용자는 접근 불가
3. 인증서 발급
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini -d yourdomain.com -d "*.yourdomain.com"
질문에 답변:
- Email: 입력
- Terms of Service: Y
- Share email: N (또는 원하는 대로)
발급 완료 시: /etc/letsencrypt/live/yourdomain.com/에 인증서 저장
4. 인증서 자동 갱신 설정
인증서 갱신 후 Nginx를 자동으로 재시작하도록 설정:
sudo nano /etc/letsencrypt/renewal/yourdomain.com.conf
[renewalparams] 섹션에 다음 줄 추가:
post_hook = systemctl reload nginx
인증서 자동 갱신 확인
# 자동 갱신 타이머 확인
sudo systemctl list-timers | grep certbot
# 갱신 테스트
sudo certbot renew --dry-run
# 인증서 만료일 확인
sudo certbot certificates
5. Nginx 설정
sudo nano /etc/nginx/sites-available/rhymix
# HTTP → HTTPS 리다이렉트
server {
listen 80;
server_name yourdomain.com *.yourdomain.com;
return 301 https://$host$request_uri;
}
# HTTPS 서버
server {
listen 443 ssl http2;
server_name yourdomain.com *.yourdomain.com;
root /home/ubuntu/rhymix; # 라이믹스 설치 경로
index index.php index.html;
client_max_body_size 32m;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
include snippets/rhymix.conf; # 라이믹스 rewrite 규칙 인클루드
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
설치 경로 /home/ubuntu/rhymix 확인 후 수정
PHP-FPM 소켓 경로는 서버 PHP 버전 확인 후 맞춰야 함
6. Nginx 적용
sudo ln -s /etc/nginx/sites-available/rhymix /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
7. SSL 검증
Cloudflare Dashboard → SSL/TLS → Full (Strict) 모드
웹 브라우저 접속 > 정상 연결 확인
권한 설정
# 상위 디렉터리 통과 권한 부여
sudo chmod 755 /home
sudo chmod 755 /home/ubuntu
sudo chmod 755 /home/ubuntu/rhymix
# 파일 권한 정리
sudo find /home/ubuntu/rhymix -type d -exec chmod 755 {} \;
sudo find /home/ubuntu/rhymix -type f -exec chmod 644 {} \;
# 소유권 확인
sudo chown -R ubuntu:ubuntu /home/ubuntu/rhymix
# 재시작
sudo systemctl restart nginx
sudo systemctl restart php8.2-fpm
접속 후 라이믹스 설정창대로 진행
DB 접속 정보는 다른 서버 접속 정보로 사용하여 진행하였음