becool

20210622 (화) webservice 본문

linux

20210622 (화) webservice

gusalstm 2021. 6. 22. 14:49
반응형

wordpress

P339 

정적인 웹서비스가 아닌 동적인 웹서비스

WordPress 는 PHP + MariaDB 등이 필요

 

[root@host1 ~]# yum install -y php php-mbstring php-pear

[root@host1 ~]# yum install mariadb-server -y

[root@host1 ~]# systemctl start mariadb.service

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec);
MariaDB [(none)]> grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by '1234';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

CREATE TABLE / CREATE USER / GRANT
yum install wordpress → 전체 세팅 후 설치

 

[root@host1 ~]# yum install epel-release -y

[root@host1 ~]# yum install -y wordpress

[root@host1 ~]# vim /etc/wordpress/wp-config.php

 

 21 // ** MySQL settings - You can get this info from your web host ** //
 22 /** The name of the database for WordPress */
 23 define( 'DB_NAME', 'database_name_here' );   → 'wordpress'
 24 
 25 /** MySQL database username */
 26 define( 'DB_USER', 'username_here' ); → 'wordpress'
 27 
 28 /** MySQL database password */
 29 define( 'DB_PASSWORD', 'password_here' );  → '1234'
 30 
 31 /** MySQL hostname */
 32 define( 'DB_HOST', 'localhost' ); → 'localhost'
 33 
 34 /** Database Charset to use in creating database tables. */
 35 define( 'DB_CHARSET', 'utf8' );  → 'utf8'

 36 
 37 /** The Database Collate type. Don't change this if in doubt. */
 38 define( 'DB_COLLATE', '' );

 

:wq

[root@host1 ~]# vim /etc/httpd/conf.d/wordpress.conf 

Alias /wordpress /usr/share/wordpress

→ 클라이언트에서 주소+/wordpress 입력 시, /usr/share/wordpress 의 컨텐츠를 보여주게 됨

 

<Directory /usr/share/wordpress>
  AllowOverride Options     → 추가구성요소를 Options로 아래에 적어줌
  <IfModule mod_authz_core.c>
    # Apache 2.4
    Require local               → all granted
  </IfModule>
  <IfModule !mod_authz_core.c>
    # Apache 2.2
    Order Deny,Allow
    Deny from All
    Allow from 127.0.0.1
    Allow from ::1
 </IfModule>
</Directory>

[root@host1 ~]# systemctl start httpd

10.0.2.11 접속

wordpress 테스트 : http://10.0.2.11/wordpress/

 

아이디 비번 세팅 후 인스톨완료하면 아래와 같이 wordpress 데이터베이스에 테이블들이 생성됨.

 

MariaDB [(none)]> use wordpress;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [wordpress]> show tables;
+-----------------------+
| Tables_in_wordpress   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.00 sec)

 

*실습

 

wordpress / DB 서버를 따로 구성
  ※ 따로 구성할 때는 사용자 설정 / WP 에 설정파일 설정 필요
  ※ setenforce 0 (web서버)

가상머신 A B C
 A : dns서버 (firefox 접속 테스트용)
   ip 10.0.2.10 hostname : dns.school.exam.com
 B : wordpress
   ip 10.0.2.30 hostname : web.school.exam.com
 C : DB
   ip 10.0.2.40 hostname : db.school.exam.com
접속할때는 http:// web.school.exam.com/wordpress

 

dns setting

<zone 설정>

$TTL 3H
@       IN SOA  school.exam.com. root.localhost. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum


                NS      dns.school.exam.com.
                NS      web.school.exam.com.
                NS      db.school.exam.com.

dns     IN      A       10.0.2.10
web     IN      A       10.0.2.30
db      IN      A       10.0.2.40
----------------------------------------------------------
web server setting

 

[root@web ~]# vim yum install -y httpd php php-pear php-mbstring wordpress

 안될시 epel-realese 설치 후 wordpress설치

[root@web ~]# vim /etc/httpd/conf.d/wordpress.conf 

<Directory /usr/share/wordpress>
 AllowOverride Options
 Require all granted
  <IfModule mod_authz_core.c>
    # Apache 2.4
    Require local
  </IfModule>
  <IfModule !mod_authz_core.c>
    # Apache 2.2
    Order Deny,Allow
    Deny from All
    Allow from 127.0.0.1
    Allow from ::1
 </IfModule>
</Directory>

 

 

----------------------------------------------------------

db server setting

 

[root@db ~]# mysql -u root -p

MariaDB [(none)]> create database wp;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use wp;
Database changed
MariaDB [wp]> show tables;
Empty set (0.00 sec)

MariaDB [wp]> CREATE USER 'wp-user'@'web.school.exam.com' → web도메인주소 or IP주소
    -> IDENTIFIED BY '1234';

MariaDB [wp]> use mysql    → mysql 데이터베이스안에는 user table이 있다. 아래 내용 참고

MariaDB [mysql]> select user,host, password from user;
+---------+----------------------+-------------------------------------------+
| user    | host                 | password                                  |
+---------+----------------------+-------------------------------------------+
| root    | localhost            | *A4B6157319038724E3560894F7F932C8886EBFCF |
| root    | 127.0.0.1            | *A4B6157319038724E3560894F7F932C8886EBFCF |
| root    | ::1                  | *A4B6157319038724E3560894F7F932C8886EBFCF |
| slave   | %                    | *DAE180E15782177EEC0753479C7060AC1198C2F5 |
wp-user | web.school.exam.com | *A4B6157319038724E3560894F7F932C8886EBFCF |
+---------+----------------------+-------------------------------------------+
5 rows in set (0.00 sec)

MariaDB [mysql]> GRANT ALL privileges ON wp.* TO 'wp-user'@'web.school.exam.com';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> FLUSH privileges;
Query OK, 0 rows affected (0.00 sec)

 

----------------------------------------------------------

web server setting 2

 

[root@web ~]# vim /etc/wordpress/wp-config.php 

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

/** MySQL database username */
define( 'DB_USER', 'wp-user' );

/** MySQL database password */
define( 'DB_PASSWORD', '1234' );

/** MySQL hostname */
define( 'DB_HOST', 'db.school.exam.com' ); → 웹서버가 어느 DB서버를 쓸건지에 대한 주소입력

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

 

[root@web ~]# firewall-cmd --add-service=mysql
success
[root@web ~]# firewall-cmd --add-service=mysql --permanent
success

[root@web ~]# firewall-cmd --add-service=http
success
[root@web ~]# firewall-cmd --add-service=http --permanent
success

[root@web ~]# setenforce 0   → selinux 를 끄거나

[root@web ~]# semanage boolean -l |grep db  → 부울값을 on으로 변경 해야한다.

httpd_can_network_connect_db   (off  ,  off)  Allow httpd to can network connect db

[root@web ~]# setsebool -P httpd_can_network_connect_db on

 

 

 

728x90

'linux' 카테고리의 다른 글

20210624 (목) DHCP  (0) 2021.06.24
20210622 (화) Nginx  (0) 2021.06.22
20210616 (수) dns, web서비스  (0) 2021.06.16
20210507(금)  (0) 2021.05.07
20210506 (목)  (0) 2021.05.06
Comments