Ubuntu에 워드프레스 셋업하기

  1. install wordpress to server
  2. create database and user for website
  3. configure site root directories
  4. website configuration (config.php)
  5. enabling .htaccess overrides (virtual host)
  6. installing free ssl (let's encrypt)
  7. filezilla connection

 

1) [ download wordpress ]

wget https://wordpress.org/latest.zip

unzip latest.zip

 

2 ) [ create site databases and users ]

SQL Install

sudo apt update

sudo apt-get install mysql-server

Y

mysql --version (mysql 버젼체크)

mysql -u root -p

 

xxxxxxxx

ERROR 1698 (28000): Access denied for user 'root'@'localhost' 에러메세지 나오면

sudo mysql -u root -p

show databases:

use mysql

update user set plugin='mysql_native_password' where user='root';

 

FLUSH PRIVILEGES;

exit

xxxxxxxxx

비밀번호 넣기

provide your password which we set in previous session.

CREATE DATABASE database_name1;

SHOW DATABASES;

now you can check your created database is available or not in the list.

now create user for the database

CREATE USER 'Database_user1'@'localhost' IDENTIFIED BY 'db_password1';

GRANT ALL PRIVILEGES ON Database_name1.* TO 'Database_user1'@'localhost';

FLUSH PRIVILIEGES;

exit

 

3) [ Configuring Site Root Directories ]

we want to host multiple websites from single instance and ip address so we will not

which is var/www/html we will create a new directory for the particular website

sudo mkdir /var/www/public_html (안되면 파일질라에서 폴더 만들기)

sudo mkdir /var/www/public_html/your_domain1(도메인주소:abc.com)

sudo chown -R www-data:www-data /var/www/public_html/your_domain1

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

sudo rsync -avP ~/wordpress/ /var/www/public_html/your_domain1/

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

sudo usermod -a -G www-data root

sudo find /var/www/public_html/your_domain1/ -type d -exec chmod 750 {} \;

sudo find /var/www/public_html/your_domain1/ -type f -exec chmod 640 {} \;

 

4) [ Site Configuration ]

cd /var/www/public_html/your_domain1

sudo nano wp-config.php

파일질라에서 wp-config.php 내용 변경하기

now you need to change the values your database name your database user name and password. 섹션2에서 셋업한 부분(녹색)

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */

define( /DB_NAME', 'DB_name' );          <<<<<<< make changes accordingly

/** MySQL database username */

define( 'DB_USER', 'DB_username' );          <<<<<<< make changes accordingly

/** MySQL database password */

define( 'DB_PASSWORD', 'password' );          <<<<<<< make changes accordingly

/** MySQL hostname */

define( 'DB_HOST', 'localhost' );

define('FS_METHOD', 'direct');

 

시크릿키 만들기

api.wordpress.org/secret-key/1.1/salt/

아니면

curl -s https://api.wordpress.org/secret-key/1.1/salt/

 

everytime when you will use this it will generate a new code use that to update your

 

Save and exit -ctrl f ,y , enter

 

5)

Enabling .htaccess Overrides

sudo nano /etc/apache2/sites-available/your_domain1.conf

그리고 아래 코드 입력하기

<VirtualHost *:80>

ServerName your_domain1

ServerAlias www.your_domain1

ServerAdmin webmaster@localhost

DocumentRoot /var/www/public_html/your_domain1

<Directory /var/www/public_html/your_domain1/>

AllowOverride All

</Directory>

</VirtualHost>

 

control X 그리고 Yes 한번 No 한번 하면 나옴

change allow override none to allow override all

 

Enabling the Rewrite Module

sudo a2enmod rewrite

sudo apache2ctl configtest

sudo systemctl restart apache2

sudo a2ensite your_domain1

sudo service apache2 reload

 

6) [ Install Let's Encrypt SSL ]

sudo apt install certbot python3-certbot-apache

Y

>>>>>> 그리고, DNS Records에서 Type A, Name @, Value는 IP주소

 

check virtual host configuration

sudo nano /etc/apache2/sites-available/your_domain.conf

...

 

Obtaining a SSL Certificate

sudo certbot --apache

이메일 주소 넣기

A

N

그냥 엔터

2

이제 도메인 주소가면 워드프레스 화면 보임

 

7)

Now we will install phpmyadmin for the perticuler ip address.

installing PHP MY ADMIN

  1. sudo apt install phpmyadmin -y
  2. apache2를 선택
  3. No 선택
  4. sudo nano /etc/apache2/apache2.conf

[at the end add this line]

include /etc/phpmyadmin/apache.conf

Save modified buffer? Yes

(consider to select apache2 in the server selection and dont go with the default

add this text and save and exit

 

도메인주소 뒤에 /phpmyadmin 검색하면 로그인 가능

 

Changing the default phpmyadmin page to custom name

sudo nano /etc/phpmyadmin/apache.conf

[and change the third line as follows]

Alias / yournewalias /usr/share/phpmyadmin

 

now save and exit

 

sudo service apache2 restart

now search http://your_ip/yournewalias

you can see your new phpmyadmin console with all your database details.