42 Seoul

[Inception] WordPress

jaewpark 2022. 11. 3. 17:46

What is WordPress ?

웹에 있는 모든 웹사이트의 43.1% 이상을 만드는 데 사용된 무료 콘텐츠 관리 시스템(CMS)입니다

MySQL 데이터베이스 서비스와 PHP 프로그래밍 언어를 사용하여 사이트 방문자에게 블로그 및 페이지 콘텐츠를 제공합니다

CMS는 모든 페이지를 직접 코딩할 필요 없이 웹사이트를 만드는 데 사용되는 플랫폼

 

How to install ? (참고)

Step 1 : 다운로드 및 추출

apt update && apt install -y tar wget
wget : 웹 상의 파일을 다운로드 받을 때 사용하는 명령어로 비 상호작용 네트워크 다운로더
tar : 여러 개의 파일을 하나의 파일로 묶거나 풀 때 사용하는 명령어
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
압출 해제 : tar -xvzf [압축 해제할 압축 아카이브 이름]

▼ wp-config-sample.php

더보기
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

/**#@-*/

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

What is wp-config.php ? (참고)

WordPress 파일 디렉토리의 루트에 있으며 데이터베이스 연결 정보와 같은 웹사이트의 기본 구성 세부 정보를 포함합니다.

 

wp-config setting

# Set Database Name
define( 'DB_USER', 'MyUserName' );

# Set Database User
define( 'DB_USER', 'MyUserName' );

# Set Database Password
define( 'DB_PASSWORD', 'MyPassWord' );

# Set Database Host
define( 'DB_HOST', 'MyDatabaseHost' ); 

# Database character set
define( 'DB_CHARSET', 'utf8' );

# Database default collation
define( 'DB_COLLATE', '' );

# Change prefix
$table_prefix = 'r235_'; // Only numbers, letters, and underscores please!

# Security Keys
# 아래 링크 참조

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
온라인 보안키 생성 : 여기
wp-config 생성 : 참고

 

// setup.sh
#!bin/bash

rm -rf latest.tar.gz
mkdir /var/www/
mv -f /wordpress/ /var/www/
cp -rf ./tmp/wp-config.php /var/www/wordpress/
chown -R www-data:www-data /var/www/wordpress/

# Unable to create the PID file (/run/php/php7.3-fpm.pid) 계속 이런 에러 떠서 추가함
mkdir -p /run/php/

# php-fpm을 foreground에서 실행시키겠다. foreground에서 실행안하면 container가 계속 exited 으로 바뀜
exec php-fpm7.3 -F

chmod가 아닌 chown

chmod(change mode)는 파일의 읽기, 쓰기, 실행 등의 권한을 변경한다면

chown(change owner)는 파일의 소유 권한 계정을 변경한다.

chown [UserID:GroupID] [파일이나 디렉터리]
- R 옵션 : 하위 디렉토리 모두 적용