การติดตั้ง mytop เพื่อให้ monitor process : mysql 1. ทำการติดตั้ง Package epel-release [root@system ~]#yum install epel-release 2. ทำการติดตั้ง Mytop เพื่อใช้ในการ Monitor การทำงานของ mysql database [root@system ~]#yum install mytop 3. ทำการแก้ไข Config mytop [root@system ~]#nano -w /root/.mytop db=mysqldelay=2 4. ทดสอบการใช้งานคำสั่ง mytop จะพบ process mysql database ที่มีการ query อยู่ปัจจุบัน MySQL on localhost (5.7.27) up 6+20:23:37 [13:43:04] Queries: 18.0 qps: 0 Slow: 0.0 Se/In/Up/De(%): 44286894/00/00/00 qps now: 1 Slow qps: 0.0 Threads: 1 ( 1/ 9) 00/00/00/00 Key Efficiency: 99.9% Bps in/out: 0.0/ 0.2 Now in/out: 21.0/ 5.1k Id User Host/IP DB Time Cmd Query or State -- ---- ------- -- ---- --- ---------- 491510 root localhost mysql 0 Query show full processlist
วิธีติดตั้งและต่ออายุ Free SSL (Let's Encrypt ) แบบ Manual 1. ทำการ Verify website เพื่อ Generate Key , CA และ Certificate โดยสามารถทำการ Verify website ได้ที่ https://www.sslforfree.com/ - ให้ทำการกรอกข้อมูล Domain ที่ต้องการติดตั้ง Free ssl - ทำการเลือก Manual Verification - จากนั้นทำการ Download file เพื่อ Verify domain โดยให้ทำการ Download file และนำไฟล์ไปไว้ที่ Part file ที่เรียกใช้งาน Website ทั้งนี้รูปแบบการ Verify จะต้องทำการ Upload file ไปไว้ที่ /.well-known/acme-challenge/filename ตัวอย่างเช่นทำการ Upload file name : JUUOCxh14V0Q-yDbvR8Lsnr5nvWe2z26_y-nrRxBjaE นำไปไว้ที่ Part file : /var/www/html//.well-known/acme-challenge/JUUOCxh14V0Q-yDbvR8Lsnr5nvWe2z26_y-nrRxBjaE 2. เมื่อทำการ Verify website เรียบร้อยแล้วจะได้รับ Key , CA และ Certificate 3. SSH เข้าที่ Server ที่ต้องการ จากนั้นให้การสร้างไฟล์เพื่อเก็บข้อมูล Key , CA และ Certificate ที่ได้รับมา [root@system ~]# mkdir /etc/httpd/private[root@system ~]# cd /etc/httpd/private[root@system ~]# nano -w cafilename.ca-bundle[root@system ~]# nano -w certificatefilename.crt[root@system ~]# nano -w keyfilename.key 4. ทำการแก้ไขไฟล์ Config SSL เพื่อให้สามารถเรียกใช้ Key , CA และ Certificate ที่ได้รับมาได้ [root@system ~]# nano -w /etc/httpd/conf.d/ssl.conf - ทำการแก้ไข Part file Key # Server Private Key:# If the key is not combined with the certificate, use this# directive to point at the key file. Keep in mind that if# you've both a RSA and a DSA private key you can configure# both in parallel (to also allow the use of DSA ciphers, etc.)#SSLCertificateKeyFile /etc/pki/tls/private/localhost.keySSLCertificateKeyFile /etc/httpd/ssl/private/ezazbweb1.key - ทำการแก้ไข Part file Certificate # Server Certificate:# Point SSLCertificateFile at a PEM encoded certificate. If# the certificate is encrypted, then you will be prompted for a# pass phrase. Note that a kill -HUP will prompt again. A new# certificate can be generated using the genkey(1) command.#SSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateFile /etc/httpd/ssl/private/ezazbweb1.crt - ทำการแก้ไข Part file CA # Certificate Authority (CA):# Set the CA certificate verification path where to find CA# certificates for client authentication or alternatively one# huge file containing all of them (file must be PEM encoded)#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crtSSLCACertificateFile /etc/httpd/ssl/private/ezazbweb1.ca-bundle 5. ทำการ Restart apache service [root@system ~]# systemctl restart httpd
วิธีการ Custom logrotate on Ubuntu server 1. ssh login เข้าที่เครื่องที่ต้องการ 2. ทำการสร้างไฟล์ที่ต้องการ Custom config [root@system ~]# cd /etc/logrotate.d/ [root@system ~]# touch mongodb 3. ทำการ Config part และช่วงเวลาที่ต้องการทำ logrotate [root@system ~]# nano -w /etc/logrotate.d/mongodb /var/log/mongodb/*.log { *** Part ที่ต้องการทำ Logrotate *** weekly missingok rotate 14 *** ช่วงเวลาในการเก็บ Logrotate หน่วยเป็นสัปดาห์ *** compress notifempty } 4. ทำการ Force update Logrotate [root@system ~]# logrotate /etc/logrotate.conf --state /var/lib/logrotate/logrotate.status --verbose --force 5. ตรวจสอบ logrotate.status จะพบ validate log ที่ทำการ Custom ขึ้นมา [root@system ~]# more /var/lib/logrotate/logrotate.status "/var/log/nginx/error.log" 2019-7-15-3:34:1"/var/log/mongodb/mongod.log" 2019-7-3-2:42:56"/var/log/yum.log" 2019-6-15-3:7:1"/var/log/rabbitmq/rabbit@eza_upgrade.log" 2019-5-24-3:30:1"/var/log/boot.log" 2019-1-9-16:44:1"/var/log/rabbitmq/rabbit@eza.log" 2019-7-14-3:48:1
1. ssh login เข้าที่เครื่อง Directadmin ที่ต้องการ 2. ทำการ Download script ในการแปลงข้อมูล [root@system ~]# wget https://www.pusathosting.com/file/da.cpanel.import.9.4.tar.gz 3. ทำการสร้าง Directory เพื่อเก็บข้อมูล [root@system ~]# mkdir import export 4. ไปที่เครื่อง cPanel ที่ต้องการ Migrate data ให้ทำการทำ Full backup ของ Account ที่ต้องการโดยสามารถดำเนินการได้ 2 วิธี - วิธีที่ 1 ทำการ Run script เพื่อทำการ Backup [root@system ~]# /scripts/pkgacct USERNAME - วิธีที่ 2 ทำการ Full backup ผ่าน Tools บน cPanel 5. ทำการ rsync data จาก cPanel ไปที่ Directadmin (Run ที่เครื่อง cPanel) [root@system ~]# rsync -av /home/cpmove-USER.tar.gz root@x.x.x.x:/root/import 6. ทำการแก้ไข Config ที่ไฟล์ defaults.conf ip=203.78.103.158 *** แก้ไข ip server ***ns1=ns1.cdnex.co.th *** แก้ไข Nameserver ***ns2=ns2.cdnex.co.th *** แก้ไข Nameserver ***creator=admindocsroot=./data/skins/enhancedaccount=ONaftp=OFFcgi=ONdnscontrol=OFFnemailr=unlimitednemails=unlimitedpackage=customphp=ONskin=enhancedssh=OFFssl=ONsuspend_at_limit=ONsuspended=nozoom=100 7. ทำการแตกไฟล์ da.cpanel.import.9.4.tar.gz [root@system ~]# tar -xvzf da.cpanel.import.9.4.tar.gz 8. Run script [root@system ~]# perl da.cpanel.import.pl 9. เมื่อทำการ Run script เรียบร้อยแล้ว Script จะทำการแปลงไฟล์ Backup cPanel ไปเป็น Backup Directadmin โดยจะนำไฟล์ที่มีการแปลงสมบูรณ์แล้วไปเก็บไว้ที่ Directory : export ที่สร้างไว้ก่อนหน้านี้ ให้ทำการย้ายไฟล์ Backup ที่ได้ไปไว้ที่ /home/admin/user_backups/ [root@system ~]# mv /root/export/admin.tar.gz /home/admin/user_backups/ 10. ทำการ Login Dashboard Directadmin Go to reseller-level >> Manage User Backups >> Restore Backup >> จากนั้นทำการเลือกไฟล์ Backup ที่ต้องการ Restore ได้เลย
1. ทำการ Update Software Packages [root@system ~]# apt update 2. ทำการ Install Apache Web Server [root@system ~]# apt install apache2 apache2-utils 3. ทำการตรวจสอบการทำงานของ Apache ตรวจสอบ Status apache [root@system ~]# systemctl status apache2 ทำการ Enable apache เพื่อให้สามารถทำการ Auto start service เมื่อทำการ boot ได้ [root@system ~]# systemctl enable apache2 ตรวจสอบ Version apache ที่ทำการติดตั้ง [root@system ~]# apache2 -v 4. ทำการติดตั้ง MariaDB database หรือ Mysql database ติดตั้ง MariaDB database [root@system ~]# apt install mariadb-server mariadb-client ติดตั้ง Mysql server [root@system ~]# apt install mysql-server mysql-client ตรวจสอบ Status mariadb [root@system ~]# systemctl status mariadb.service ทำการ Enable mariadb เพื่อให้สามารถทำการ Auto start service เมื่อทำการ boot ได้ [root@system ~]# systemctl enable mariadb.service ทำ Run script เพื่อเพิ่มความปลอดภัยให้ Database [root@system ~]# mysql_secure_installation ตรวจสอบ Version MariaDB ที่ทำการติดตั้ง [root@system ~]# mariadb --version 5. ทำการติดตั้ง Php [root@system ~]# apt install php7.0 libapache2-mod-php7.0 php7.0-mysql php-common php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline ทำการ Enable Apache php7.0 module [root@system ~]# a2enmod php7.0 ทำการ Restart Apache web server [root@system ~]# systemctl restart apache2 ตรวจสอบ Version PHP ที่ทำการติดตั้ง [root@system ~]# php --version