본문 바로가기
42Seoul

Inception - WordPress, MariaDB

by millar 2024. 8. 24.

개요

이번 글에서는 Wordpress와 MariaDB를 직접 설치하여 과제의 요구사항에 맞춰 설정해 보겠습니다.


서비스 설치

 

먼저 MariaDB를 설치합니다.

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client -y

 

MySQL에 접속하여 데이터베이스를 생성합니다.

sudo mysql -u root
CREATE DATABASE wordpress;
CREATE USER 'user'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

 

WordPress를 다운로드합니다.

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
rm -rf latest.tar.gz
sudo mv wordpress /var/www/html

 

php-fpm을 설치합니다.

sudo apt-get install -y php php-fpm php-mysql

 

wordpress웹 파일을 생성합니다 : /etc/nginx/sites-available/wordpress

server {
    listen 443 ssl;
    server_name user.42.fr;

    ssl_certificate /home/user/user.42.fr.crt;
    ssl_certificate_key /home/user/user.42.fr.key;

    root /var/www/html/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # PHP-FPM 소켓 위치에 따라 수정
    }

    location ~ /\.ht {
        deny all;
    }
}

 

심볼릭 링크를 생성합니다. (기존의 sites-available과 sites-enabled에 존재하는 default는 삭제)

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

 

nginx를 재시작합니다.

sudo service nginx restart

 

지시사항에 따라 mariaDB와 Wordpress를 연결합니다.


/var/www/html/wordpress/wp-config.php을 생성하고 다음 내용을 복사합니다.

구성합니다.

로그인하면 대쉬보드로 이동합니다.

마치며

다음 포스팅에서는 Docker를 본격적으로 사용해 보겠습니다.

'42Seoul' 카테고리의 다른 글

Inception - Docker(mariaDB)  (0) 2024.08.27
Inception - Docker(Nginx)  (0) 2024.08.27
Inception - Nginx  (1) 2024.07.12
Inception - Introduction (가상머신 환경)  (0) 2024.02.21
Philosophers - Bonus  (1) 2023.12.17

댓글