# mariadb 접속
mysql -u root -p
# 데이터베이스 생성
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
#데이터베이스 사용자 생성
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY '패스워드입력';
# 워드프레스 다운로드
wget <https://wordpress.org/latest.tar.gz>
# 압축 해제
tar -xvzf latest.tar.gz
# 워드프레스 파일 이동
mv wordpress /var/www/html/
# 소유권 및 권한 성정
chown -R nginx:nginx /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress
# 워드프레스 설정 파일 복사
cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php
# wp-config.php 수정
vi wp-config.php
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', '패스워드입력' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
:wq
# nginx config 수정
vi /etc/nginx/nginx.conf
http {
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*; #추가
}
# nginx 서버 블록 내용 추가
mkdir -p /etc/nginx/sites-available
mkdir -p /etc/nginx/sites-enabled
vi /etc/nginx/sites-available/wordpress
server {
listen 80;
server_name 서버IP;
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/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\\.ht {
deny all;
}
}
:wq
# 심볼릭 링크 생성
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
# nginx 설정 테스트
nginx -t
# nginx 재시작
systemctl restart nginx
# fastcgi-php.conf 생성
mkdir -p /etc/nginx/snippets
vi /etc/nginx/snippets/fastcgi-php.conf
fastcgi_split_path_info ^(.+\\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
include fastcgi_params;
:wq
# php-fpm 활성화 확인
systemctl status php-fpm
# 비활성화 되어 있다면 활성화
systemctl start php-fpm
웹 브라우저에서 http://서버 ip 입력