# mariadb 접속
mysql -u root -p
# 데이터베이스 생성
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
# 데이터베이스 사용자 생성
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY '패스워드입력';
# 데이터베이스 권한 넣기
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
# 즉시 적용
FLUSH PRIVILEGES;
# 워드프레스 다운로드
wget <https://ko.wordpress.org/latest-ko_KR.tar.gz>
# 압축 해제
tar xzvf latest-ko_KR.tar.gz
# 워드프레스 파일 이동
mv wordpress /var/www/html/
# 소유권 및 권한 성정
chown -R nginx:nginx /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress
# PHP-FPM 설정
vi /etc/php-fpm.d/www.conf
# apache에서 nginx로 수정
user = nginx
group = nginx
# 주석 제거후 nobody에서 nginx로 수정
listen.owner = nginx
listen.group = nginx
:wq
# 워드프레스 설정 파일 복사
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/*; #추가
}
:wq
# nginx 서버 블록 내용 추가
mkdir -p /etc/nginx/sites-available
mkdir -p /etc/nginx/sites-enabled
vi /etc/nginx/sites-available/wordpress
server {
listen 80;
server_name your_domain.com www.your_domain.com; # ip 입력
root /var/www/html/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \\.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\\.ht {
deny all;
}
}
:wq
# 심볼릭 링크 생성
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
# nginx 설정 테스트
nginx -t
# nginx 재시작
systemctl restart nginx ; systemctl restart php-fpm
웹 브라우저에서 http://서버 ip 입력