리눅스 웹메일 오픈소스 RoundCube


리눅스에서 메일서버를 구축하는 방법은 다람쥐메일 등 여러가지가 있겠지만 Postfix + DoveCot + RoundCube 로 웹메일을 구축 방법에 대해서 알아보겠습니다.

CentOS 7.x 기준입니다.

먼저 DNS 설정에서 MX 레코드 설정이 되어 있어야 합니다.


▶ MX 레코드 설정

mail            A            domain.com

domain.com    MX    10    mail.domain.com

이런 형태로 되면 됩니다.

보내는 건 되는데 받는게 안된다면 방화벽 또는 mx 레코드 설정을 의심해 보아야 합니다.


▶ Postfix 설치

# yum install postfix

# vi /etc/postfix/main.cf

myhostname = mail.domain.com

mydomain = domain.com

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

home_mailbox = Maildir/

# systemctl start postfix

# systemctl enable postfix

postfix 대신에 sendmail 을 사용하여도 됩니다.


▶ DoveCot 설치

# yum install dovecot

# vi /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

# vi /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir

# vi /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no

# systemctl start dovecot

# systemctl enable dovecot

pop3 나 imap 을 위해서 설치하여야 합니다.


▶ DB Database 생성

CREATE DATABASE roundcube;

GRANT ALL PRIVILEGES ON roundcube.* TO roundcube@localhost IDENTIFIED BY '비밀번호';

exit;

mysql -u root -p 로 접속해서 생성하면 됩니다.

roundcube 대신에 마음에 드는 계정명으로 생성


▶ RoundCube 소스 다운로드

# cd /var/www/html

# wget https://github.com/roundcube/roundcubemail/releases/download/1.3.7/roundcubemail-1.3.7-complete.tar.gz

# tar zxvf roundcubemail-1.3.7-complete.tar.gz

# ln -s roundcubemail-1.3.7 roundcube

# chown -R apache.apache roundcubemail-1.3.7

아파치의 DocumentRoot 에 맞게 받으면 됩니다.

참고로 yum install roundcubemail 로 설치하는 방법도 있습니다. ( https://ivps.tistory.com/580 참고 )


▶ RoundCube 설치

브라우저에서 자신의 도메인에 맞게 http://domain.com/roundcube/installer 페이지를 호출합니다.

required 관련된 부분이 OK 가 나오면 됩니다.

NEXT 버튼을 눌러서 다음으로 진행합니다.


mysql 계정 정보를 입력하고 다음으로 넘어갑니다.


Check DB config 에서 Initialize database 를 눌러서 DB 정보를 초기화 합니다.


▶ 메일계정 생성

# useradd roundcube

# passwd roundcube

Changing password for user roundcube.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

테스트에 사용될 계정을 생성합니다.


▶ 웹메일 접속 테스트

http://domain.com/roundcube 페이지를 열어서 로그인을 시도합니다.

로그인을 시도합니다.

저장소 서버에 연결을 실패했습니다. 에러가 뜨는군요~

DovoCot 이 설치가 되지 않았거나 설정이 잘 못 되면 나타나는 현상입니다.

설정을 재확인 합니다.

로그인이 정상적으로 되는지 좀전의 installer 페이지에서도 확인이 가능합니다.


▶ SMTP 포트 방화벽 설정

# firewall-cmd --permanent --zone=public --add-service=smtp

# firewall-cmd --reload

외부에서 메일을 받으려면 방화벽에서 smtp 포트가 열려 있어야 합니다.


이제 메일을 주고 받기 테스트 하시면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[MySQL] systemctl start mariadb 에러


조금 황당한 경우이긴 하지만 mysql 이 죽어있길래 재시작을 하니 에러가 나서 확인해봤습니다.

[root@vtr html]# systemctl status mariadb

● mariadb.service - MariaDB database server

   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)

   Active: failed (Result: exit-code) since Thu 2018-10-04 16:38:06 KST; 4min 23s ago

  Process: 22597 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=1/FAILURE)

  Process: 22596 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)

  Process: 22566 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)

 Main PID: 22596 (code=exited, status=0/SUCCESS)


Oct 04 16:38:04 vtr systemd[1]: Starting MariaDB database server...

Oct 04 16:38:04 vtr mariadb-prepare-db-dir[22566]: Database MariaDB is probab...

Oct 04 16:38:05 vtr mysqld_safe[22596]: 181004 16:38:05 mysqld_safe Logging ....

Oct 04 16:38:05 vtr mysqld_safe[22596]: 181004 16:38:05 mysqld_safe Starting...l

Oct 04 16:38:06 vtr systemd[1]: mariadb.service: control process exited, co...=1

Oct 04 16:38:06 vtr systemd[1]: Failed to start MariaDB database server.

Oct 04 16:38:06 vtr systemd[1]: Unit mariadb.service entered failed state.

Oct 04 16:38:06 vtr systemd[1]: mariadb.service failed.

Hint: Some lines were ellipsized, use -l to show in full.

운영중인 VPS 가 메모리가 너무 부족해서 생긴 현상인데 스왑메모리를 추가해서 해결하였습니다.

swap 늘이는 방법은 https://ivps.tistory.com/283 여기를 참고하세요~



'LINUX' 카테고리의 다른 글

RoundCube VirtualHost 도메인 연결  (0) 2018.10.05
리눅스 웹메일 오픈소스 RoundCube  (0) 2018.10.04
리눅스 퍼미션 권한이란  (0) 2018.09.13
CentOS 서버 이전시 백업 목록  (0) 2018.09.04
CentOS 6.x NGINX configtest  (0) 2018.06.01
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 퍼미션 권한이란


Linux 에서 파일 또는 디렉토리에는 Permission 이라는 권한 설정이 되어 있습니다.

이유는 리눅스가 여러 사용자가 사용하는 OS 이기 때문입니다.

루트 폴더에서 ls -l 명령어로 한번 파일 리스트를 살펴보겠습니다.

리눅스 퍼미션 권한이란

맨 앞쪽 글자가 의미하는건

b : block type

c : character type

d : directory

l : symbolic link

p : named pipe

s : socket

- : 일반파일

을 의미합니다.


그리고 뒷쪽으로 9자리는 소유자 3자리, 소유자그룹 3자리, 그 외 유저 3자리입니다.

r : 읽기

w : 쓰기

x : 실행

을 의미합니다.


권한변경은 chmod 로 할 수 있습니다.

ex) chmod 777 파일명


'LINUX' 카테고리의 다른 글

리눅스 웹메일 오픈소스 RoundCube  (0) 2018.10.04
[MySQL] systemctl start mariadb 에러  (0) 2018.10.04
CentOS 서버 이전시 백업 목록  (0) 2018.09.04
CentOS 6.x NGINX configtest  (0) 2018.06.01
리눅스 하드디스크 정보보기  (0) 2018.05.29
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 서버 이전시 백업 목록



서버를 운영하다가 트래픽이 많아지거나 리소스나 용량이 부족하게 된다면 상위의 고사양 서버로 이전을 해야됩니다.


조금 귀찮기는 하지만 한번에 복사하는 방식으로 백업해서 이전한다면 사용자 계정별로 백업하는 것 보다는 좀 더 편한한 방법이 될 것입니다.



▶ 계정 백업 ( 로그인 및 데이터 )


/etc/group

/etc/gshadow

/etc/passwd

/etc/shadow


/home/



▶ DB 백업 ( mysql 기준 )


/var/lib/mysql/



▶ 시스템 설정 파일


/etc/cron.d/

/etc/my.cnf

/etc/fstab ( UUID 인 경우는 그냥 복사하면 안되고 설정해 주어야 함 )

/etc/localtime

/etc/hosts

/etc/hosts.allow

/etc/hosts.deny

/etc/httpd/conf/

/etc/httpd/conf.d/

/etc/php.ini

/etc/phpMyAdmin/config.inc.php

/etc/nginx/conf.d

/etc/php-fpm.d/www.conf

/etc/security/limits.conf

/etc/named.rfc1912.zones ( /var/named 추가적으로 백업 )

/etc/letsencrypt/
/etc/systemd/system/multi-user.target.wants/
/etc/firewalld/zones/public.xml


일단 현재까지 생각나는 것만 정리해 보았습니다.


서버 환경 마다 다를 것입니다.


'LINUX' 카테고리의 다른 글

[MySQL] systemctl start mariadb 에러  (0) 2018.10.04
리눅스 퍼미션 권한이란  (0) 2018.09.13
CentOS 6.x NGINX configtest  (0) 2018.06.01
리눅스 하드디스크 정보보기  (0) 2018.05.29
CentOS 하드디스크 추가시 마운트하기  (0) 2018.05.29
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 6.x NGINX configtest


아파치는 apachectl configtest 옵션으로 환경설정이 제대로 되었는지 검증이 가능합니다.

nginx 는 nginx -t 옵션으로 확인하면 됩니다.

[root@vps conf.d]# nginx configtest

nginx: invalid option: "configtest"


[root@vps conf.d]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

아파치 버전 마다 다르겠지만 2.2 버전대에서는 apachectl configtest 는

# apachectl -t 와 동일합니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 하드디스크 정보보기



리눅스에서 CrystalDiskInfo 와 같은 유틸리티가 있습니다.


그리고 SMART 기능이 제공이 되어야 확인이 가능합니다.



▶ smartmontools 설치


# yum install smartmontools



▶ smartctl 명령어로 정보확인


# smartctl -i /dev/sdb

smartctl 5.43 2016-09-28 r4347 [x86_64-linux-2.6.32-696.23.1.el6.x86_64] (local build)

Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net


=== START OF INFORMATION SECTION ===

Model Family:     Hitachi Deskstar 7K1000.D

Device Model:     Hitachi HDS721010DLE630

Serial Number:    MSK5235H7TT6KG

LU WWN Device Id: 5 000cca 37cf58a4e

Firmware Version: MS2OA610

User Capacity:    1,000,204,886,016 bytes [1.00 TB]

Sector Sizes:     512 bytes logical, 4096 bytes physical

Device is:        In smartctl database [for details use: -P show]

ATA Version is:   8

ATA Standard is:  ATA-8-ACS revision 4

Local Time is:    Tue May 29 13:10:51 2018 KST

SMART support is: Available - device has SMART capability.

SMART support is: Enabled


# smartctl -a /dev/sdb

...

  1 Raw_Read_Error_Rate     0x000b   063   063   016    Pre-fail  Always       -       251007239

  2 Throughput_Performance  0x0005   134   134   054    Pre-fail  Offline      -       98

  3 Spin_Up_Time            0x0007   154   154   024    Pre-fail  Always       -       152 (Average 145)

  4 Start_Stop_Count        0x0012   100   100   000    Old_age   Always       -       15

  5 Reallocated_Sector_Ct   0x0033   001   001   005    Pre-fail  Always   FAILING_NOW 1910

  7 Seek_Error_Rate         0x000b   100   100   067    Pre-fail  Always       -       0

  8 Seek_Time_Performance   0x0005   113   113   020    Pre-fail  Offline      -       35

  9 Power_On_Hours          0x0012   095   095   000    Old_age   Always       -       41568

 10 Spin_Retry_Count        0x0013   100   100   060    Pre-fail  Always       -       0

 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       15

192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       107

193 Load_Cycle_Count        0x0012   100   100   000    Old_age   Always       -       107

194 Temperature_Celsius     0x0002   162   162   000    Old_age   Always       -       37 (Min/Max 21/42)

196 Reallocated_Event_Count 0x0032   001   001   000    Old_age   Always       -       1995

197 Current_Pending_Sector  0x0022   100   100   000    Old_age   Always       -       0

198 Offline_Uncorrectable   0x0008   100   100   000    Old_age   Offline      -       0

199 UDMA_CRC_Error_Count    0x000a   200   200   000    Old_age   Always       -       0

...


5번과 9번 항목을 주로 보는데 섹터 상태가 안좋군요~


그리고 작동시간은 5년을 넘어갑니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 하드디스크 추가시 마운트하기



기존 하드디스크 이외에 하나더 추가할 경우 포맷하고 마운트를 하여야 합니다.


먼저 fdisk -l 로 Disk 정보를 확인합니다.


[root@vps ~]# fdisk -l


Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

...


Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

255 heads, 63 sectors/track, 121601 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x00000000


/dev/sdb 로 확인되었습니다.


이제 파티션을 잡아야 합니다.


[root@vps ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xbf2eadcc.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').


Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-121601, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-121601, default 121601):

Using default value 121601


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.


굵은파란색을 보시면 됩니다.


파티션을 잡은 뒤에는 포맷을 합니다.


[root@vps ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

/dev/sdb1 alignment is offset by 512 bytes.

This may result in very poor performance, (re)-partitioning suggested.

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=1 blocks, Stripe width=0 blocks

61054976 inodes, 244190000 blocks

12209500 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

7453 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000, 214990848


Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.


시간이 조금 걸립니다.


이제 마운트를 하면 됩니다.


uuid 로 마운트를 해볼까요~


[root@vps ~]# blkid /dev/sdb1

/dev/sdb1: UUID="5a76eec0-4b80-d3c4-9de4-302bffcc898c" TYPE="ext4"


UUID 를 복사해서 /etc/fstab 에 아래 처럼 추가합니다.


UUID=5a76eec0-4b80-d3c4-9de4-302bffcc898c /hdd2 ext4 defaults 1 1


/hdd2 는 미리 만들어 주어야 합니다. (mkdir /hdd2)


# mount -a 로 마운트 하면 됩니다.


# df -h 로 제대로 마운트 되었는지 확인합니다.


'LINUX' 카테고리의 다른 글

CentOS 6.x NGINX configtest  (0) 2018.06.01
리눅스 하드디스크 정보보기  (0) 2018.05.29
리눅스 RSYNC 특정 폴더 제외하기  (0) 2018.05.28
CentOS yum install 메모리 에러  (0) 2018.05.25
htaccess 특정IP만 허용하기  (0) 2018.04.12
블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 RSYNC 특정 폴더 제외하기



서버 파일 백업시 유용한 유틸인 rsync 입니다.


특정 폴더를 제외하고 싶을때는 --exclude 옵션을 사용하면 됩니다.


rsync -av --delete --exclude 'tmp' /home /backup


/home/tmp 폴더를 제외하고 싶다면 상대경로로 'tmp' 만 적으시면 됩니다.



여러개를 제외하려면 --exclude-from '적용제외할리스트파일'


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS yum install 메모리 에러


vps 서버에 php mysql 을 설치하려고 하는데 아래 처럼 에러가 발생하네요~

아무래도 메모리 부족인 것 같습니다.

Error downloading packages:

  libX11-common-1.6.5-1.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  libX11-1.6.5-1.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-cli-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-mbstring-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-pdo-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  libzip-0.10.1-8.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  apr-util-1.5.2-6.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  perl-Data-Dumper-2.145-3.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-gd-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  autoconf-2.69-11.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  libXpm-3.5.12-1.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-mysql-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-fpm-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-devel-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  m4-1.4.16-10.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  mailcap-2.1.41-2.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  perl-Thread-Queue-3.02-2.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  php-common-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  automake-1.13.4-3.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  httpd-tools-2.4.6-80.el7.centos.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  libxcb-1.12-1.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  libXau-1.0.8-2.1.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  httpd-2.4.6-80.el7.centos.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  t1lib-5.1.2-14.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  apr-1.4.8-3.el7_4.1.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  libjpeg-turbo-1.2.90-5.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  php-5.4.16-45.el7.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

  perl-Test-Harness-3.28-3.el7.noarch: [Errno 5] [Errno 12] Cannot allocate memory

  2:libpng-1.5.13-7.el7_2.x86_64: [Errno 5] [Errno 12] Cannot allocate memory

https://ivps.tistory.com/283 여기를 참고해서 스왑 메모리가 없다면 추가해 주면 됩니다.


스왑메모리를 1기가 정도 추가해주고 부터는 설치가 잘 되는군요~



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

htaccess 특정IP만 허용하기


워드프레스 처럼 /wp-admin/ 폴더는 관리자 아이피만 허용하도록 하고 싶을때가 있습니다.

이런 경우엔 wp-admin 디렉토리에 .htaccess 파일을 만들어서 아래 내용을 넣어주면 됩니다.


  order deny,allow

  deny from all

  allow from ::1


xampp 와 같은 APM TOOL 을 사용하면 IP가 ::1 로 인식하더군요~

서버에서는 관리자 접속 아이피로 설정하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,