데이터베이스 설치 / 설정

mysql을 설치하려고 했지만 mariadb를 한 번도 안 써봐서 후자를 택했다. 명령어는 똑같음!

설치 방법은 다음과 같다.

더보기

// 데이터베이스 설치

vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
// repo 추가

yum install MariaDB-client MariaDB-server
systemctl enable mariadb // 부팅시 자동 서비스 자동시작

——————————————————

// 한글 문제 설정

vi /etc/my.cnf

[mysqld]
init_connect=”SET collation_connection = utf8_general_ci” 
init_connect=”SET NAMES utf8″ 
character-set-server = utf8
collation-server = utf8_general_ci

[client]
default-character-set = utf8

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8    

….저장

 systemctl start mariadb // mariadb 시작

——————————————————

//MariaDB 계정 설정 

mysql -u root // db접속
>use mysql;
>update user set password=password(‘패스워드’) where user=’root’;
>flush privileges;
>exit

mysql -u root -p //설정한 비밀번호로 접속!

'공부 > Linux' 카테고리의 다른 글

(CentOS 7) SSH 보안설정  (0) 2020.02.19
(CentOS 7) openssh 업데이트  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #4  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #2  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #1  (0) 2020.02.19

1. PHP 설치 / 연동

워드프레스는 PHP 기반으로 만들어졌다. 워드프레스에서 php7.3 이상의 버전을 사용 권고하고 있어서 7.3 이상의 버전을 설치해야 하는 게 좋지만 숫자를 착각하는 바람에 7.2를 설치했다. 내용은 72인데 73 이상으로 바꾸고 진행하면 된다.

YUM을 이용해서 설치를 해볼 것인데 그냥 설치하면 구버전으로 설치가 된다. 그래서 REMI Repository를 추가해 설치한다.

remi를 사용하려면 epel부터 설치해줘야 한다. 다음 명령어들을 사용하면 된다.

yum install -y epel-release
 
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm
 
yum install -y yum-utils
yum-config-manager --enable remi-php72 // 73이상으로
 
yum install -y php

wget 명령어가 작동이 안 된다면 yum install wget으로 설치해보자.

php -v 명령어로 버전 정보를 확인하고 테스트로 phpinfo를 만들어보았다.

vi /usr/share/nginx/html/phpinfo.php
 
<?php phpinfo(); ?>
:wq

다음과 같이 php파일을 만든 후 http://주소/phpinfo.php로 들어가면 원래대로라면 php 버전 정보들이 떠야 한다. 그래서 뭔가 하고 검색해봤더니 Nginx와 PHP를 연동해야 한다고 한다.

 

yum install -y php-fpm

 

php-fpm은 웹서버와 php를 연결해주는 역할을 한다. 관련 설정은 사이트를 참고했다.

https://ignorabilis.tistory.com/10

'공부 > Linux' 카테고리의 다른 글

(CentOS 7) SSH 보안설정  (0) 2020.02.19
(CentOS 7) openssh 업데이트  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #4  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #3  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #1  (0) 2020.02.19

Vmware 가상 환경에 CentOS를 설치해 Nginx + PHP + MariaDB 조합으로 워드프레스 웹 서버를 구축할 예정이다. Nginx와 MariaDB는 처음 사용해보는 건데 아파치와 mysql과 비슷할 것 같다.

 

1. VMWARE , OS 셋팅

현재 세팅은 CentOS 7.7 버전이고 서버 용도라 그래픽 환경이 아닌 콘솔 환경이다. 파티션은 스왑 메모리 설정만 해주고 나머지 용량은 루트 디렉터리에 설정해주었다. 네트워크는 NAT로 자동으로 설정해주었고 아무런 보안조치가 안되어 있는 상태이다.

2. Nginx 설치

vi /etc/yum.repos.d/nginx.repo
 
 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
 
...
 
yum install -y nginx
#테스트를 위해 Nginx 시작
systemctl start nginx
 
#시스템 시작시 Nginx가 실행되도록 하려면
systemctl enable nginx

서비스를 시작하고 사이트 접속을 했더니 접속이 되지 않는 현상이 생겼다.  그 이유는 당연하지만 OS를 설치하고 방화벽이고 뭐고 아무것도 안 했기 때문이다.

3. 방화벽 설정

[root@localhost ~]# getenforce // selinux 활성화 여부
Enforcing
[root@localhost ~]# setenforce 0 // 0 - 비활성화 설정
[root@localhost ~]# getenforce
Permissive
 
//위 방법은 재부팅하면 초기화
//영구적용하려면 아래 방법 사용후 재부팅
 
[root@localhost ~]# vi /etc/selinux/config
 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled // 기본설정은 enforcing
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

SELinux는 Security Enhanced Linux의 약자로 영어 단어만 봐도 보안 관련된 설정이라는 것을 유추할 수 있다. 보안상 켜 두는 것이 좋겠지만 서비스들이 제한되거나 충돌하는 경우도 있어서 해제하고 좀 더 리눅스에 대해 익숙해지면 알아보는 걸로…

CentOS/RHEL7 에서는 기존에 쓰던 iptables에서 firewalld로 변경되었다. 그렇다고 해서 iptables가 없어진 게 아니고 iptables를 기반으로 해서 동작하고 있다.

http포트를 허용하는 firewalld 명령어는 다음과 같다.

[root@localhost ~]# firewall-cmd --add-service=http --permanent
success
[root@localhost ~]# firewall-cmd --add-service=https --permanent
success
[root@localhost ~]# firewall-cmd --reload
success

테스트 겸 재부팅 후 사이트 접속하면 ‘Welcome to nginx!’ 라는 문구가 반겨준다.

'공부 > Linux' 카테고리의 다른 글

(CentOS 7) SSH 보안설정  (0) 2020.02.19
(CentOS 7) openssh 업데이트  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #4  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #3  (0) 2020.02.19
(CentOS 7) 워드프레스 설치 #2  (0) 2020.02.19

+ Recent posts