1. Oracle VirtualBox 설치 VirtualBox-7.2.4-170995-Win.exe Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack 확장 - 설치 : Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack 2. Oracle VirtualBox 관리자 - 새로만들기 - Virtual machine name and operating system VM Name : ZX1(10.10.0.100) VM Folder : C:\VMs\VBOX ISO Image : C:\VMs\Setup\ubuntu-24.04.4-live-server-amd64.iso (체크안함) Proceed with Unattended Installation : 무인설치건너뛰기 - Specify virtual hardware Base Memory : 4096 MB Number of CPUs : 2 - specify virtual hard disk Create a New Virtual Hard Dsik D:\VMs\VBOX\ZX1(10.10.0.100)\ZX1(10.10.0.100).vdi 25.00GB --완료 - 네트워크 어댑터1 : (체크)네트워크 어댑터 활성화 Attached to : NAT 포트포워딩 apache2 TCP 80 80 apache2_ssl TCP 443 443 어댑터2 : (체크)네트워크 어댑터 활성화 Attached to : 호스트전용어댑터 --시작 --ubuntu 설치 # 1. root 계정 비밀번호 활성화 sudo passwd root # 현재 비밀번호(@서버암호), 새 UNIX 비밀번호(@서버암호) 입력 # 2. root 계정으로 전환 su - # 3. netplan 고정 IP 설정 파일 정돈 (/etc/netplan/01-netcfg.yaml) rm -f /etc/netplan/50-cloud-init.yaml vi /etc/netplan/01-netcfg.yaml network: version: 2 ethernets: enp0s3: dhcp4: yes enp0s8: dhcp4: no addresses: [10.10.0.100/24] :wq netplan apply # 4. OpenSSH 보안 설정 vi /etc/ssh/sshd_config PermitRootLogin yes Ciphers aes128-ctr,aes192-ctr,aes256-ctr KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256 MACs hmac-sha2-256,hmac-sha2-512 :wq systemctl restart ssh # 5. 공유폴더 설정 # 기존 wwwroot 디렉터리 백업 및 정리 # 기존 폴더 백업 mv /storage/wwwroot /storage/wwwroot_backup # 마운트 포인트 새 디렉터리 생성 mkdir -p /storage/wwwroot ls -ld /storage/wwwroot # VirtualBox 게스트 확장(Guest Additions) 설치 sudo apt update sudo apt install -y build-essential dkms linux-headers-$(uname -r) sudo apt install -y virtualbox-guest-utils modinfo vboxsf # VirtualBox 공유 폴더 설정 # VBox콘솔메뉴 : 장치 - 공유폴더 - 머신폴더 하위에 추가 - 폴더선택 폴더경로 : D:\VMs\antigravity_wwwroot 폴더이름 : wwwroot (체크해제) 읽기전용 (체크해제) 자동마운트 --부팅 시 자동 마운트 설정 (/etc/fstab) (체크) Make Machine-permanent (체크해제) Make Global # 수동 마운트 테스트 및 웹 서버 권한 부여 sudo usermod -aG vboxsf $USER sudo usermod -aG vboxsf www-data sudo mount -t vboxsf -o rw,uid=$(id -u www-data),gid=$(id -g www-data),dmode=775,fmode=664 wwwroot /storage/wwwroot # 부팅 시 자동 마운트 설정 (/etc/fstab) vi /etc/fstab wwwroot /storage/wwwroot vboxsf rw,uid=www-data,gid=www-data,dmode=775,fmode=664,_netdev 0 0 :wq umount /storage/wwwroot mount -a ####################################################### --20260422 : 추가분 # vi /etc/php/8.2/apache2/php.ini (수정:409)max_execution_time = 120 #PHP 스크립트 최대 실행 시간:120초(2분) (수정:419)max_input_time = 120 #POST/GET 입력 데이터 처리 최대 시간:120초(2분) (수정:435)memory_limit = 1024M #PHP 스크립트에서 사용할 수 있는 최대 메모리 용량 :wq # systemctl restart apache2 --20260329 : 추가분 # 디렉토리 내부 새 파일 자동 권한 설정 sudo apt update sudo apt install acl setfacl -d -m u::rwx /storage1/wwwroot/master/ # 시스템스위치 데이터이전 실행방법 chmod +x /storage1/wwwroot/master/data_tools_age.sh chmod +x /storage1/wwwroot/master/data_tools_backup.sh chmod +x /storage1/wwwroot/master/data_tools_certificate.sh chmod +x /storage1/wwwroot/master/data_tools_copy.sh chmod +x /storage1/wwwroot/master/data_tools_ghost.sh chmod +x /storage1/wwwroot/master/data_tools_master.sh chmod +x /storage1/wwwroot/master/data_tools_restore.sh # 복원 실행방법 # /storage1/wwwroot/master/data_tools_restore.sh # 백업 실행방법2026-04-22 (수) # /storage1/wwwroot/master/data_tools_backup.sh --20260311 : 추가분 Windows VM 네트워크 - Adapter Type : Intel PRO/1000 MT Server Linux VM 네트워크 - Adapter Type : 반가상 네트워크(virtio-net), Promiscuous Mode : 가상머신에 허용 AX1_Apache(192.168.56.101) 10GB / 8 vCPU 저장소 - 속성 Type : AHCI -> virtio-scsi 저장소 - 호스트 I/O 캐시 사용하기 비활성화 마더보드 - Chipset : PIIX3 DX1_MySQL(192.168.56.201) 16GB / 8 vCPU : innodb_buffer_pool_size = 12G DX2_MySQL(192.168.56.202) 4GB / 4 vCPU MX1_Apache_MySQL(192.168.56.200) 6GB / 4 vCPU SX1_Apache_MySQL(192.168.56.203) 4GB / 2 vCPU --20260213 : 추가분 # 서비스 중지 # systemctl stop apache2 # systemctl stop mysql # systemctl restart apache2 --소유권 변경 : 해당 디렉토리에 대한 쓰기 권한을 가지고 있어야 합니다. # mkdir -p /storage1/wwwroot/files sudo chown -R www-data:www-data /storage1/wwwroot sudo chmod -R 755 /storage1/wwwroot sudo chmod -R 775 /storage1/wwwroot/files sudo chown -R www-data:www-data /storage1/wwwroot/files sudo chown -R www-data:www-data /storage2/wwwroot/files sudo chown -R www-data:www-data /storage3/wwwroot/files --20260211 : 추가분 # vi /etc/apache2/mods-available/php8.2.conf (추가:6) SetHandler application/x-httpd-php :wq # vi /etc/apache2/sites-available/000-default.conf (추가:15)오류페이지처리 # vi /etc/apache2/sites-available/default-ssl.conf (추가:10)오류페이지처리 ErrorDocument 400 /core/error.html ErrorDocument 401 /core/error.html ErrorDocument 403 /core/error.html ErrorDocument 404 /core/error.html ErrorDocument 500 /core/error.html ErrorDocument 502 /core/error.html ErrorDocument 503 /core/error.html :wq ####################################################### --20260210 : 서버부팅(5분) --우분투 설치: http://www.ubuntu.com/download/server --우분투(Ubuntu)에서 APM 웹서버 구축하기: http://sarghis.com/blog/680/ CPU Dual Intel Xeon x 2, RAM 48 GB SSD 삼성 PM893 480GB(윈도우,VBOX,VM x 4EA) HDD SAS 1TB × 2EA 미러링(240GB : AX1_Apache_Storage1) HDD SAS 1TB × 2EA 미러링(120GB : DX1_MySQL_Storage1, DX2_MySQL_Storage1, DX3_MySQL_Storage1, MX1_Apache_MySQL_Storage1) HDD SAS 1TB x 2EA 백업용 --가상머신 만들기 --VirtualBox-7.2.4-170995-Win.exe --Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack 확장 - 설치 : Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack --Virtual machine Name and Operating System (가이드모드) 이름 : ZX1_Apache Folder : C:\VMs\VBOX ISO Image : C:\VMs\Setup\ubuntu-22.04.3-live-server-amd64.iso (체크안함) Proceed with Unattended Installation : 무인설치건너뛰기 ZX1_Apache CPU 2개, RAM : 4GB, Storage1(120GB) 설정 위치: VM 설정 > 시스템(System) > 프로세서(Processor) > PAE/NX 사용(Enable PAE/NX) 체크 주의: VM이 종료된 상태에서만 설정을 변경할 수 있습니다. --저장소 Disk Size : 25GB (체크)미리전체크기할당 : Pre-allocate Full Size (체크)SSD일경우 --완료 --(필수)네트워크 어댑터1 : NAT --네크워크 포트포워딩 **어댑터2 : 네크워크 어댑터 활성화 다음에 연결됨 : 호스트전용어댑터 --시작 --우분투설치(30분소요) --STEP1 : Ubuntu22.04 운영체제설치 --STEP1-1 : Ubuntu22.04 운영체제설치 *Try or Install Ubuntu Server 1)Welcome:Use Up,Down and ENTER keys to select your language. : [English](엔터) 2)Intaller update available : [Continue without updating](엔터) 3)Keyboard configuration Layout: [English] Variant: [English] : [Done](엔터) Choose the type of installation **[X] Ubuntu Server 4)Network connections VMWare : [ens32 eth-] DHCPv4 10.0.2.15/24 VBox : [enp0s3 eth-][enp0s8 eth-] : [Done](엔터) 5)Configure proxy Proxy address: (공백) : [Done](엔터) Configure ubuntu archive mirror Mirror address : http://kr.archive.unbutu.com/ubuntu [Done](엔터) 6)Guided storage configuration (X)Use an entire disk [X]Set up this disk as an LVM group : [Done](엔터) 7)Storage configuration FILE SYSTEM SUMMARY : [Done](엔터) **7)Confirm destructive action : [Continue](엔터) **8)Profile setup Your name : ubuntu Your server's name : ubuntu Pick a ubsername : ubuntu Choose a password : @서버암호 Confirm your a password : @서버암호 [Done](엔터) 9)SSH Setup : [Done](엔터) 10)Featured Server Snaps : [Done](엔터) [Reboot Now] Rebooting... (6분소요) --OS버전확인 login : ubuntu password : @서버암호 $ lsb_release -a :버전확인 --root암호설정 $ sudo passwd root passwd for ubuntu:[현재로그인계정암호] Enter new UNIX password:[root계정암호] Retry new UNIX password:[root계정암호] $ exit --우분투의 모든패키지를 최신버전으로 업그레이드 # apt update # apt upgrade -y --시간설정 # apt install timedatectl vim # timedatectl set-timezone Asia/Seoul # timedatectl --(안함)한글모드지원 # apt-get install language-pack-ko # locale-gen ko_KR.UTF-8 # update-locale LANG=ko_KR.UTF-8 --STEP1-2 : 네트워크설정 --네트워크도구설치 # apt install -y net-tools # ifconfig # ip link show # ls /sys/class/net enp0s3 enp0s8 lo # rm -f /etc/netplan/50-cloud-init.yaml ---유동IP일경우 # vi /etc/netplan/01-netcfg.yaml network: ethernets: enp0s3: dhcp4: true dhcp4-overrides: route-metric: 100 enp0s8: dhcp4: no addresses: - 192.168.56.254/24 routes: [] version: 2 :wq # netplan generate ** (generate:1174): WARNING **: 08:58:03.607: Permissions for /etc/netplan/01-netcfg.yaml are too op en. Netplan configuration should NOT be accessible by others. # netplan apply ** (generate:1179): WARNING **: 08:58:11.512: Permissions for /etc/netplan/01-netcfg.yaml are too op en. Netplan configuration should NOT be accessible by others. WARNING:root: Cannot call Open vSwitch: ovsdb-server.service is not running. ** (process:1177): WARNING **: 08:58:11.903: Permissions for /etc/netplan/01-netcfg.yaml are too ope n. Netplan configuration should NOT be accessible by others. ** (process:1177): WARNING **: 08:58:12.010: Permissions for /etc/netplan/01-netcfg.yaml are too ope n. Netplan configuration should NOT be accessible by others. ** (process:1177): WARNING **: 08:58:12.011: Permissions for /etc/netplan/01-netcfg.yaml are too ope n. Netplan configuration should NOT be accessible by others. ---고정IP일경우 # ls /sys/class/net ens32 lo # vi /etc/netplan/01-netcfg.yaml network: renderer: networkd ethernets: ens32: dhcp4: no addresses: - 183.111.185.243/24 routes: - to: default via: 183.111.185.241 nameservers: addresses: - 168.126.63.1 - 8.8.8.8 version: 2 :wq # ifconfig --STEP1-3 : telnet설정 --텔넷서버 설치 # apt install -y xinetd telnetd vsftpd openssh-server --텔넷서버 환경설정 추가 # vi /etc/xinetd.conf defaults{...} (추가:13) service telnet { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure = USERID } :wq --텔넷서버 재시작 # systemctl restart xinetd --OpenSSH설정 --SSH 환경설정수정:root접속 # vi /etc/ssh/sshd_config # PermitRootLogin prohibit-password (추가:34) PermitRootLogin yes Ciphers aes128-ctr,aes192-ctr,aes256-ctr KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256 MACs hmac-sha2-256,hmac-sha2-512 :wq # systemctl restart ssh # systemctl status ssh Active: active (running) # ss -nlt LISTEN 0 128 0.0.0.0:22 0.0.0.0:* --방화벽 포트추가 (활성화)# ufw enable # ufw status Status: active # ufw allow ssh [SSH] MobaXterm 접속 ####################################################### --STEP1-4 : vsftp설정 --vsftp환경설정수정 # vi /etc/vsftpd.conf anonymous_enable=NO local_enable=YES (수정:31-주석제거)write_enable=YES (수정:114-주석제거)chroot_local_user=YES (추가:115) allow_writeable_chroot=YES pasv_enable=YES pasv_min_port=40000 pasv_max_port=40100 :wq # systemctl restart vsftpd --FTP 환경설정수정:root접속 # vi /etc/ftpusers (수정:3)#root :wq --게스트확장CD설치 --VBox콘솔메뉴 : 장치 - 게스트확장CD삽입... --(확인)C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso # mkdir -p /tools # mount /dev/cdrom /tools mount: /tools: WARNING: source write-protected, mounted read-only. # /tools/VBoxLinuxAdditions.run Verifying archive integrity... 100% MD5 checksums are OK. All good. Uncompressing VirtualBox 7.2.4 Guest Additions for Linux 100% bzip2 not found. Please install: bzip2 tar; and try again. --Virtaul BOX 공유폴더 --VBox콘솔메뉴 : 장치 - 공유폴더 - 머신폴더 하위에 추가 - 폴더선택 폴더경로 : D:\VMs\storage 폴더이름 : mnt_storage (체크)자동마운트,(체크)항상사용하기 : Make Machine-permanent, Make Global # mkdir -p /mnt/storage1 # mount -t vboxsf mnt_storage /mnt/storage1 --부팅할경우 공유폴더마운트 # vi /etc/fstab mnt_storage /mnt/storage1 vboxsf defaults 0 0 :wq -------------------------------------------------------------------------- 20260803:(해결)저장된 상태와 현재 설정이 충돌 자세한정보 : apic#0: Config mismatch - uApicMode: saved=3 config=2 [ver=5 pass=final] (VERR_SSM_LOAD_CONFIG_MISMATCH). 결과 코드: E_FAIL (0x80004005) 구성 요소: ConsoleWrap 인터페이스: IConsole {6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} 해결방법 : Oracle VM VirtualBox 관리자(머신-저장된 상태 삭제...) 20260214:(해결)스냅샷 디스크 오류 자세한정보 : Could not open the medium 결과 코드: E_FAIL (0x80004005) 구성 요소: SessionMachine 인터페이스: IMachine {e36a5081-a82a-40bd-9e4e-42a44d6ce50f} Could not read from boot medium! Please insert a bootable medium and reboot 해결방법 : Oracle VM VirtualBox 관리자 1.미디어-해당 하드디스크-연결 오류디스크 삭제 2.해당 머신설정-디스크추가-하드디스크 선택 20210917:(해결)가상머신 세션을 열 수 없습니다. 가상머신 세션을 열 수 없습니다. 자세한정보 : The VM session was closed before any attempt to power it on. 결과코드 : E_FAIL (0x80004005) 구성요소 : SessionMachine 인터페이스 : ISession {c0447716-ff5a-4795-b57a-ecd5fffa18a4} 해결방법1 : Oracle VM VirtualBox 관리자(머신-저장된 상태 삭제...) 해결방법2 : 작업관리자 -VirtualBox 프로세스(작업끝내기) 20260708:(해결)설정 파일 인식 오류 자세한정보 : Runtime error opening 'D:\VMs\VBOX\AX1_Apache(192.168.56.101)\AX1_Apache(192.168.56.101).vbox' for reading VERR_FILE_NOT_FOUND (File not found.). D:\tinderbox\win-rel\src\VBox\Main\src-server\MachineImpl.cpp[1000] (long __cdecl Machine::i_registeredInit(void)). 결과 코드: E_FAIL (0x80004005) 구성 요소: MachineWrap 인터페이스: IMachine {e36a5081-a82a-40bd-9e4e-42a44d6ce50f} 해결방법 : AX1_Apache(192.168.56.101).vbox-prev 파일을 AX1_Apache(192.168.56.101).vbox 복사함 -------------------------------------------------------------------------- --STEP2 : APACHE2+PHP설정 --STEP2-1 : APACHE2+PHP설정 # apt update # apt upgrade -y # apt install -y software-properties-common -y # add-apt-repository ppa:ondrej/php -y # ls /etc/apt/sources.list.d/ ondrej-ubuntu-php-focal.list # apt update # apt upgrade -y # apt install -y apache2 php8.2 libapache2-mod-php8.2 php8.2-cli php8.2-common php8.2-fpm php8.2-mysql php8.2-gd php8.2-curl php8.2-mbstring php8.2-xml php8.2-zip php8.2-bcmath php8.2-intl php8.2-imap php8.2-imagick php-pear php8.2-dev --php버전확인 # php -v PHP 8.2.30 (cli) (built: Dec 18 2025 23:36:49) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.30, Copyright (c) Zend Technologies with Zend OPcache v8.2.30, Copyright (c), by Zend Technologies --STEP2-2 : PHP설정 # vi /etc/apache2/mods-available/php8.2.conf (추가:6) SetHandler application/x-httpd-php :wq --PHP디버깅 # vi /etc/php/8.2/apache2/php.ini (수정:198)short_open_tag = On #PHP 시작 태그를 표준 형태인 > ~/.bashrc echo 'export PATH=/var/www/.npm-global/bin:$PATH' >> ~/.profile www-data@ubuntu:~$ exit --관리자계정에서 PM2 list 보기 # vi ~/.bashrc alias pm2-www='sudo -u www-data -i pm2' :wq # pm2-www list --보안 유지 (히스토리 삭제) cat /dev/null > ~/.bash_history && history -c (30분소요) # shutdown -P now --ZX1_Apache(192.168.56.254) ####################################################### --STEP3 : 미디어 가상하드만들기(하드추가:/storage1) --STEP3-1 : 미디어 가상하드 만들기(5분) --비어있는 가상하드만들기(가상하드 복사하지않고 새로만들기) 파일-도구-미디어-하드디스크-만들기(10분) 하드디스크파일위치와크기: E:\VMs\VBOX\AX1_Apache_Storage1.vdi / DiskSize: 240.00 GB 하드디스크파일위치와크기: D:\VMs\VBOX\DX1_Apache_Storage1.vdi / DiskSize: 120.00 GB 하드디스크파일위치와크기: D:\VMs\VBOX\DX2_Apache_Storage1.vdi / DiskSize: 120.00 GB 하드디스크파일위치와크기: D:\VMs\VBOX\MX1_Apache_MySQL_Storage1.vdi / DiskSize: 120.00 GB (체크)미리전체크기할당 --파티션 확인 # fdisk -l --디스크인식 확인 # lsblk --파티션 생성 # fdisk /dev/sdb Command (m for help): n Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-167772159, default 2048): (엔터) Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): (엔터) Command (m for help): w --- Command (m for help): n #새 파티션 Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p #primary Partition number (1-4, default 1): 1 #파티션 번호 First sector (2048-167772159, default 2048): (엔터) #시작섹터(기본) Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): (엔터) #끝섹터(전체사용) Created a new partition 1 of type 'Linux' and of size 80 GiB. Command (m for help): p Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 sectors Disk model: VBOX HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xc17740d9 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 167772159 167770112 80G 83 Linux Command (m for help): w #저장 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. --- # lsblk sdb 8:32 0 120G 0 disk └─sdb1 8:33 0 120G 0 part --포맷 # mkfs.ext4 /dev/sdb1 mke2fs 1.46.5 (30-Dec-2021) Creating filesystem with 20971264 4k blocks and 5242880 inodes Filesystem UUID: e590ede8-b85c-4ea5-b197-3f7e9dcfac25 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done --하드추가할경우마운트할 디렉토리를 만든다 --디스크 마운트 # mkdir -p /storage1 # mount /dev/sdb1 /storage1 --용량확인 # df -h /dev/sdb1 118G 24K 112G 1% /storage1 --UUID확인 # blkid /dev/sdb1 /dev/sdb1: UUID="3732619d-888a-4256-9c4c-d174379e6303" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b61c9657-01" --자동마운트 # vi /etc/fstab (추가:12) /dev/disk/by-uuid/3732619d-888a-4256-9c4c-d174379e6303 /storage1 ext4 defaults 0 2 --마운트확인 # mount -a --물리적하드디스크 용량확인 # df -h -T | grep dev/sd /dev/sda2 ext4 2.0G 132M 1.7G 8% /boot /dev/sdb1 ext4 118G 24K 112G 1% /storage1 (3TB일경우에만사용)?3TB는 fdisk 파티셔닝할수없음.parted사용. # parted /dev/sdb (parted) mklabel gpt Yes/No? yes (parted) unit TB (parted) mkpart primary 0.00TB 3.00TB (parted) print (parted) quit ####################################################### --STEP4 : APACHE + PHP 환경설정 --STEP4-1 : APACHE2환경설정 # vi /etc/apache2/apache2.conf (수정:170-주석처리) # # Options Indexes FollowSymLinks # AllowOverride None # Require all granted # (추가:175) Options FollowSymLinks AllowOverride None Require all granted :wq --STEP4-2 : Apache logrotate 로그설정 # cp /etc/logrotate.d/apache2 /etc/logrotate.d/apache2.old # vi /etc/logrotate.d/apache2 /storage1/logs/apache2/*.log { daily rotate 14 size 100M compress delaycompress missingok notifempty create 640 root adm sharedscripts postrotate systemctl reload apache2 > /dev/null endscript } :wq # vi /etc/apache2/sites-available/000-default.conf (수정:13) DocumentRoot /storage1/wwwroot (추가:15)오류페이지처리 ErrorDocument 400 /core/error.html ErrorDocument 401 /core/error.html ErrorDocument 403 /core/error.html ErrorDocument 404 /core/error.html ErrorDocument 500 /core/error.html ErrorDocument 502 /core/error.html ErrorDocument 503 /core/error.html (수정:23) ErrorLog /storage1/logs/apache2/localhost-80-error.log CustomLog /storage1/logs/apache2/localhost-80-access.log combined :wq mkdir -p /storage1/wwwroot mkdir -p /storage1/logs/apache2 chown -R www-data:www-data /storage1/logs/apache2 chmod 750 /storage1/logs/apache2 apache2ctl configtest a2enmod rewrite a2ensite 000-default.conf systemctl restart apache2 --접속경로(/storage1/wwwroot) # vi /storage1/wwwroot/phpinfo.html (접속)http://192.168.56.101:8081/phpinfo.html --STEP4-3 : APACHE2 SSL서버인증서 설치(20251128) --6-1-1. Certbot 설치 --Let's Encrypt 인증서를 자동으로 발급하고 관리해주는 Certbot 패키지를 설치합니다. # apt update # apt upgrade -y # apt install certbot python3-certbot-apache -y --HTTPS 포트(80)가 열려 있는지 확인하고 허용합니다. ufw delete allow 'Apache' ufw allow 'Apache Full' ufw allow 9100/tcp ufw status 상태: 활성 목적 동작 출발 -- -- -- 22/tcp ALLOW Anywhere Apache Full ALLOW Anywhere 9100/tcp ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6) Apache Full (v6) ALLOW Anywhere (v6) 9100/tcp (v6) ALLOW Anywhere (v6) --인증서만 재발급 (서버 설정은 안 건드림) # certbot certonly --webroot -w /storage1/wwwroot -d cube2005.co.kr -d www.cube2005.co.kr What would you like to do? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: Keep the existing certificate for now 2: Renew & replace the certificate (may be subject to CA rate limits) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 Renewing an existing certificate for cube2005.co.kr and www.cube2005.co.kr --인증서만 발급 # certbot certonly --webroot -w /storage1/wwwroot -d cube2005.co.kr -d www.cube2005.co.kr --1: 이메일 입력 (Enter email address) Enter email address (Enter 'c' tocancel): dkjang@naver.com --2: 서비스 약관 동의 (Terms of Service) Please read the Terms of Service at (Y)es/(N)o: y Would you be willing, once your first certificate is successfully (Y)es/(N)o: y --3: EFF 뉴스레터 구독 여부 (Would you be willing...) Would you be willing to share your email address(Y)es/(N)o: n --4: 도메인 소유권 확인 및 인증서 발급 도메인 선택: 목록에서 방금 설정한 도메인 번호 선택 (엔터) Which names would you like to activate HTTPS for? 1: cube2005.co.kr blank to select all options shown (Enter 'c' to cancel): 1 --5: HTTP 리다이렉트 설정 (HTTPS 전환) Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 --Congratulations! You have successfully enabled https://cube2005.co.kr --인증서가 /etc/letsencrypt/live/cube2005.co.kr/ 경로에 저장되었다는 안내가 나옵니다. --(해결)Some challenges have failed. 윈도우방화벽(고급보안이포함된WindowsDefender방화벽)-인바운드규칙 : 80 ZX1_Apache-설정-네트워크-포크포워딩 : apache2(80) ufw allow 'Apache Full' # ls /etc/letsencrypt/live/ --인증서복사 # mkdir -p /mnt/storage1/letsencrypt # cp -a /etc/letsencrypt /mnt/storage1 --Let's Encrypt 인증서는 90일간 유효합니다. Certbot은 자동으로 갱신 타이머를 등록합니다. # certbot renew --dry-run --post-hook "systemctl reload apache2" Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/cube2005.co.kr.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account registered. Simulating renewal of an existing certificate for cube2005.co.kr and www.cube2005.co.kr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # vi /etc/apache2/sites-available/default-ssl.conf ServerAdmin webmaster@localhost #DocumentRoot /var/www/html (추가:6) ServerName cube2005.co.kr ServerAlias www.cube2005.co.kr DocumentRoot /storage1/wwwroot (추가:10)오류페이지처리 ErrorDocument 400 /core/error.html ErrorDocument 401 /core/error.html ErrorDocument 403 /core/error.html ErrorDocument 404 /core/error.html ErrorDocument 500 /core/error.html ErrorDocument 502 /core/error.html ErrorDocument 503 /core/error.html (추가:18) #ErrorLog ${APACHE_LOG_DIR}/error.log #CustomLog ${APACHE_LOG_DIR}/access.log combined ErrorLog /storage1/logs/apache2/cube2005.co.kr-error.log CustomLog /storage1/logs/apache2/cube2005.co.kr-access.log combined (추가:39) #SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLCertificateFile /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/cube2005.co.kr/privkey.pem :wq --mod_ssl 모듈활성화 a2enmod ssl a2ensite default-ssl.conf apache2ctl configtest systemctl restart apache2 (안함)# ufw allow 80,443,9100/tcp --기존 인증서에 도메인 추가 (확장) --기존에 발급받은 도메인들을 모두 포함하고 새로운 도메인을 추가하여 명령어를 실행합니다. # certbot --apache --expand -d cube2005.co.kr -d www.cube2005.co.kr -d new-domain.com --특정 인증서 이름으로 도메인 리스트 교체 --인증서의 이름을 확인한 후 해당 인증서에 연결된 도메인들을 완전히 새로 고침합니다. # certbot certificates --해당 이름을 지정하여 도메인 리스트 업데이트 # certbot --apache --cert-name cube2005.co.kr -d new-domain.com -d www.new-domain.com --도메인을 변경한 후에는 Apache 가상 호스트 설정 파일의 ServerName과 ServerAlias도 새 도메인에 맞게 수정되었는지 확인해야 합니다. -------------------------------------------------------------------------- --STEP4-4 : composer 설치 # apt install -y composer Composer 2.2.6 # mkdir -p /storage1/wwwroot/libs/composer # cd /storage1/wwwroot/libs/composer --설치 스크립트 다운로드 # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" --Composer 2 설치 (PHP 7.4 지원 최신 버전 자동 선택) # php composer-setup.php Composer (version 2.9.5) successfully # composer --version Continue as root/super user [yes]? yes Composer version 2.9.5 2026-01-29 11:40:53 PHP version 8.2.30 (/usr/bin/php8.2) Run the "diagnose" command to get more detailed diagnostics output. --mPDF 라이브러리 설치 # cd /storage1/wwwroot/libs/composer # composer require mpdf/mpdf Continue as root/super user [yes]? yes # chown -R www-data:www-data ./vendor/ --Excel 라이브러리 설치 # cd /storage1/wwwroot/libs/composer # composer require phpoffice/phpspreadsheet Continue as root/super user [yes]? yes -------------------------------------------------------------------------- --STEP4-5 : Node.js WSS 서버 연동 --WSS(Secure WebSocket) 적용 절차 SSL 인증서 준비 chat_server_wss_cube2005.sh 스크립트로 생성된 파일이 이 파일과 같은 경로에 있어야 합니다. mkdir -p /storage1/wwwroot/chat cd /storage1/wwwroot/chat npm install ws mkdir -p /storage1/wwwroot/chat cp -L /etc/letsencrypt/live/cube2005.co.kr/privkey.pem /storage1/wwwroot/chat/cube2005.co.kr_privkey.pem cp -L /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem /storage1/wwwroot/chat/cube2005.co.kr_fullchain.pem chown www-data:www-data /storage1/wwwroot/chat/cube2005.co.kr_privkey.pem chown www-data:www-data /storage1/wwwroot/chat/cube2005.co.kr_fullchain.pem chmod 600 /storage1/wwwroot/chat/cube2005.co.kr_privkey.pem chmod 644 /storage1/wwwroot/chat/cube2005.co.kr_fullchain.pem -------------------------------------------------------------------------- --STEP4-6 : 채팅서버 - MX1_Apache_MySQL(192.168.56.200) # /mnt/storage1/wwwroot/master/chat_server_wss_keycopy.sh 도메인을 입력하세요 (기본: cube2005.co.kr): (엔터) 대상 경로를 입력하세요 (기본: /storage1/wwwroot/chat): (엔터) --www-data 사용자로 전환 # sudo -u www-data -i --설치 경로 확인 www-data@ubuntu:~$ which pm2 /var/www/.npm-global/bin/pm2 www-data@ubuntu:~$ cd /storage1/wwwroot/chat/ pm2 start chat_server_wss_cube2005.js --name chat_server_wss_cube2005 pm2 save --force pm2 startup exit --부팅 시 자동 실행 스크립트 생성 # sudo env PATH=$PATH:/usr/bin /var/www/.npm-global/lib/node_modules/pm2/bin/pm2 startup systemd -u www-data --hp /var/www # pm2-www list # pm2-www restart chat_server_wss_cube2005 --서비스삭제(강제갱신) # pm2-www delete all # pm2-www save --force --PM 명령어 # pm2 start npm --name "" -- start # pm2 start # pm2 list # pm2 save # pm2 resurrect # pm2 startup # pm2 delete all # pm2 kill # pm2 start # pm2 stop # pm2 restart # pm2 restart 5 -n rename # pm2 delete --PM2 삭제 # pm2 stop all # pm2 delete all # pm2 save --force # npm uninstall -g pm2 # which pm2 # rm -rf /root/.pm2 -------------------------------------------------------------------------- --SAMBA설치(20210305) --https://hahaite.tistory.com/312 --윈도우에서 우분투 디렉토리 공유하기 # apt update # apt upgrade -y # apt install -y samba # vi /etc/samba/smb.conf (추가:1) [storage1] comment = storage1 path = /storage1 read only = no writable = yes browsable = yes valid users = root create mask = 0777 directory mask = 0777 [storage2] comment = storage2 path = /storage2 read only = no writable = yes browsable = yes valid users = root create mask = 0777 directory mask = 0777 :wq [storage1] comment = storage1 #공유폴더설명 path = /storage1 #공유할폴더경로 read only = no #읽기전용아님 writable = yes #쓰기가능 browsable = yes #폴더내용탐색가능 valid users = root #접속가능사용자계정 create mask = 0777 #파일권한 directory mask = 0777 #디렉토리권한 # smbpasswd -a root New SMB password: @서버암호 Retype new SMB password: @서버암호 Added user root. # systemctl restart smbd # ufw allow 139,445/tcp --윈도우설정 1. 서버관리자-역할및기능추가-기능선택-SMB1.0/CIFS File Sharing Support 2. gpedit.msc(로컬그룹정책편집기) 컴퓨터구성-관리템플릿-네트워크-Lanman워크스테이션-보안되지않은게스트로그온사용:사용 3. 네트워크 폴더 자격 증명 삭제(오류일경우 액세스가 거부되었습니다) > net use \\192.168.56.254\storage1 /delete --윈도우탐색기 계정 : root 암호 : @서버암호 (체크)내자격증명기억 --우분투에서 윈도우 폴더 공유하기 # apt install -y cifs-utils # vi /etc/fstab //192.168.56.101/storage1 /mnt/storage2 cifs username=administrator,password=@서버암호 0 0 # mount -a -------------------------------------------------------------------------- --STEP5 : MySQL설정 --STEP5-1 : MySQL 설치 # apt update # apt upgrade -y # apt install -y mysql-server mysql-client php-mysql # mysql -V mysql Ver 8.0.44-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu)) ####################################################### --MySQL 접속 권한 및 계정 설정(@서버암호) # mysql -uroot -p@서버암호 -- 유저 정보 확인 mysql> SELECT HOST, USER, PLUGIN FROM mysql.user; -- 모든 IP(%)에서 접속 가능한 root 계정 생성 및 권한 부여 mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; -- 로컬 접속 플러그인 및 비밀번호 업데이트 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '@서버암호'; -- root 계정을 모든 호스트(%)에서 접속 가능 mysql> ALTER USER 'root'@'%' IDENTIFIED BY '@서버암호'; -- 설정 반영 및 종료 mysql> FLUSH PRIVILEGES; mysql> EXIT; -------------------------------------------------------------------------- --STEP5-2 : 데이터 저장경로변경(/var/lib/mysql -> /storage1/mysql) --STEP5-3 : 로그 저장경로변경 (/var/log/mysql -> /storage1/logs/mysql) -- 서비스 중지 # systemctl stop mysql # systemctl status mysql --디렉토리 생성 mkdir -p /storage1/mysql/ mkdir -p /storage1/logs/mysql/ chown -R mysql:mysql /storage1/mysql chown -R mysql:mysql /storage1/logs/mysql chmod 750 /storage1/mysql chmod 750 /storage1/logs/mysql rsync -av /var/lib/mysql/ /storage1/mysql/ -- MySQL 설정 업데이트 # vi /etc/mysql/mysql.conf.d/mysqld.cnf [mysqld] (추가:15) datadir = /storage1/mysql bind-address = 0.0.0.0 character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init-connect = 'SET NAMES utf8mb4' innodb_file_per_table = 1 log_error = /storage1/logs/mysql/mysql.log slow_query_log = 1 slow_query_log_file = /storage1/logs/mysql/mysql-slow.log (주석:40) #bind-address = 127.0.0.1 #mysqlx-bind-address = 127.0.0.1 (주석:71) #log_error = /var/log/mysql/error.log ---DX1_MySQL일경우--- # InnoDB 메모리 innodb_buffer_pool_size = 12G innodb_buffer_pool_instances = 8 # InnoDB 로그 innodb_log_file_size = 2G innodb_log_buffer_size = 128M # InnoDB I/O innodb_read_io_threads = 8 innodb_write_io_threads = 8 innodb_flush_log_at_trx_commit = 2 innodb_flush_method = O_DIRECT # 임시 테이블 tmp_table_size = 512M max_heap_table_size = 512M # 정렬 / 조인 버퍼 join_buffer_size = 4M sort_buffer_size = 4M # 연결 thread_cache_size = 32 max_connections = 300 :wq --로그 파일 생성 touch /storage1/logs/mysql/mysql.log touch /storage1/logs/mysql/mysql-slow.log chown mysql:mysql /storage1/logs/mysql/mysql.log chown mysql:mysql /storage1/logs/mysql/mysql-slow.log chmod 640 /storage1/logs/mysql/mysql.log chmod 640 /storage1/logs/mysql/mysql-slow.log --Mysql logrotate 로그설정 # cp /etc/logrotate.d/mysql-server /etc/logrotate.d/mysql-server.old # vi /etc/logrotate.d/mysql-server /storage1/logs/mysql/mysql.log /storage1/logs/mysql/mysql-slow.log { daily rotate 7 size 50M missingok notifempty create 640 mysql adm compress sharedscripts postrotate test -x /usr/bin/mysqladmin || exit 0 mysqladmin --defaults-file=/etc/mysql/debian.cnf flush-logs endscript } :wq --STEP5-4 : AppArmor 보안 설정 (필수) # vi /etc/apparmor.d/usr.sbin.mysqld (수정:60) # Allow data dir access /storage1/mysql/ r, /storage1/mysql/** rwk, (수정:74) # Allow log file access /storage1/logs/mysql/mysql.log rw, /storage1/logs/mysql/mysql-slow.log rw, /storage1/logs/mysql/ r, /storage1/logs/mysql/** rwk, :wq -- Alias 설정 (권장) # vi /etc/apparmor.d/tunables/alias alias /var/lib/mysql/ -> /storage1/mysql/, :wq # systemctl reload apparmor # systemctl restart mysql --외부 접속허용 # ufw allow 3306/tcp --특정 IP만 허용하는 경우 # ufw allow from 183.111.185.242 to any port 3306 -- 데이터 경로 확인 # mysql -uroot -p@서버암호 -e"SELECT @@datadir" mysql: [Warning] Using a password on the command line interface can be insecure. +-----------------+ | @@datadir | +-----------------+ | /storage1/mysql/| +-----------------+ -- 로그 경로 확인 # mysql -u root -p@서버암호 -e "SHOW VARIABLES LIKE '%log_error%';" mysql: [Warning] Using a password on the command line interface can be insecure. +----------------------------+----------------------------------------+ | Variable_name | Value | +----------------------------+----------------------------------------+ | binlog_error_action | ABORT_SERVER | | log_error | /storage1/logs/mysql/mysql.log | | log_error_services | log_filter_internal; log_sink_internal | | log_error_suppression_list | | | log_error_verbosity | 2 | +----------------------------+----------------------------------------+ -------------------------------------------------------------------------- --데이터베이스최적화 --DB전체최적화 # mysqlcheck -uroot -p@서버암호 -o --all-databases ---DB지정최적화 # mysqlcheck -uroot -p@서버암호 -o {DATABASE_NAME} ---TABLE최적화 mysql> OPTIMIZE TABLE {DATABASE_NAME}.{TABLE_NAME}; --데이터베이스복원 # mysql -uroot -p@서버암호 mysql> CREATE DATABASE {DATABASE_NAME} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; # mysql -uroot -p@서버암호 {DATABASE_NAME} < /storage1/backup/20260205/{DATABASE_NAME}.sql # mysql -uroot -p@서버암호 mysql> CREATE DATABASE YELLOW DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; # mysql -uroot -p@서버암호 YELLOW < /storage1/backup/20260205/YELLOW.sql --데이터베이스백업 # mysqldump -uroot -p@서버암호 {DATABASE_NAME} > /storage1/backup/20260205/{DATABASE_NAME}.sql # mysqldump -uroot -p@서버암호 YELLOW > /storage1/backup/20260205/YELLOW.sql --데이터베이스자동백업:파일생성 # vi /storage1/backup/mysql_backup.sh #!/bin/bash DATE=$(date +%Y%m%d) BACKUP_DIR=/storage1/backup/$DATE/ mysqldump -uroot -p@서버암호 --databases {DATABASE_NAME} > $BACKUP_DIR"{DATABASE_NAME}".sql :wq #3일지난 백업은 삭제한다 #-ctime n 옵션은 파일의 퍼미션을 마지막으로 변경시킨 날짜를 기준으로 파일을 찾아낸다. #+n : n일 또는 n일 이전에 퍼미션이 변경된 파일 #-n : 오늘 부터 n일 전 사이에 퍼미션이 변경된 파일 #n : 정확히 n일 전에 퍼미션이 변경된 파일 find $BACKUP_DIR"*.sql -ctime +3 -exec rm -f {} \; # chmod 755 mysql_backup.sh # ./mysql_backup.sh # bash mysql_backup.sh --데이터베이스자동백업:스케줄등록 # crontab -e Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano 3. /usr/bin/vim.basic <---- vi 4. /usr/bin/vim.tiny Choose 1-4 [2]: 4 --vi (추가)0 1 * * * /storage1/wwwroot/master/data_tools_master.sh # date # systemctl restart cron # crontab -r //삭제 # 분(0-59) 시(0-23) 일(1-31) 월(1-12) 요일(0-6:0일요일-6토요일) 수행명령어 --0,10,20,30,40,50분 실행 0,10,20,30,40,50 * * * * bash /storage1/wwwroot/master/data_tools_master.sh --1-10일 실행 0 0 1-10 * * bash /storage1/wwwroot/master/data_tools_master.sh --MySQL 재설치 --MySQL 삭제 # apt remove --purge mysql* # systemctl status mysql # systemctl restart mysql -------------------------------------------------------------------------- --20210109:데이터베이스 경로변경 절대안됨(/storage1/mysql) --20240327:윈도우공유폴더일경우(오류발생:chown권한) root@ubuntu:~# systemctl restart mysql Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. root@ubuntu:~# systemctl restart mysql root@ubuntu:/# mysql -uroot -p@서버암호 -e"SELECT @@datadir" mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) root@ubuntu:~# systemctl restart mysql --20260111:부팅 초기에 아직 mount 안 된 상태 Apache 프로세스가 I/O 대기 상태(D 상태) 에 빠짐 INFO: task apache2:1599 blocked for more than 120 seconds Apache DocumentRoot, ErrorLog, CustomLog가 그 경로를 사용 부팅 초기에 아직 mount 안 된 상태 --보안 유지 (히스토리 삭제) cat /dev/null > ~/.bash_history && history -c ####################################################### --STEP6 : 시스템 복제 --STEP6-1 : 가상머신복제하기(60분) 머신 - 복제 이름: AX1_Apache, DX1_MySQL, DX2_MySQL, DX3_MySQL, MX1_Apache_MySQL 경로: D:\VMs\VBOX (체크)하드웨어 UUID 유지 --완료 AX1_Apache(192.168.56.101) RAM : 6GB, CPU 4개, Storage1(240GB) --네트워크-어댑터1 : NAT-포트포워딩 apache2 TCP (호스트포트)80 (게스트포트)80 #certbot 인증서포트 열려있어야 한다 apache2_ssl TCP (호스트포트)443 (게스트포트)443 DX1_MySQL(192.168.56.201) RAM : 12GB, CPU 6개, Storage1(120GB) DX2_MySQL(192.168.56.202) RAM : 4GB, CPU 4개, Storage1(120GB) DX3_MySQL(192.168.56.203) RAM : 4GB, CPU 1개, Storage1(25GB) MX1_Apache_MySQL(192.168.56.200) RAM : 4GB, CPU 2개, Storage1(120GB) --네트워크-어댑터1 : NAT-포트포워딩 webchat TCP (호스트포트)9100 (게스트포트)9100 --네트워크도구설치 # ifconfig ---유동IP일경우 # vi /etc/netplan/01-netcfg.yaml network: ethernets: enp0s3: dhcp4: true dhcp4-overrides: route-metric: 100 enp0s8: dhcp4: no addresses: - 192.168.56.254/24 routes: [] version: 2 :wq netplan generate netplan apply -------------------------------------------------------------------------- --STEP6-1 : APACHE2 개발서버 환경설정일경우:20260207 --6-1-1.웹서버설정 # vi /etc/php/8.2/apache2/php.ini (수정:508)display_errors = On #PHP 실행 중 발생하는 에러, 경고, 알림 등을 브라우저 화면출력 :wq # vi /etc/apache2/apache2.conf (수정:175) # vi /etc/apache2/sites-available/000-default.conf (수정:13)DocumentRoot /mnt/storage1/wwwroot # vi /etc/apache2/sites-available/default-ssl.conf (수정:7)DocumentRoot /mnt/storage1/wwwroot (수정:26) ErrorLog /storage1/logs/apache2/waitbook.co.kr-error.log CustomLog /storage1/logs/apache2/waitbook.co.kr-access.log combined (수정:47) SSLCertificateFile /etc/letsencrypt/live/waitbook.co.kr/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/waitbook.co.kr/privkey.pem -- 인증서만 재발급 (Apache DocumentRoot 경로확인) # certbot certonly --webroot -w /mnt/storage1/wwwroot -d waitbook.co.kr -d www.waitbook.co.kr --인증서복사 # mkdir -p /mnt/storage1/letsencrypt # cp -a /etc/letsencrypt /mnt/storage1 --채팅서버_인증서복사 - AX1_Apache(192.168.56.101) # /mnt/storage1/wwwroot/master/chat_server_wss_keycopy.sh 도메인을 입력하세요 (기본: cube2005.co.kr): waitbook.co.kr 대상 경로를 입력하세요 (기본: /storage1/wwwroot/chat): /mnt/storage1/wwwroot/chat --6-1-2.채팅서버설정 --채팅서버_실행 - MX1_Apache_MySQL(192.168.56.200) --www-data 사용자로 전환 # sudo -u www-data -i www-data@ubuntu:~$ which pm2 /var/www/.npm-global/bin/pm2 www-data@ubuntu:~$ cd /mnt/storage1/wwwroot/chat/ pm2 start chat_server_wss_waitbook.js --name chat_server_wss_waitbook pm2 save --force pm2 startup exit # pm2-www list # pm2-www restart chat_server_wss_waitbook --소유권 변경 : 해당 디렉토리에 대한 쓰기 권한을 가지고 있어야 합니다. # mkdir -p /mnt/storage1/wwwroot/files # sudo chown -R www-data:www-data /storage1/wwwroot # sudo chmod -R 755 /storage1/wwwroot # sudo chown -R www-data:www-data /storage1/wwwroot/files # sudo chown -R www-data:www-data /storage1/wwwroot/files_misc # sudo chown -R www-data:www-data /storage1/wwwroot/files_logs # sudo chown -R www-data:www-data /storage1/wwwroot/server # crontab -e Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano 3. /usr/bin/vim.basic <---- vi 4. /usr/bin/vim.tiny Choose 1-4 [2]: 4 --vi (추가)00 01 * * * sudo -u www-data -i pm2 restart chat_server_wss_cube2005 00 10 * * * sudo -u www-data -i pm2 restart chat_server_wss_waitbook # systemctl restart cron -------------------------------------------------------------------------- --STEP7 : 시스템 --STEP7-1 : 가상시스템 내보내기 파일-가상시스템 내보내기... Virtual machines(가상머신선택) (다음) Format settings(가상머신형식) 형식 : Open Virtualzation Format 1.0 파일 : D:\VMs\VBOX\ZX1_Apache_20250205.ova Mac주소정책 : 모든네트워크어댑터 MAC주소포함 추가옵션 : (체크)Manifest파일쓰기 가상시스템설정 (Finish) --STEP7-2 : 가상시스템 가져오기 파일-가상시스템 가져오기... 가져올 가상 시스템 원본 : 로컬파일시스템 파일 : D:\VMs\VBOX\ZX1_Apache_20260205.ova (다음) 가상시스템설정 이름 : ZX1_Apache_20260205 가상디스트이미지 : ZX1_Apache_20260205-disk001.vmdk 머신기본폴더 : D:\VMs\VBOX MAC주소정책 : NAT네트워크어댑태MAC주소만포함 추가옵션 : (체크)VDI로 하드디스크 가져오기 --STEP7-3 : 윈도우부팅할경우 VBox 자동실행 --작업스케줄러 VMBox HeadlessStart : 시스템시작시 VMBox Savestate : 이벤트상태-기본-로그:시스템,원본:User32,이벤트1074 --VirtaulBOX 명령어 --C:\VMs\HeadlessStart_OracleVMVirtualBox.bat "VBoxManage.exe" startvm "vmname" [--type gui|sdl|headless|separate] "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "AX1_Apache(192.168.56.101)" --type headless "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "DX1_MySQL(192.168.56.201)" --type headless "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "DX2_MySQL(192.168.56.202)" --type headless "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "DX3_MySQL(192.168.56.203)" --type headless "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "MX1_Apache_MySQL(192.168.56.200)" --type headless --C:\VMs\Savestate_OracleVMVirtualBox.bat "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "AX1_Apache(192.168.56.101)" savestate "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "DX1_MySQL(192.168.56.201)" savestate "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "DX2_MySQL(192.168.56.202)" savestate "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "DX3_MySQL(192.168.56.203)" savestate "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "MX1_Apache_MySQL(192.168.56.200)" savestate --작업스케줄러 이름: VMBox HeadlessStart 트리거: 시작할때 자세히: 시스템 시작시 동작: 프로그램시작 프로그램: D:\VMs\Setup\HeadlessStart_OracleVMVirtualBox.bat 시작위치: D:\VMs\Setup\ 이름: VMBox Savestate 트리거: 이벤트상태 설정: 기본 로그: 시스템 원본: User32 이벤트: 1074 (체크)사용 동작: 프로그램시작 프로그램: D:\VMs\Setup\Savestate_OracleVMVirtualBox.bat 시작위치: D:\VMs\Setup\ --윈도우방화벽설정 고급보안이포함된WindowsDefender방화벽 (80,443,9100)CUBE 프로토콜및포트:로컬포트:80,443,9100 -------------------------------------------------------------------------- --STEP7-4 : 고정 디스크와 동적 디스크를 변환하는 방법 VirtualBox에서 .ova 파일을 가져올 때 디스크를 고정 크기(Fixed Size)로 설정하려면, 가져오기 시 동적 할당으로 설정된 가상 디스크 파일을 생성한 후 VBoxManage 명령어를 사용하여 고정 크기로 변환해야 한다 > cd C:\Program Files\Oracle\VirtualBox > VBoxManage.exe list hdds --동적에서 고정으로 변환하는 명령 > VBoxManage.exe clonemedium disk "C:\VMs\VBOX\AX1_Apache\AX1_Apache_std.vdi" "C:\VMs\VBOX\AX1_Apache\AX1_Apache_fix.vdi" -variant Fixed --고정에서 동적으로 변환하는 명령 > VBoxManage.exe clonemedium disk "C:\VMs\VBOX\AX1_Apache\AX1_Apache_fix.vdi" "C:\VMs\VBOX\AX1_Apache\AX1_Apache_std.vdi" -variant Standard --STEP7-5 : 하드디스크 용량늘리기 파일-도구-미디어-하드디스크-(가상미디어선택)-속성-크기변경: 확장 # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 253:0 0 11.5G 0 lvm / sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 60G 0 part /storage1 # sudo parted /dev/sdb GNU Parted 3.4 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. # (parted) print Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdb: 85.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 64.4GB 64.4GB primary ext4 # (parted) resizepart 1 100% Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue? Yes/No? yes # (parted) quit Information: You may need to update /etc/fstab. # sudo resize2fs /dev/sdb1 resize2fs 1.46.5 (30-Dec-2021) Filesystem at /dev/sdb1 is mounted on /storage1; on-line resizing required old_desc_blocks = 8, new_desc_blocks = 10 The filesystem on /dev/sdb1 is now 20971264 (4k) blocks long. # df -h /dev/sdb1 79G 298M 75G 1% /storage1 # lsblk sdb 8:16 0 80G 0 disk └─sdb1 8:17 0 80G 0 part /storage1 -------------------------------------------------------------------------- --STEP7-6 : 하드디스크추가(하드추가:/storage2) 파일-도구-미디어-하드디스크-만들기 위치: D:\VMs\VBOX\AX1_Apache(192.168.56.101)\AX1_Apache_Storage2.vdi 크기: 840.00 GB (체크)미리전체크기할당 --완료 --파티션 확인 # fdisk -l Disk /dev/sdc: 840 GiB, 901943132160 bytes, 1761607680 sectors --디스크인식 확인 # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 63.8M 1 loop /snap/core20/2686 loop1 7:1 0 63.8M 1 loop /snap/core20/2717 loop2 7:2 0 87M 1 loop /snap/lxd/29351 loop3 7:3 0 91.4M 1 loop /snap/lxd/36918 loop4 7:4 0 38.8M 1 loop /snap/snapd/21759 loop5 7:5 0 48.1M 1 loop /snap/snapd/25935 sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 253:0 0 11.5G 0 lvm / sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 120G 0 part /storage1 sdc 8:32 0 840G 0 disk sr0 11:0 1 50.7M 0 rom --파티션 생성 # fdisk /dev/sdc Command (m for help): n #새 파티션 Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-167772159, default 2048): (엔터) Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): (엔터) Command (m for help): w --- # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdc 8:32 0 120G 0 disk └─sdc1 8:33 0 120G 0 part --포맷 # mkfs.ext4 /dev/sdc1 mke2fs 1.46.5 (30-Dec-2021) Creating filesystem with 20971264 4k blocks and 5242880 inodes Filesystem UUID: e590ede8-b85c-4ea5-b197-3f7e9dcfac25 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done --하드추가할경우마운트할 디렉토리를 만든다 --디스크 마운트 # mkdir -p /storage2 # mount /dev/sdc1 /storage2 --용량확인 # df -h /dev/sdc1 79G 24K 75G 1% /storage2 --UUID확인 # blkid /dev/sdc1 /dev/sdc1: UUID="11b966cd-e0b4-448f-9577-67def38e94b5" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6c2d338c-01" --자동마운트 # vi /etc/fstab (추가:13) /dev/disk/by-uuid/11b966cd-e0b4-448f-9577-67def38e94b5 /storage2 ext4 defaults 0 2 --마운트확인 # mount -a --물리적하드디스크 용량확인 # df -h -T | grep dev/sd /dev/sda2 ext4 2.0G 132M 1.7G 8% /boot /dev/sdb1 ext4 118G 804M 111G 1% /storage1 /dev/sdc1 ext4 826G 28K 784G 1% /storage2 --bind mount(리눅스 마운트 방식) --데이터이동 # sudo mkdir -p /storage2/wwwroot/files # sudo mv /storage1/wwwroot/files/* /storage2/wwwroot/files/ --바인드 마운트 # sudo mount --bind /storage2/wwwroot/files /storage1/wwwroot/files # sudo chown -R www-data:www-data /storage2/wwwroot/files --자동마운트 # vi /etc/fstab (추가:14) /storage2/wwwroot/files /storage1/wwwroot/files none bind 0 0 --마운트확인 # sudo mount -a --(선택)unmount # sudo umount /storage1/wwwroot/files -------------------------------------------------------------------------- 20260210:(해결)[FAILED] A start job is running for /dev/disk/by-uuid/.... Ubuntu가 fstab에 등록된 디스크(UUID)를 마운트하려고 기다리는데, 해당 디스크가 존재하지 않거나 UUID가 변경되어 찾지 못하는 상태입니다. Give root password for maintenance (or press Control-D to continue) : @서버암호 해결방법1 : 하드디스크추가(/storage1) # fdisk -l # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 25G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 2G 0 part /boot └─sda3 8:3 0 23G 0 part └─ubuntu--vg-ubuntu--lv 253:0 0 11.5G 0 lvm / sdb 8:16 0 60G 0 disk # fdisk /dev/sdb Command (m for help): n Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-167772159, default 2048): (엔터) Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): (엔터) Command (m for help): w # mkfs.ext4 /dev/sdb1 # mkdir -p /storage1 # mount /dev/sdb1 /storage1 # df -h # blkid /dev/sdb1 /dev/sdb1: UUID="b3ff74ae-2953-488b-a653-6f5e3e95fe31" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b61c9657-01" # vi /etc/fstab /dev/disk/by-uuid/b3ff74ae-2953-488b-a653-6f5e3e95fe31 /storage1 ext4 defaults 0 2 :wq # shutdown -r now 해결방법2 : 주석처리 부팅후 수정하기 # vi /etc/fstab (주석처리) #/dev/disk/by-uuid/92e3bf92-50aa-4574-8568-c1fb2ac75cb3 /storage1 ext4 defaults 0 2 :wq # shutdown -r now -------------------------------------------------------------------------- --STEP7-7 : APACHE2 멀티도메인+서브도메인 https://velog.io/@yjj4899/ubuntu-20.04-apache2-설치부터-설정까지 /etc/apache2/sites-available/cube2005.co.kr.conf # cd /etc/apache2/sites-available/ # cp 000-default.conf cube2005.co.kr.conf # vi cube2005.co.kr.conf ServerAdmin dkjang@naver.com ServerName cube2005.co.kr ServerAlias cube2005.co.kr www.cube2005.co.kr DocumentRoot /storage1/wwwroot/www.cube2005.co.kr ErrorLog /storage1/logs/apache2/cube2005.co.kr-error.log CustomLog /storage1/logs/apache2/cube2005.co.kr-access.log combined ServerName app.cube2005.co.kr DocumentRoot /storage1/wwwroot/app.cube2005.co.kr :wq # vi cube2005.co.kr.conf ServerAdmin webmaster@localhost ServerName cubeapp.co.kr ServerAlias cubeapp.co.kr www.cubeapp.co.kr DocumentRoot /storage1/wwwroot/www.cubeapp.co.kr ErrorLog /storage1/logs/apache2/cubeapp.co.kr-error.log ErrorLog /storage1/logs/apache2/cubeapp.co.kr-access.log ServerName app.cubeapp.co.kr DocumentRoot /storage1/wwwroot/app.cubeapp.co.kr :wq --000-default.conf 비활성 # a2dissite 000-default.conf --default-ssl.conf 비활성 # a2dissite default-ssl.conf --cube2005.co.kr.conf 활성화 # a2ensite cube2005.co.kr.conf --cube2005.co.kr.conf 활성화 # a2ensite cube2005.co.kr.conf # systemctl restart apache2 https://my.hosting.kr/domains 네임서버추가 A @ 183.111.185.242 A app 183.111.185.242 A www 183.111.185.242 --STEP7-8 : APACHE2 다중포트설정 # vi /etc/apache2/ports.conf #Listen 80 (추가)Listen 8083 :wq # vi /etc/apache2/sites-available/000-default.conf (수정) ProxyPreserveHost On ProxyPass / http://localhost:8083/ ProxyPassReverse / http://localhost:8083/ ErrorLog /storage1/logs/apache2/localhost-8083-error.log CustomLog /storage1/logs/apache2/localhost-8083-access.log combined :wq # systemctl restart apache2 -------------------------------------------------------------------------- --기본명령어 shutdown -P now :전원종료 shutdown -r now :재부팅(reboot) --디렉토리 삭제 rm -rf {디렉토리명} rm -rf * --Alias 설정하기 vi ~/.bashrc alias shutn='shutdown -h now' -------------------------------------------------------------------------- --20210802 : editplus(에디트플러스)FTP설정 파일-FTP-FTP설정 설명 : 183.111.185.242 FTP서버 : 183.111.185.242 Username : root Pasword : @서버암호 디렉토리 : /storage1/wwwroot 고급옵션(선택) : 암호화 : sftp --SSH Secure File Transfer Client File-Connect... Profile : 183_111_185_242 -connection Hostname : 183.111.185.242 Username : root Portnumber : 22 -Favorite folder Home folder : /storage1/wwwroot Profile : 192_168_56_101 -connection Hostname : 192.168.56.101 Username : root Portnumber : 22 -Favorite folder Home folder : /storage1/wwwroot -------------------------------------------------------------------------- --APACHE2 SSL서버인증서 직접설치 https://www.sslcert.co.kr/ GOGETSSL : 7,000원 # vi /etc/apache2/sites-available/cube2005.co.kr.conf RedirectPermanent / https://www.cube2005.co.kr ServerAdmin dkjang@naver.com ServerName cube2005.co.kr ServerAlias cube2005.co.kr www.cube2005.co.kr DocumentRoot /storage1/wwwroot/www.cube2005.co.kr ErrorLog /storage1/wwwroot/www.cube2005.co.kr/config/log/cube2005.co.kr-error.log CustomLog /storage1/wwwroot/www.cube2005.co.kr/config/log/cube2005.co.kr-access.log combined ServerAdmin dkjang@naver.com ServerName www.cube2005.co.kr:443 DocumentRoot /storage1/wwwroot/www.cube2005.co.kr ErrorLog /storage1/wwwroot/www.cube2005.co.kr/config/log/cube2005.co.kr-ssl-error.log TransferLog /storage1/wwwroot/www.cube2005.co.kr/config/log/cube2005.co.kr-ssl-access.log SSLEngine on SSLCertificateKeyFile /storage1/wwwroot/www.cube2005.co.kr/config/ssl-2022/cube2005.co.kr_20220520AE34A.key.pem SSLCertificateFile /storage1/wwwroot/www.cube2005.co.kr/config/ssl-2022/cube2005.co.kr_20220520AE34A.crt.pem SSLCertificateChainFile /storage1/wwwroot/www.cube2005.co.kr/config/ssl-2022/RootChain/chain-bundle.pem SSLCACertificateFile /storage1/wwwroot/www.cube2005.co.kr/config/ssl-2022/RootChain/AAACertificateServicesRoot.crt.pem ServerName app.cube2005.co.kr DocumentRoot /storage1/wwwroot/app.cube2005.co.kr :wq # a2enmod ssl #mod_ssl 모듈활성화 # a2ensite cube2005.co.kr.conf #활성화 # systemctl restart apache2 --20230621 : 인증서갱신 /etc/apache2/sites-available/cube2005.co.kr.conf : 인증서파일경로와 파일명수정 # systemctl restart apache2 -------------------------------------------------------------------------- --20200618 : Ubuntu에서 메일서버 만들기(Postfix) --https://lasthackers.com/ubuntu에서-메일서버-만들기postfix/ # apt install postfix System Mail Name : cube2005.co.kr # dpkg-reconfigure postfix # systemctl restart postfix # netstat -ntl | grep 25 # vi /etc/postfix/main.cf --(VMWare)20180620 : 외부접속 VMWare Workstation Network Adapter : Custom:Specific virtual network : VMnet0(Auto-bridging) --(VMWare)20231106 : 우분투 하드용량늘리기 https://minddong.tistory.com/49 # df -h /dev/sda2 9.8G 9.2G 45M 100% / # parted (parted) print Disk /dev/sda: 21.5GB 2 2097kB 10.7GB 10.7GB ext4 (parted) resizepart Partition number? 2 Warning: Partition /dev/sda2 is being used. Are you sure you want to continue? Yes/No? yes End? [10.7GB]? 21.5G (parted) q # resize2fs -p /dev/sda2 resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/sda2 is mounted on /; on-line resizing required old_desc_blocks = 2, new_desc_blocks = 3 The filesystem on /dev/sda2 is now 5242363 (4k) blocks long. # df -h /dev/sda2 20G 9.2G 9.5G 50% /