PHP세팅, 간단한 게시판, MariaDB 연동

PHP세팅, 간단한 게시판, MariaDB 연동

MariaDB에 site1, site2 계정 생성 mysql -u root -p

CREATE DATABASE site1; GRANT ALL PRIVILEGES ON site1.* TO site1@`%` IDENTIFIED BY 'sbs123414'; CREATE DATABASE site2; GRANT ALL PRIVILEGES ON site2.* TO site2@`%` IDENTIFIED BY 'sbs123414';

site1, site2에도 php가 작동하도록 설정 sudo vim /etc/nginx/conf.d/vhost.conf

server { listen 8011; server_name _; set $documentRoot /web/site1/public; include /etc/nginx/conf.d/php_vhost.conf.include; } server { listen 8012; server_name _; set $documentRoot /web/site2/public; include /etc/nginx/conf.d/php_vhost.conf.include; }

Site1 DB에 airticle 테이블 만들고 게시물 3개 삽입

CREATE TABLE article (

id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,

reg_date DATETIME NOT NULL,

update_date DATETIME NOT NULL,

title VARCHAR(100) NOT NULL,

`body` TEXT NOT NULL

);

INSERT INTO article

SET reg_date = NOW(),

update_date = NOW(),

title = '제목1',

`body` = '내용1';

INSERT INTO article

SET reg_date = NOW(),

update_date = NOW(),

title = '제목2',

`body` = '내용2';

INSERT INTO article

SET reg_date = NOW(),

update_date = NOW(),

title = '제목3',

`body` = '내용3';

article.list.php로 site1.article 테이블의 모든 게시물들은 HTML로 리스팅

vim /web/site1/public article_list.php

//

from http://koreabio.tistory.com/35 by ccl(A) rewrite - 2021-12-26 13:00:44