Languages/PHP

WordPress 세팅하기 (with Nginx, Php8.2) on Ubuntu18

HC-Kang 2023. 5. 17. 09:22

서버 업데이트, 업그레이드

sudo apt update && sudo apt -y upgrade

 

nginx 설치

sudo apt install nginx
sudo systemctl status nginx

 

mysql 설치(5.7)

sudo apt install mysql-server
sudo mysql_secure_installation

 

mysql DB, 계정, 패스워드 설정

CREATE DATABASE wordpress_db;
set global validate_password_policy=LOW;
GRANT ALL ON wordpress_db.* TO '{USER_NAME}'@'localhost' IDENTIFIED BY '{PASSWORD}' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

 

php8.2 설치

sudo apt install -y lsb-release gnupg2 ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2

php --version
sudo apt-get install -y php8.2-cli php8.2-fpm php8.2-mysql php8.2-opcache php8.2-mbstring php8.2-xml php8.2-gd php8.2-curl

 

nginx conf 준비

  • wordpress.conf 파일
server {
            listen 80;
            root /var/www/html;
            index index.php index.html;
            #server_name {YOUR_DOMAIN.DOMAIN | YOUR_IP_ADDRESS};

            #access_log /var/log/nginx/wordpress.access.log;
            #error_log /var/log/nginx/wordpress.error.log;

            location / {
                         try_files $uri $uri/ =404;
            }

            location ~ \.php$ {
                         include snippets/fastcgi-php.conf;
                         fastcgi_pass unix:/run/php/php8.2-fpm.sock;
            }

            location ~ /\.ht {
                         deny all;
            }

            location = /favicon.ico {
                         log_not_found off;
                         access_log off;
            }

            location = /robots.txt {
                         allow all;
                         log_not_found off;
                         access_log off;
           }

            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                         expires max;
                         log_not_found off;
           }
}

 

cd /etc/nginx/sites-available
sudo vi ./wordpress.conf

sudo nginx -t
cd ../sites-enabled/
sudo ln -s ../sites-available/wordpress.conf .
sudo systemctl reload nginx
sudo systemctl status nginx

 

Wordpress 설치

cd /var/www/html
sudo wget <https://wordpress.org/latest.tar.gz>
sudo tar -zxvf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf ./wordpress/

sudo cp ./wp-config-sample.php ./wp-config.php

sudo chown -R www-data:www-data *
sudo chmod -R 755 *

 

config 설정

sudo vi wp-config.php

# ...
# ...
# define('DB_NAME', 'wordpress_db');
# define('DB_USER', 'wpuser');
# define('DB_PASSWORD', 'Passw0rd!');
# ...
# ...

 

Reference


install php8.2

https://computingforgeeks.com/how-to-install-php-8-2-on-ubuntu/