1. FTP 계정 생성
FTP 계정 생성전 FTP 서비스 이용을 위해 서버내 FTP 서비스가 구동중인지 확인이 필요합니다.
FTP 서비스 구동 여부 확인
[root@serverhosting_test ~]# service vsftpd status
Redirecting to /bin/systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
위와 같이 미구동 상태일 경우 아래 명령어로 구동 바랍니다.
[root@serverhosting_test ~]# service vsftpd start (또는 systemctl start vsftpd.service)
Redirecting to /bin/systemctl start vsftpd.service
FTP 서비스 구동 확인 완료
[root@serverhosting_test ~]# service vsftpd status
Redirecting to /bin/systemctl status vsftpd.service
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-04-13 15:45:29 KST; 29s ago
Process: 5664 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 5665 (vsftpd)
CGroup: /system.slice/vsftpd.service
└─5665 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Apr 13 15:45:29 serverhosting_test systemd[1]: Starting Vsftpd ftp daemon...
Apr 13 15:45:29 serverhosting_test systemd[1]: Started Vsftpd ftp daemon.
FTP 계정 생성을 위해선 우선 계정 생성이 필요한 서버에 접속(SSH)합니다.
아래 명령어에 따라 FTP 계정 생성 진행
1. FTP 계정 생성 : useradd -d [FTP계정의 홈경로] [FTP 계정명]
2. 생성한 FTP 계정 패스워드 설정 : passwd [FTP 계정명]
3. FTP 계정 생성 여부 체크 : cat /etc/passwd
4. home 경로 정상 생성 여부 체크 : ls -alt /home / grep [FTP 계정명]
계정 생성 예시
생성할 FTP 계정명 : serverhosting
FTP 계정의 홈경로 : /home/serverhosting
[root@serverhosting_test ~]# useradd -d /home/serverhosting serverhosting
[root@serverhosting_test ~]# passwd serverhosting
Changing password for user serverhosting.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@serverhosting_test ~]# cat /etc/passwd | grep serverhosting
serverhosting:x:1004:1004::/home/serverhosting:/bin/bash --> 생성한 FTP 계정 정보
[root@serverhosting_test ~]# ls -alt /home/ | grep serverhosting
drwx------ 2 serverhosting serverhosting 62 2022-04-13 15:04 serverhosting --> FTP계정 홈경로 정보
2. MYSQL 계정 생성
mysql 계정 및 DB 생성전 mysql 이 구동되어 있어야합니다.
mysql 구동 여부 및 구동 명령어 확인은 아래 링크 참고 바랍니다.
mysql 구동 및 구동 여부 체크
1. mysql 접속 : /opt/mysql/bin/mysql -u root -p
최초 접속일 경우 mysql 패스워드는 없는 상태입니다.
"enter"키 입력시 바로 접속 가능
mysql 설치 경로가 /opt가 아닐 경우 opt가 아닌 설치 경로로 수정하여 명령어 실행
2. DB 생성 : create database [DB명];
3. mysql 계정 생성 : grant all privileges on [계정명].* to [DB명]@localhost identified by '[계정에 대한 패스워드]';
4. MYSQL 적용 : flush privileges;
MYSQL 계정 및 DB 생성 예시
생성할 DB명 : serverhosting
생성할 MYSQL 계정 : serverhosting_user
계정에 대한 패스워드 : serverhosting@01
mysql> create database serverhosting;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on serverhosting.* to serverhosting_user@localhost identified by 'serverhosting@01';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
생성되어 있는 DB 리스트 확인
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| serverhosting |
| test |
+--------------------+
4 rows in set (0.00 sec)
생성되어 있는 MYSQL 계정 확인
mysql> select host,user from mysql.user;
+-------------+-----------------+
| host | user |
+-------------+-----------------+
| 127.0.0.1 | root |
| localhost | root |
| localhost | serverhosting_user|
+-------------+-----------------+
3 rows in set (0.00 sec)
MYSQL 외부 접속 설정
mysql> grant all privileges on [DB명].* to [계정명]@"외부접속 IP" identified by '[계정에 대한 패스워드]';
외부에서 MYSQL 접속할 IP : 111.111.111.111
외부 접속할 DB명 : serverhosting
외부 접속할 MYSQL 계정명 : serverhosting_user
MYSQL 계정 패스워드 : serverhosting@01
mysql> grant all privileges on serverhosting.* to serverhosting_user@"111.111.111.111" identified by 'serverhosting@01';
mysql> select host,user from mysql.user;
+-------------+-----------------------+
| host | user |
+-------------+-----------------------+
| 127.0.0.1 | root |
| localhost | root |
| localhost | serverhosting_user |
| 111.111.111.111 | serverhosting_user|
+-------------+-----------------------+
4 rows in set (0.00 sec)
위와 같이 설정을 진행하여도 DB 접속이 불가할 경우 방화벽(iptables,ufw 등) 설정 확인이 필요합니다.