그누보드5와 React 같이 사용하기 1/2 정보
그누보드5와 React 같이 사용하기 1/2
본문
https://www.youtube.com/watch?v=jqqM607r10M
ubuntu 24.04 LTS 버전의 서버에서
그누보드5를 설치하고 npm 을 설치하여 react 를 같이 사용하는 방법에 대해 알아 봅니다.
sudo apt update
sudo apt install -y apache2 php php-gd php-mysql mysql-server
sudo a2enmod rewrite
mysql 접속후
    CREATE DATABASE mydb;
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
    GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';
    FLUSH PRIVILEGES;
    exit;
cd /var/www/html
git clone https://github.com/gnuboard/gnuboard5.git
cd gnuboard5
mkdir data
chmod 707 data
웹에서 그누보드5 실행
    MySQL 정보입력
    User : myuser
    Password : mypassword
    DB : mydb
sudo apt install -y npm
npx create-react-app react-app
cd react-app
vi package.json
    
    "homepage": "/gnuboard5/react-app",
npm run build
vi .htaccess 
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /gnuboard5/react-app/
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /gnuboard5/react-app/index.html [L]
</IfModule>
vi /etc/apache2/sites-enabled/000-default.conf
    Alias /gnuboard5/react-app /var/www/html/gnuboard5/react-app/build
    <Directory /var/www/html/gnuboard5/react-app>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
systemctl restart apache2
 
추가(240827) : .htaccess 는 없어도 되는 것으로 확인했습니다.
7
댓글 7개

nginx 의 경우 아래 설정을 적용해 보세요.
apt install nginx php-fpm
        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;
server_name _;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }
 
    # React 앱을 위한 위치 설정
    location /react-app {
        alias /var/www/html/gnuboard5/react-app/build;
    }

뭔가 건의를 하고 싶은데, 또 선동 당할까봐 건의 해보기가 무섭네요 ㅎㅎ

@미니님a 작업중에 말씀해 주시는게 좋습니다.
개발이 완료되면 변경이 어렵습니다.
https://github.com/gnuboard/gnuboard5/tree/feat/restapi

@리자
https://github.com/gnuboard/gnuboard5/issues/336
그누6에 있던 기능 개발 건의입니다
API 만 사용 + 예외적으로 관리자 페이지만 접근 가능...

@미니님a 아~ 이 내용은 개발완료 후 포함할 예정이었습니다.
감사합니다.

@리자 답변 감사합니다.

react 공부해보고 싶었는데..  많은 도움이 될꺼 같습니다. 
감사합니다.
