Debian 10에서 Nginx로 Pico CMS를 설치하는 방법

Debian 10에서 Nginx로 Pico CMS를 설치하는 방법

2022-10-18 last update

9 minutes reading nginx debian web server
Pico는 PHP로 작성된 간단하고 빠른 오픈 소스 플랫 파일 CMS입니다. 이는 처리할 관리 백엔드 및 데이터베이스가 없음을 의미합니다. 콘텐츠 폴더에 .md 파일을 만들기만 하면 페이지가 됩니다. Pico는 강력하고 유연한 테마를 위해 Twig 템플릿 엔진을 사용합니다. Pico 소스 코드는 Github에서 사용할 수 있습니다. 이 가이드에서는 Debian 10(buster) 시스템에 Nginx와 함께 Pico CMS를 설치합니다.

요구 사항


Pico를 실행하기 위한 요구사항은 다음과 같습니다.
  • Nginx
  • PHP 버전 5.3.6 이상
  • 작곡가
  • 전제 조건


  • Debian 10(버스터) 운영 체제.
  • sudo 권한이 있는 루트가 아닌 사용자.
  • 초기 단계


    Debian 버전을 확인하세요.

    lsb_release -ds
    # Debian GNU/Linux 10 (buster)

    Set up the timezone:

    sudo dpkg-reconfigure tzdata

    Update your operating system packages (software). This is an essential first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

    sudo apt update && sudo apt upgrade -y

    Install some essential packages that are necessary for basic administration of the Debian operating system:

    sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https

    1단계 - PHP 설치

    Install PHP, as well as the required PHP extensions:

    sudo apt install -y php7.3 php7.3-cli php7.3-fpm php7.3-common php7.3-curl php7.3-gd php7.3-json php7.3-zip php7.3-xml php7.3-mbstring

    To show PHP compiled in modules, you can run:

    php -m

    ctype
    curl
    exif
    fileinfo
    . . .
    . . .

    Check the PHP version:

    php --version

    # PHP 7.3.4-2 (cli) (built: Apr 13 2019 19:05:48) ( NTS )
    # Copyright (c) 1997-2018 The PHP Group
    # Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
    # with Zend OPcache v7.3.4-2, Copyright (c) 1999-2018, by Zend Technologies

    PHP-FPM service is automatically started and enabled on reboot on Debian 10 system, so there is no need to start and enable it manually. We can move on to the next step, which is the database installation and setup.

    2단계 - acme.sh 클라이언트 설치 및 Let's Encrypt 인증서 받기(선택사항)

    Securing your forum with HTTPS is not necessary, but it is a good practice to secure your site traffic. To obtain a TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a pure UNIX shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies. 

    Download and install acme.sh:

    sudo su - root
    git clone https://github.com/Neilpang/acme.sh.git
    cd acme.sh
    ./acme.sh --install --accountemail [email protected]
    source ~/.bashrc
    cd ~

    Check acme.sh version:

    acme.sh --version
    # v2.8.0

    Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

    # RSA 2048
    acme.sh --issue --standalone -d example.com --keylength 2048
    # ECDSA
    acme.sh --issue --standalone -d example.com --keylength ec-256

    If you want fake certificates for testing, you can add --staging flag to the above commands.

    After running the above commands, your certificates and keys will be in:

    • For RSA: /home/username/example.com directory.
    • For ECC/ECDSA: /home/username/example.com_ecc directory.

    To list your issued certs you can run:

    acme.sh --list

    Create a directory to store your certs. We will use /etc/letsencrypt directory.

    mkdir -p /etc/letsecnrypt/example.com
    sudo mkdir -p /etc/letsencrypt/example.com_ecc
    /etc/letsencrypt 디렉터리에 인증서를 설치/복사합니다.
    # RSA
    acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
    # ECC/ECDSA
    acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

    All the certificates will be automatically renewed every 60 days.

    After obtaining certs exit from root user and return back to regular sudo user:

    exit

    3단계 - NGINX 설치 및 구성

    Install NGINX:

    sudo apt install -y nginx

    Check the NGINX version:

    sudo nginx -v
    # nginx version: nginx/1.14.2

    Next, configure NGINX for Pico CMS. Run sudo vim /etc/nginx/sites-available/pico.conf and add the following configuration.

    server {
      
      listen 80;
      listen 443 ssl;
      server_name example.com;
      root /var/www/pico;
    ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com/private.key;
    ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
    index index.php; location ~ ^/((config|content|vendor|composer\.(json|lock|phar))(/|$)|(.+/)?\.(?!well-known(/|$))) { deny all; } location / { index index.php; try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri =404; fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_param PICO_URL_REWRITING 1; } }
    파일을 pico.conf 디렉터리에 연결하여 새sites-enabled 구성을 활성화합니다.
    sudo ln -s /etc/nginx/sites-available/pico.conf /etc/nginx/sites-enabled
    NGINX 구성에서 구문 오류를 확인하세요.
    sudo nginx -t
    NGINX 서비스 새로고침:
    sudo systemctl reload nginx.service

    4단계 - Composer 설치


    PHP 종속성 관리자인 Composer를 전역적으로 설치합니다.
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

    php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

    php composer-setup.php

    php -r "unlink('composer-setup.php');"

    sudo mv composer.phar /usr/local/bin/composer
    작곡가 버전 확인:
    composer --version
    # Composer version 1.8.6 2019-06-11 15:03:05
    참고: Composer 설치 명령은 향후 변경될 것이므로 위의 명령이 작동하지 않으면 최신 명령을 확인하십시오https://getcomposer.org/download/.

    5단계 - Pico CMS 설치


    Pico CMS용 문서 루트 디렉터리를 만듭니다.
    sudo mkdir -p /var/www/pico
    /var/www/pico 디렉터리의 소유권을 다음으로 변경합니다. [y our_username] :
    sudo chown -R [your_username]:[your_username] /var/www/pico
    위 명령어에서 [your_username]을 현재 로그인한 Linux 사용자의 사용자 이름으로 바꿉니다.
    그런 다음 문서 루트 디렉터리로 이동합니다.
    cd /var/www/pico
    작곡가와 함께 Pico 다운로드:
    composer create-project picocms/pico-composer .
    /var/www/pico 디렉토리의 소유권을 www-data:로 변경
    sudo chown -R www-data:www-data /var/www/pico
    Debian 10(buster) 시스템에 Pico CMS를 성공적으로 설치했습니다. 이제 Pico의 루트 디렉터리에 자신만의 콘텐츠 폴더를 만들고 콘텐츠 디렉터리에 .md 파일을 만들면 해당 파일이 페이지가 됩니다.

    연결


  • http://picocms.org/
  • https://github.com/picocms/Pico