티스토리 뷰

반응형

APM 설치에 앞서

서버는 AWS를 사용했으며, 이 것을 기준으로 기록합니다.
(다른 클라우드를 사용하시는 분들께는 죄송합니다.)
또한 작성의 속도를 높이기 위해 모든 문장에 높임법을 사용하지 않겠습니다. (여기부터 시작)
본인도 초보라 문제 해결 능력은 떨어지지만 앞으로 자주하게 될 것 같아 여기에 기록한다.

 

aws / Ubuntu Server 20.04 LTS 사용

 

하기의 모든 명령어는 sudo su를 실행 후 입력하는 것을 기본으로 한다.

ubuntu@ip-000-000-000-000:~$ sudo su
root@ip-000-000-000-000:/#

설치에 앞서 우분투 버전 확인한다.
lsb_release -a를 입력하여 버전을 확인하는데 맨 아래 Codename을 잘 확인해봐야 한다.
만약 apt-get을 사용하는데 어딘가 모를 오류가 발생한다면 /etc/apt/sources.list에 이 Codename에 맞게 미러서버를 설정했는지 확인해봐야한다.

root@ip-000-000-000-000:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

/etc/apt/sources.list 내에 Codename이 실제 버전과 맞지 않는 경우 아래와 같은 오류가 노출된다.

 

The following packages have unmet dependencies:
distro-info-data : Breaks: distro-info (< 0.20~) but 0.18ubuntu0.18.04.1 is to be installed
dpkg : Breaks: libapt-pkg5.0 (< 1.7~b) but 1.6.13 is to be installed
E: Broken packages

 

apt update & apt upgrade

apt-get은 apt로 줄여서 사용할 수 있게 되어있다. 만약 apt 명령어가 먹히지 않는다면 apt-get으로 입력해주면 된다. (vim을 vi로 줄여쓰는 경우도 이와 같음)
/etc/apt/sources.list에는 우리가 apt를 사용할 때 읽어올 서버(저장소)들이 적혀 있는데 만약 당신의 서버가 한국에 있다면 아래의 명령어를 실행하여 저장소를 한국에 있는 서버로 바꿔주는 것이 설치 시간 단축에 도움을 준다.
vim 편집기를 사용하여, /etc/apt/sources.list를 연다.

root@ip-000-000-000-000:/# vi /etc/apt/sources.list

파일이 열리면 d를 꾸욱 눌러서 모든 라인을 지우고 아래의 내용을 복붙한다.
복붙 후 :wq를 입력하여 저장하고 편집기를 나온다.

deb http://mirror.kakao.com/ubuntu/ focal main restricted universe multiverse
deb http://mirror.kakao.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirror.kakao.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse

복붙한 내용을 보면 아까 확인했던 Codename인 focal이 쓰여 있는데 Codename이 다른 서버를 사용하는 사람들은 focal 부분을 본인의 서버 Codename으로 바꿔 놓으면 된다.
일일이 고치는 것이 귀찮기 때문에 아래의 명령어를 참고하여 자신의 Codename으로 바꿔준다.

root@ip-000-000-000-000:/# sed -i 's/focal/자신서버의Codename/g' /etc/apt/sources.list

만약 본인이 저장소를 직접 선택하고 싶다면 아래의 링크를 참조한다.
https://launchpad.net/ubuntu/+archivemirrors

저장소 변경이 끝났다면 update & upgrade로 서버를 최신화 한다.

root@ip-000-000-000-000:/# apt update
update 내용...
root@ip-000-000-000-000:/# apt upgrade

apt upgrade 명령어를 입력시 블라블라하다가 Y/n이 나타나는데 y입력 후 엔터키 누르면 된다.
지금까지의 과정을 무리없이 끝냈다면 우리가 원하는 apache2, php8, mariadb를 설치할 준비가 완료된 것이다.

 

서버 시간 설정

시간 설정을 하자(물론 날짜도 포함). 이 부분이 안되어 있으면 나중에 피(?)를 볼 수 있다.

root@ip-000-000-000-000:/# dpkg-reconfigure tzdata

입력 후 하단의 이미지와 같이 각각 Asia 선택 후 엔터 키, Seoul 선택 후 엔터 키를 누른다.

시간 설정이 끝났다. 확인은 date 명령어로 해준다.

root@ip-000-000-000-000:/# date
Tue Jun  8 16:29:13 KST 2021

간단..ㅎ

 

Apache2 설치

먼저 apache2를 설치해보자.

root@ip-000-000-000-000:/# apt install apache2

설치될 용량을 말해주면서 Do you want to continue? [Y/n] 분기가 생기는데 그냥 y를 입력해준다.
(앞으로 이 과정은 생략함)

 

설치가 끝나고 진짜 하나도 안궁금할수도 있지만 아파치 버전을 확인해 보고 싶은 사람은 apache2 -v를 입력하면 확인이 가능하다. 필자와 버전이 다르더라도 놀라지 않도록 한다. 그동안 버전이 올랐을 수도 있다…ㅎ;

root@ip-000-000-000-000:/# apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Server built:   2020-08-12T19:46:17

아파치 설치 후 웹브라우저에 서버의 아이피를 입력해보면 뭔가 뜬다.

뭐라 막 써있는데 그냥 '잘 설치되었구나'라고 생각하고 창을 닫았다.

추가로 certbot을 설치

root@ip-000-000-000-000:/# apt install certbot

 

PHP8.1 설치 (updated at 2022-01-03)

작성일 기준, 현재 최신 버전의 php를 설치하려면 저장소를 따로 지정해줘야 한다.
apt list php 등의 명령어로 확인해 보면 알겠지만 php7대 까지만 설치할 수 있다.
아래의 명령어로 php는 최신 버전을 받을 수 있는 저장소로 따로 연결해준다.

root@ip-000-000-000-000:/# add-apt-repository ppa:ondrej/php
 Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

IMPORTANT: The <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://mirror.kakao.com/ubuntu focal InRelease
Get:2 http://mirror.kakao.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://mirror.kakao.com/ubuntu focal-backports InRelease [101 kB]
Get:4 http://mirror.kakao.com/ubuntu focal-updates/main amd64 Packages [1026 kB]
Get:5 http://mirror.kakao.com/ubuntu focal-updates/universe amd64 Packages [781 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu focal InRelease [23.9 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages [91.9 kB]
Get:9 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main Translation-en [31.6 kB]
Fetched 2283 kB in 3s (846 kB/s)
Reading package lists... Done

위의 작업이 끝났다면 php8.0을 설치한다.
참고로 libapache2-mod-php8.0은 아파치에서 사용하기 위한 모듈이다.

root@ip-000-000-000-000:/# apt install php8.1 libapache2-mod-php8.1

설치 후 php 버전 확인 명령어

root@ip-000-000-000-000:/# php -v
PHP 8.1.1 (cli) (built: Dec 31 2021 07:26:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

아래의 추가 라이브러리는 본인이 필요한 것만 설치하면 된다.

root@ip-000-000-000-000:/# apt install php8.1-{cli,curl,dev,gd,imagick,imap,mbstring,mysql,oauth,soap,xml,xmlrpc,zip}

 

MariaDB 설치

mariadb를 설치하자.

root@ip-000-000-000-000:/# apt install mariadb-server

 

설치 후 몇 가지 설정을 해줘야하는데.. (설명은 소스 하기에..)

root@ip-000-000-000-000:/# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Enter current password for root (enter for none):
여기는 루트 비밀번호를 입력하라는 것인데 이제 막 설치해 비밀번호가 없으니 그냥 엔터키를 누른다.
(다음에 또 실행할 경우에는 아래에서 설정하는 비밀번호를 입력해주면 된다.)
Set root password? [Y/n] y
루트 비밀번호를 설정할지 결정 참고로 필자는 아래 모든 분기에 y를 선택했다.
Remove anonymous users? [Y/n] y
익명 사용자 제거 유무
Disallow root login remotely? [Y/n] y
원격 루트 로그인 허용 안함
Remove test database and access to it? [Y/n] y
테스트DB 삭제 여부
Reload privilege tables now? [Y/n] y
권한 테이블 리로드 여부

 

 

일단 apache2, php8, mariadb 설치를 마쳤다.

수고하셨습니다 :)

 

반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함