HomeAbout Me

Ubuntu 20.04 LTS에 PHP 7.4 설치 및 라이믹스 설치하기

By Woosung
Published in Ubuntu
November 01, 2020
2 min read
Ubuntu 20.04 LTS에 PHP 7.4 설치 및 라이믹스 설치하기

라이믹스(rhymix)는 오픈소스 국산 설치형 CMS입니다.

XpressEngine기반으로 포크되어 활발하게 개발되고 있습니다.

PHP 8.0을 공식적으로 지원하는 2.0버전도 조만간 나온다고 합니다.

공식 홈페이지 : https://rhymix.org/

커뮤니티 : https://xetown.com/

Github : https://github.com/rhymix/rhymix


무료 홈페이지 주소 받기

https://blog.wsgvet.com/free-homepage-address-freenom

클라우드 플레어 가입 및 네임서버 변경하기

https://blog.wsgvet.com/cloudflare-sign-in-and-change-nameserver

구글 클라우드 플랫폼 가입, 도메인 연결, Nginx 설치

https://blog.wsgvet.com/sign-in-google-cloud-platform-and-connect-domain-and-hello-world

구글 클라우드 컴퓨트 엔진에서 우분투 기본 설정하기

https://blog.wsgvet.com/google-cloud-compute-engine-ubuntu-basic-setting

우분투 20.04 LTS에 MariaDB 설치하기

https://blog.wsgvet.com/ubuntu-2004-install-mariadb/

위 5개 글에 따라 따라오셨다면 이제 이 글을 보시면 됩니다.


1. php7.4 설치

sudo apt install php7.4 php7.4-fpm php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-mbstring php7.4-xml php7.4-gd php7.4-curl

위 명령어로 패키지를 설치합니다.

조금만 기다리면 설치가 완료됩니다.

sudo systemctl enable php7.4-fpm

위 명령어로 재부팅시에 자동 시작되게 합니다.

sudo systemctl start php7.4-fpm

위 명령어로 실행합니다.


sudo nano /etc/php/7.4/fpm/php.ini

위 명령어로 들어가면 엄청나게 많은 글의 내용이 나오는데요.

short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
post_max_size = 101M
max_execution_time = 360
date.timezone = Asia/Seoul

위 항목을 찾아서 다 바꿔줍니다.

찾는 방법은 컨트롤 + W 누르면 밑에 검색창이 나오는데, 앞부분을 복사해서 붙여넣고 엔터를 치면 찾아집니다.

예를들어 short_open_tag를 바꾸고 싶다면 short_open_tag 를 넣고 엔터를 치면 해당부분으로 갑니다.

참고로 short_open_tag는 처음 검색하면 설명 부분이 나오는데 한번더 검색하면 제대로 나옵니다.

cgi.fix_pathinfo는 아마도 ;cgi.fix_pathinfo = 1 이렇게 되어있을텐데요. 앞에 ; 은 주석으로 처리한다는 뜻이므로 이것도 빼야겠죠.

;cgi.fix_pathinfo = 1cgi.fix_pathinfo = 0  이렇게 바꿔줘야 하는 것입니다.

그 뒤에 수정하면 됩니다.

참고로 upload_max_filesizepost_max_size는 파일 업로드 용량과 매우 높은 관계가 있습니다.

업로드할 파일 크기가 크다면 100M 이상으로 해주셔도 됩니다.

그리고 밑에 Nginx 설정에서도 하나 더 변경해줘야 됩니다. 따로 설명드리겠습니다.

전부 찾아서 다 바꾼 후

컨트롤 + O, 엔터, 컨트롤 + X를 누르면 저장 후 빠져나와집니다.

sudo systemctl reload php7.4-fpm

위 명령어로 설정을 적용해줍니다.


2. MariaDB에 라이믹스 전용 DB 및 유저 생성하기

sudo mysql -u root -p

위 명령어로 DB에 접속합니다.

CREATE DATABASE rhymix;

위 명령어로 rhymix라는 DB를 만듭니다.

CREATE USER 'rhymixuser'@'localhost' IDENTIFIED BY 'yourpassword';

위 명령어로 rhymixuser라는 DB사용자를 만듭니다.

yourpassword 부분은 원하는 비번으로 수정하세요!

GRANT ALL ON rhymix.* TO 'rhymixuser'@'localhost' WITH GRANT OPTION;

위 명령어로 rhymixuserrhymix라는 DB의 모든 권한을 얻습니다.

FLUSH PRIVILEGES;
EXIT;

위 두 명령어로 저장 후 나갑니다.

3. 라이믹스 설치파일 다운받기

mkdir -p /var/www/rhymix

위 명령어로 라이믹스 파일이 들어갈 폴더를 생성합니다.

cd /var/www/rhymix

위 명령어로 폴더로 이동합니다.

curl -o rhymix.tar.gz -fSL https://github.com/rhymix/rhymix/tarball/master

위 명령어로 라이믹스 최신버전을 다운 받습니다.

tar -xf rhymix.tar.gz -C . --strip-components=1

위와 같이 현재 폴더에 압축을 풉니다.

rm rhymix.tar.gz

위 명령어로 압축파일을 삭제합니다.


이제 권한을 수정해야 합니다.

sudo chmod -R 755 /var/www/rhymix

라이믹스의 폴더 포함 모든 파일 및 폴더의 권한을 755로 줍니다.

sudo mkdir /var/www/rhymix/files

files 폴더를 생성합니다.

sudo chmod 707 /var/www/rhymix/files

files 폴더의 권한을 707로 줍니다.

sudo chown -R www-data:www-data /var/www/rhymix

라이믹스 폴더 이하의 모든 파일과 폴더의 소유권을 www-data에게 줍니다.

sudo curl -sSLo /etc/nginx/snippets/rhymix-rewrite.conf https://raw.githubusercontent.com/rhymix/rhymix/master/common/manual/server_config/rhymix-nginx.conf

위 명령어로 라이믹스의 짧은 주소 대응 파일을 다운 받습니다.

라이믹스 파일 설정은 이제 끝입니다.


4. Nginx 설정파일 만들기

Nginx 서버 설정하기

먼저 Nginx 설정파일부터 만듭니다.

sudo nano /etc/nginx/sites-available/rhymix

위 명령어로 Nginx설정파일을 만들고 들어갑니다.

server {
listen 80;
listen [::]:80;
server_name www.example.com example.com; # example.com를 자신이 원하는 도메인으로 수정하세요.
root /var/www/rhymix;
index index.php ;
include snippets/rhymix-rewrite.conf;
location ~ \.(gif|jpg|png)$ {
add_header Vary "Accept-Encoding";
add_header Cache-Control "public, no-transform, max-age=31536000";
}
location ~* \.(css|js)$ {
add_header Cache-Control "public, max-age=604800";
log_not_found off;
access_log off;
}
location ~*.(mp4|ogg|ogv|svg|svgz|eot|otf|woff|woff2|ttf|rss|atom|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|cur)$ {
add_header Cache-Control "max-age=31536000";
access_log off;
}
charset utf-8;
server_tokens off;
client_max_body_size 100M;
location / {
try_files $uri $uri/ =404;
}
location ~ /\.ht {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

위 내용에서 example.com 부분을 자신의 도메인으로 바꿔주세요.

참고로 업로드 용량을 100MB 이상을 원하신다면 client_max_body_size 100M;client_max_body_size 1000M;와 같이 뒤에 숫자를 변경해주면 됩니다.

그리고 컨트롤 + O, 엔터, 컨트롤 + X 엔터를 누르면 저장 후 빠져나옵니다.


sudo ln -s /etc/nginx/sites-available/rhymix /etc/nginx/sites-enabled/

위 명령어로 설정파일을 활성화되게 해줍니다.

sudo rm -f /etc/nginx/sites-enabled/default

위 명령어로 기존 활성화된 default 서버 링크만 삭제해줍니다.

sudo nginx -t

위 명령어로 설정에 이상이 없는지 확인합니다.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

위와 같이 oksuccessful이 나오면 성공입니다.

sudo service nginx restart

위 명령어로 nginx를 재시작 해줍니다.

이제 python3-certbot-nginx를 통한 SSL 인증서 발급을 위한 준비는 끝났습니다.


SSL 인증서 설치프로그램 certbot 설치하기

sudo apt install python3-certbot-nginx

위 명령어로 Nginx와 연결할 수 있는 certbot을 설치합니다.


SSL 인증서 발급받기

sudo certbot --nginx -d example.com -d www.example.com

이제 위와 같은 형식으로 자신의 도메인과 www.도메인에 SSL 인증서 생성을 시작합니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel):

위와 같이 인증서 갱신 및 보안 공지 등을 받을 이메일 주소를 입력합니다.

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel:

A를 입력하고 엔터를 누릅니다.

Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:

이메일 주소를 공유하고 싶다면 y, 그렇지 않다면 n을 입력하고 엔터를 누릅니다.

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/rhymix
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/rhymix
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

위와 같이 인증서가 발급됩니다. HTTP를 전부 HTTPS로 리다이렉트 하는 것이 좋습니다. 2를 입력하고 엔터를 누르면 됩니다.

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/rhymix
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/rhymix
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://example.com and https://www.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2021-01-29. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

위와 같이 매우 쉽게 발급이 되었고, Nginx도 재기동되어 이제 주소창에 자신의 주소를 입력하면 바로 https로 접속되는 것을 확인할 수 있습니다.

정말 쉽죠?


SSL 인증서 갱신 확인방법

sudo systemctl status certbot.timer

위 명령어를 내리면

● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Sat 2020-10-31 14:07:53 UTC; 14min ago
Trigger: Sun 2020-11-01 01:50:41 UTC; 11h left
Triggers: ● certbot.service

위와 같이 나오는 것을 확인할 수 있습니다. 즉 하루에 2번씩 자동으로 갱신 체크를 해줍니다.


SSL 인증서 갱신 테스트하기

sudo certbot renew --dry-run

위 명령어를 내리면

Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/example.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator nginx, Installer nginx
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Waiting for verification...
Cleaning up challenges
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of nginx server; fullchain is
/etc/letsencrypt/live/example.com/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/example.com/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.

위와 같이 Congratulations, all renewals succeeded. 내용이 뜨면 갱신에 문제가 없다는 뜻입니다.


5. gif 움짤 변환을 위한 ffmpeg 설치하기

라이믹스 코어에 gif 움짤 변환하는 기능이 내장되어 있습니다.

우분투에서는 간단하게 ffmpeg만 설치하면 변환이 가능합니다. 웹호스팅에서는 불가능한 부분이죠 ^^

sudo apt install ffmpeg

위와 같이 설치만 해주면 됩니다.

정말 쉽죠? ^^

다만 구글 클라우드 무료 티어에서는 CPU의 성능이 낮아 변환 시간이 오래걸릴 수 있습니다.

이 부분은 성능이 높은 유료 서비스를 이용하면 해결됩니다.


6. 라이믹스 접속 및 초기 설정하기

이제 주소창에 설정한 주소 를 넣어보세요.

01 rhymix setup

위와 같이 뜬다면 성공입니다.

동의에 체크 후 다음을 누릅니다.

02 rhymix php

설치환경을 확인 후 다음을 누릅니다.

03 rhymix db

DB 종류, DB 서버 주소, DB 서버 포트는 그대로 두면 됩니다.

DB 아이디rhymixuser를 넣으면 됩니다.

DB 비밀번호yourpassword 대신에 넣었던 비밀번호를 넣으면 됩니다.

DB 이름rhymix를 넣으면 됩니다.

그리고 다음을 누릅니다.

04 rhymix admin

관리자 계정 생성 화면입니다.

원하는 대로 입력하면 됩니다. SSL 사용항상 사용으로 체크해주시고요.

다음을 누릅니다.

05 rhymix welcome

위와 같이 나오면 드디어 끝입니다.

감사합니다!


Tags

Google CloudphprhymixSSL

Share

Previous Article
Gatsby Flexiblog 테마 업데이트 하는 방법

Woosung

Woosung

반가워요!

우성군의 NAS를 운영하고 있는 우성짱입니다. 2013년부터 그누보드4 운영을 시작으로, 이제 정적사이트까지 만들게 되었습니다. 이런 신세계를 눈 앞에 볼 수 있다는 것이 정말 신기하고 재밌습니다.

Expertise

그누보드
Nginx
Server

Social Media

github홈페이지

Related Posts

우분투 20.04에 워드프레스 설치하기
Ubuntu
우분투 20.04에 워드프레스 설치하기
June 05, 2020
2 min
© 2026, All Rights Reserved.
Powered By
Vector created by pikisuperstar

Topics

GatsbyUbuntughostGnuboardGoogle Cloud

Social Media