본문 바로가기
서버 및 보안

phpBB

by 다움위키 2023. 12. 25.

phpBBPHP 스크립팅 언어로 작성된 인터넷 포럼 패키지입니다. 이름 "phpBB"는 PHP Bulletin Board의 약어입니다. GNU 일반 공중 라이선스 아래에서 사용 가능한, phpBB는 자유와 오픈-소스입니다.

phpBB의 기능은 여러 데이터베이스 엔진 (PostgreSQL, SQLite, MySQL, Oracle Database, Microsoft SQL Server), 플랫 메시지 구조 (스레드와 반대), 계층적 하위-포럼, 주제 분할/병합/잠금, 사용자 그룹, 게시물당 여러 첨부 파일, 전체 텍스트 검색, 플러그인 및 다양한 알림 옵션 (이메일, Jabber 인스턴트 메시징, ATOM 피드)에 대한 지원을 포함합니다.

Database backup

먼저 이전 시스템의 내용을 백업해 둡니다.

  • cd
  • mysqldump -u root -p phpBB3 > phpBB3.sql
  • cd /var/www/html
  • sudo cp -a phpBB /home/$USER/phpBB.old

Installation

phpBB를 설치하기 전에, Nginx, MariaDBPHP을 설치하고 제대로 동작하는지 확인을 해야 합니다.

현재 우분투 18.04에서는 패키지를 제공하지 않기 때문에, 소스를 직접 받아서 설치합니다.

사실 웹 응용프로그램들은 대부분 패키지로 설치하는 것과 소스로 설치하는 것에 큰 차이가 없는 경우가 대부분입니다.
  • cd /var/www/html
  • sudo wget https://www.phpbb.com/files/release/phpBB-3.2.2.tar.bz2
  • sudo tar jxvf phpBB-3.2.2.tar.bz2
  • sudo chown -R root:root phpBB3
  • sudo mv phpBB3 phpBB
  • cd phpBB
  • sudo chmod 666 config.php
  • sudo chmod 775 store cache files images/avatars/upload
  • sudo chgrp www-data store cache files images/avatars/upload

Creating a database

자세한 구성은 MySQL Startup Guide을 참조하십시오.

  • mysql -u root -p
MariaDB [(none)]> create database if not exists <database name> default character set utf8 collate utf8_unicode_ci;
MariaDB [(none)]> create user '<username>'@'localhost' identified by '<password>';
MariaDB [(none)]> grant select, insert, update, delete, create, drop, index, alter on phpbb.* to 'phpbb'@'localhost' identified by '<password>';
MariaDB [(none)]> quit

Nginx settings

File:PhpBB.gz을 받아서 압축을 풀어서 첫 문자를 소문자로 바꿉니다. 해당 파일을 /etc/nginx/site-available/ 아래로 옮깁니다.

  • cd /etc/nginx/site-enabled
  • sudo ln -sf /etc/nginx/site-available/phpBB .

최근에는 약간의 변화가 있었습니다. /etc/nginx/site-available/phpBB에 씁니다.

server {
	listen 8000;
        #server_name phpBB;

        root /var/www/html/phpBB;

        location / {
            # phpBB uses index.htm
            index index.php index.html index.htm;
            try_files $uri $uri/ @rewriteapp;
        }

        location @rewriteapp {
            rewrite ^(.*)$ /app.php/$1 last;
        }

        # Deny access to internal phpbb files.
        location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb|store|vendor) {
            deny all;
            # deny was ignored before 0.8.40 for connections over IPv6.
            # Use internal directive to prohibit access on older versions.
            internal;
        }

        # Pass the php scripts to fastcgi server specified in upstream declaration.
        location ~ \.php(/|$) {
            # Unmodified fastcgi_params from nginx distribution.
            include fastcgi_params;
            # Necessary for php.
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            try_files $uri $uri/ /app.php$is_args$args;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
			#include hhvm.conf;
        }

        # Correctly pass scripts for installer
        location /install/ {
            # phpBB uses index.htm
            try_files $uri $uri/ @rewrite_installapp;

            # Pass the php scripts to fastcgi server specified in upstream declaration.
            location ~ \.php(/|$) {
                # Unmodified fastcgi_params from nginx distribution.
                include fastcgi_params;
                # Necessary for php.
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
                try_files $uri $uri/ /install/app.php$is_args$args;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
				#include hhvm.conf;
            }
        }

        location @rewrite_installapp {
            rewrite ^(.*)$ /install/app.php/$1 last;
        }

        # Deny access to version control system directories.
        location ~ /\.svn|/\.git {
            deny all;
            internal;
        }
}

포트의 변경 없이 이전에는 http://localhost/phpBB 로 접근이 가능하였지만, 지금은 80번을 rewrite로 다른 프로그램이 이용하고 있기 때문에 포트를 바꾸어서 http://localhost:8000/phpBB 로 접근할 수밖에 없는 상황입니다. 추가 정보가 필요합니다.

Completing the phpBB install

Nginx 설정을 바꾸었으므로, 서비스를 재시작합니다.

  • sudo systemctl restart nginx

웹으로 접근을 하셔서 설치를 계속합니다. 설정에 따라 서버이름이나 포트는 달라질 수 있습니다.

http://localhost:9000

업데이트

다음 버전이 출시되면 확인할 내용입니다.
  • sudo wget https://www.phpbb.com/files/release/phpBB-3.2.3.tar.bz2
  • sudo tar jxvf phpBB-3.2.3.tar.bz2
  • sudo chown -R root:root phpBB3
  • cd phpBB3
  • sudo rm -rf config.php images files store
  • sudo cp -a ../phpBB/config.php .
  • sudo cp -a ../phpBB/images .
  • sudo cp -a ../phpBB/files .
  • sudo cp -a ../phpBB/store .

이 과정은 옵션입니다. cache 디렉토리 권한, 사용자를 다음과 바꾸어 줍니다.

  • sudo chmod 775 cache
  • sudo chgrp www-data cache
  • sudo chmod 775 cache/production
  • sudo chgrp www-data cache/production

이제 디렉토리 이름을 서비스하기 위한 디렉토리(웹서버에서 정해둔) 이름으로 바꿉니다.

  • cd /var/www/html
  • sudo mv phpBB phpBB.old
  • sudo mv phpBB3 phpBB

데이터베이스 판올림을 지금 눌러서 테이블 구조 판올림을 합니다. 설치 마무리를 위해 install디렉토리를 삭제합니다.

  • cd phpBB
  • sudo mv install install.dist
  • sudo chmod 000 install.dist
브라우저를 눌러서 판올림을 하기 힘든 상황이라면 다음과 같이 해 줍니다.
  • sudo php ./bin/phpbbcli.php db:migrate --safe-mode
    • Database updater has completed!