หน้าเว็บ

วันเสาร์ที่ 7 ธันวาคม พ.ศ. 2562

Windows Server 2003 : Windows Server 2003 Update To R2

Windows Server 2003 : Windows Server 2003 Update To R2
DC04 ที่ Copy VMware มาจากเครื่อง Intranet Local Join และ ทำ Domain เสร็จแล้ว แต่ตัว Version ไม่ใช่ Windows Server 2003 R2
ซึ่งต้อง Update ในหนังสือหน้า 23-24
ทำดังนี้
- Backup Snapshots ก่อนทำ
- หาแผ่นที่ใช้ลง ถ้าของแท้ให้เอาแผ่น 2 ใส่ แต่ตัวนี้เป็น skz ให้ mout แผ่น windows server 2003 skz เข้าไปเลย
ในแผ่นจะมี Folder Update R2
พบปัญหาเวลากดที่ Link Update แล้ว Error
Windows 2003 Wizard Another
Application requires a restart of this computer. Before Setup can run, you must restart the computer.
วิธีแก้ต้องลบ registry เข้าไปที่
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
แล้วลบ PendingFileRenameOperations ออก ถึงจะลงได้
- ติดตั้งตามขึ้นตอน เสร็จแล้ว Reboot
จะเป็น Windows Server 2003 R2

- ต้องดู Active Directory schema version ต้องเป็น Version เดียวกัน กับตัว Master
WINDOWS EDITION SCHEMA VERSION
Windows 2000 Server : 13
Windows Server 2003 : 30
Windows Server 2003 R2 : 31
Windows Server 2008 : 44
Windows Server 2008 R2 : 47
Windows Server 2012 : 56
Windows Server 2012 R2 - Preview : 69

โดยใช้คำสั่ง
dsquery * cn=schema,cn=configuration,dc=domain,dc=com -scope base -attr objectVersion"

เปลี่ยนชื่อ Domain และ dc ที่ใช้ จะต้องได้ Version เดียวกัน กับตัว Master

31 เป็นตัว Windows Server 2003 R2 ถ้าไม่ได้เป็นคนตัวตัวต้อง Update Active Directory schema version (ในหนังสือหน้า 24)

https://nolabnoparty.com/en/finding-active-directory-schema-version/

วันจันทร์ที่ 2 ธันวาคม พ.ศ. 2562

mysql Error Set Default Date 0000-00-00 ไม่ได้

mysql Error Set Default Date 0000-00-00 ไม่ได้
เนื่องจาก mysql 5.7 ไม่รองรับให้ใส่วันที่ ที่ไม่ถูกต้อง
https://dzone.com/articles/upgrading-to ... strict-mod

วิธีแก้ต้องแก้ โหมด mysql
Select มาดูได้ด้วยคำสั่ง
  1. SELECT @@SESSION.sql_mode;

ค่า Default
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION


วิธีแก้ ต้องนำค่า NO_ZERO_IN_DATE,NO_ZERO_DATE ออก
  1. SET SESSION sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'


หรือ ก็ได้
  1. SELECT @@GLOBAL.sql_mode;
  2. SET GLOBAL sql_mode = '...';
 

วันพฤหัสบดีที่ 28 พฤศจิกายน พ.ศ. 2562

Ubuntu : Ubuntu 14.04 Update Vmware Tools แล้ว Error

Ubuntu : Ubuntu 14.04 Update Vmware Tools แล้ว Error
https://intranet.sci.com/blog.php?u=3&b=832

root@webax:/tmp/vmware-tools-distrib# ./vmware-install.pl -d
open-vm-tools packages are available from the OS vendor and VMware recommends
using open-vm-tools packages. See http://kb.vmware.com/kb/2073803 for more
information.
Do you still want to proceed with this installation? [no]
INPUT: [no] default


ต้อง run คำสั่ง
  1. ./vmware-install.pl -f


https://kb.vmware.com/s/article/2107676

วันพุธที่ 27 พฤศจิกายน พ.ศ. 2562

Python : Script สำหรับลบข้อความใน Slack อัตโนมัติ

Python : Script สำหรับลบข้อความใน Slack อัตโนมัติ

Run ที่เครื่องที่ออกเน็ต ได้ ในที่นี้ใช้เครื่อง Extranet
1. ติดตั้งโปรแกรม
  1. sudo apt-get install python-pip

2. ติดตั้ง Slack Client
  1. pip install slackclient
3. สร้าง code removeSlack.py
  1. from slackclient import SlackClient
  2. #from time import sleep
  3. import time
  4. #import datetime
  5. from datetime import datetime, timedelta
  6.  
  7. legacy_token = 'xxxxxx'  # don't if you share your code
  8. channel = 'Cxxxxx'  # the id of the channel to delete all msgs inside
  9.  
  10. sc = SlackClient(legacy_token)
  11. response = sc.api_call('channels.info', channel=channel)
  12.  
  13. #oldest_ts = response['channel']['created']
  14. date_days_ago = datetime.now() - timedelta(days=60)
  15. oldest_ts = time.mktime(date_days_ago.timetuple())
  16. print(datetime.fromtimestamp(oldest_ts))
  17.  
  18. date_days_ago = datetime.now() - timedelta(days=30)
  19. latest_ts = time.mktime(date_days_ago.timetuple())
  20. print(datetime.fromtimestamp(latest_ts))
  21.  
  22. response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  23. allmsgs = [item['ts'] for item in response['messages']]
  24. print(len(allmsgs))
  25. for msg in allmsgs:
  26.     sc.api_call('chat.delete', channel=channel, ts=msg)
  27.     time.sleep(1)
  28. ########### Chanel Server  ###################
  29. channel = 'Cxxxxx'
  30.  
  31. sc = SlackClient(legacy_token)
  32. response = sc.api_call('channels.info', channel=channel)
  33.  
  34. #oldest_ts = response['channel']['created']
  35. date_days_ago = datetime.now() - timedelta(days=60)
  36. oldest_ts = time.mktime(date_days_ago.timetuple())
  37. print(datetime.fromtimestamp(oldest_ts))
  38.  
  39. date_days_ago = datetime.now() - timedelta(days=30)
  40. latest_ts = time.mktime(date_days_ago.timetuple())
  41. print(datetime.fromtimestamp(latest_ts))
  42.  
  43. response = sc.api_call('channels.history', channel=channel, count=1000, oldest=oldest_ts, latest=latest_ts)
  44. allmsgs = [item['ts'] for item in response['messages']]
  45. print(len(allmsgs))
  46. for msg in allmsgs:
  47.     sc.api_call('chat.delete', channel=channel, ts=msg)
  48.     time.sleep(1)
4. chmod ให้ Run ได้
5. สร้าง Cront ให้ run ตามที่ต้องการในที่นี้ run อาทิตย์ละครั้ง วันจันทร์
0 0 * * 1 python /home/pi/removeSlak.py >> /home/pi/removeSlack.log 2>&1

วันอังคารที่ 26 พฤศจิกายน พ.ศ. 2562

Ubuntu : Ubuntu 18.04 Https Free letsencrypt

Ubuntu : Ubuntu 18.04 Https Free letsencrypt
ที่ต้องมี
1. เครื่องที่จะทำต้องออก Net ได้ เพื่อ Check DNS ข้างนอก
2. ต้องมี Domain ที่ตรวจสอบจาก DNS ข้างนอกได้ เช็คได้ที่
https://check-your-website.server-daten.de/
ถ้าไม่มีจะ Error
root@intranet1804:~# certbot-auto certonly --standalone -d intranettest.sci.com -d www.intranettest.sci.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for intranettest.sci.com
http-01 challenge for www.intranettest.sci.com

Waiting for verification...
Challenge failed for domain intranettest.sci.com
Challenge failed for domain www.intranettest.sci.com
http-01 challenge for intranettest.sci.com
http-01 challenge for www.intranettest.sci.com
Cleaning up challenges
Some challenges have failed.

IMPORTANT NOTES:
- The following errors were reported by the server:

Domain: intranettest.sci.com
Type: dns
Detail: DNS problem: NXDOMAIN looking up A for intranettest.sci.com

Domain: www.intranettest.sci.com
Type: dns
Detail: DNS problem: NXDOMAIN looking up A for
www.intranettest.sci.com
3. Stop apace ก่อน Run Code ไม่อย่างนั้นจะ Error
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for intranettest.com
http-01 challenge for www.intranettest.com
Cleaning up challenges
Problem binding to port 80: Could not bind to IPv4 or IPv6.

IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.

เริ่มติดตั้ง letsencrypt


Step 1 – Prerequisites
Before starting work on this task, I assume you already have:

- Running Ubuntu system with sudo privileges shell access.
- A domain name registered and pointed to your server’s public IP address. For this tutorial, we use example.com and www.example.com, which is pointed to our server.
- Running web server with VirtualHost configured for example.com and www.example.com on Port 80.

Step 2 – Install Let’s Encrypt Client


Download the certbot-auto Let’s Encrypt client and save under /usr/sbin directory. Use the following command to do this.
  1. sudo wget https://dl.eff.org/certbot-auto -O /usr/sbin/certbot-auto
  2. sudo chmod a+x /usr/sbin/certbot-auto

Step 3 – Get a SSL Certificate

Let’s Encrypt do a strong Domain Validation automatically with multiple challenges to verify the ownership of the domain. Once the Certificate Authority (CA) verified the authenticity of your domain, SSL certificate will be issued.
  1. sudo certbot-auto certonly --standalone -d example.com  -d www.example.com

Above command will prompt for an email address, which is used for sending email alerts related to SSL renewal and expiration. Also, asks a few more questions. After completion, it will issue an SSL certificate and will also create a new VirtualHost configuration file on your system.

Step 4 – Check SSL Certificate

If everything goes fine. A new ssl will be issued at below location. Navigate to below directory and view files.
  1. cd /etc/letsencrypt/live/example.com
  2. ls

Files List:
cert.pem
chain.pem
fullchain.pem
privkey.pem

Setp 5 – Configure SSL VirtualHost

Use the following configurations for Apache and Nginx web server. Edit virtual host configuration file and add below entries for the certificate.

Apache:
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem


Step 6 – Configure SSL Auto Renew


In the end, configure the following job on your server crontab to auto-renew SSL certificate if required.

  1. 0 6 30 * * sudo /usr/sbin/certbot-auto -q renew

หรือ
  1. 0 6 30 * * certbot renew --dry-run



Step 7 นำไฟล์ไปใช้ ที่ 000-default.conf
เช่น
<VirtualHost *:80>
ServerName extranet.scivalve.com
Redirect / https://extranet.scivalve.com/
ServerAdmin suwit@scivalve.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =extranet.scivalve.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
ServerName extranet.scivalve.com
DocumentRoot /var/www/extranet
SSLEngine on
ServerAdmin suwit@scivalve.com
<Directory /var/www/extranet/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/letsencrypt/live/extranet.scivalve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/extranet.scivalve.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

https://tecadmin.net/install-lets-encrypt-create-ssl-ubuntu/

Ubuntu : Ubuntu 18.04 ส่ง log apace2 ไปเก็บที่ Log Server

Ubuntu : Ubuntu 18.04 ส่ง log apace2 ไปเก็บที่ Log Server
Ubuntu 18.04 Server มีการลง rsyslog มาให้อยู่แล้ว แก้แค่ Config

1. rsyslog.conf
  1. nano /etc/rsyslog.conf
แก้
#module(load="imudp")
#input(type="imudp" port="514")
ลบ # ออก
module(load="imudp")
input(type="imudp" port="514")

2. เพิ่ม ไฟล์ log ที่เราจะส่งไปเก็บ เช่น access.log, error.log, other_vhosts_access.log เป็นต้น
# Apache access file:

$ModLoad imfile
$InputFileName /var/log/apache2/access.log
$InputFileTag apache-access:
$InputFileStateFile stat-apache-access
$InputFileSeverity info
$InputRunFileMonitor

#Apache Error file:

$ModLoad imfile
$InputFileName /var/log/apache2/error.log
$InputFileTag apache-errors:
$InputFileStateFile stat-apache-error
$InputFileSeverity error
$InputRunFileMonitor
#Apache Other file;
$ModLoad imfile
$InputFileName /var/log/apache2/other_vhosts_access.log
$InputFileTag apache-other:
$InputFileStateFile stat-apache-other
$InputFileSeverity info
$InputRunFileMonitor

$InputFilePollInterval 10

if $programname == 'apache-access' then @@192.168.2.108:514
& ~
if $programname == 'apache-errors' then @@192.168.2.108:514
& ~
if $programname == 'apache-other' then @@192.168.2.108:514
& ~

# Forward syslog messages to Loggly
*.* @@192.168.2.108:514


วันอาทิตย์ที่ 24 พฤศจิกายน พ.ศ. 2562

Ubuntu : Ubuntu 18.04 Add Harddisk From Vmware

Ubuntu : Ubuntu 18.04 Add Harddisk From Vmware
1. Add disk edit Vmware
2. Check disk all root@intranet-test:~#
  1. fdisk -l 
Disk /dev/loop0: 88.5 MiB, 92778496 bytes, 181208 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
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: gpt
Disk identifier: 43516ABD-068C-45F5-BC44-9BBBBAD0D4D2

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 104855551 104851456 50G Linux filesystem

Disk /dev/sdb: 150 GiB, 161061273600 bytes, 314572800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

3. Create disk
root@intranet-test:~#
  1. fdisk /dev/sdb
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The old ext4 signature will be removed by a write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbd682c0d.

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
Partition number (1-4, default 1): #Enter
First sector (2048-314572799, default 2048): #Enter
Last sector, +sectors or +size{K,M,G,T,P} (2048-314572799, default 314572799):

Created a new partition 1 of type 'Linux' and of size 150 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

4. Convertor disk to ext4
  1. sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 39321344 4k blocks and 9830400 inodes
Filesystem UUID: bf8171ec-a497-4ad8-80a0-aef19903721f
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
5 ดู Disk
  1. fdisk -l
Disk /dev/loop0: 88.5 MiB, 92778496 bytes, 181208 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
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: gpt
Disk identifier: 43516ABD-068C-45F5-BC44-9BBBBAD0D4D2

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 104855551 104851456 50G Linux filesystem

Disk /dev/sdb: 150 GiB, 161061273600 bytes, 314572800 sectors
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: 0xbd682c0d

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 314572799 314570752 150G 83 Linux
6. ดู uuid เพื่อเอาไปใส่ใน fstab
  1. ls -al /dev/disk/by-uuid/

7. เพิ่ม uuid ใน fstab เพื่อให้ mount auto เมื่อเปิดเครื่อง
  1. nano /etc/fstab
UUID=bf8171ec-a497-4ad8-80a0-aef19903721f /www ext4 defaults 0 0
8. สร้าง Folder ที่จะ mount ไป ใน
  1. mkdir /www

9. reboot เครื่อง
10. Check ว่า disk ถูก Mount เรียบร้อย
  1. df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 395M 1.1M 394M 1% /run
/dev/sda2 49G 5.8G 41G 13% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/loop0 89M 89M 0 100% /snap/core/7270
/dev/sdb1 147G 61M 140G 1% /www
tmpfs 395M 0 395M 0% /run/user/1000
https://oxyme.wordpress.com/2018/08/29/add-install-a-new-hdd-on-ubuntu-18-04-lts-server-edition/

PHPBB3 : Install PHPBB3 V 3.0.12 On Ubuntu 18.04.3 และ Upgrade Version เป็น 3.0.14 รุ่นสุดท้าย

PHPBB3 : Install PHPBB3 V 3.0.12 On Ubuntu 18.04.3 และ Upgrade Version เป็น 3.0.14 รุ่นสุดท้าย
**** ไป Version 3.1 หรือ 3.2 ไม่ได้ เนื่องจาก ***
จาก 3.0 ไป 3.1 หรือ 3.2 ไม่ได้
1. MODs for 3.0.x are incompatible with 3.1.x and their functionality will be removed in the update process. Mod ที่จำเป็นต้องใช้ Blog Mod จะใช้ไม่ได้
2. Styles for 3.0.x cannot be installed or used on 3.1.x. Styles Template ไม่เข้ากัน
https://www.phpbb.com/community/viewtopic.php?t=2398876
https://www.phpbb.com/community/viewtopic.php?t=2402101

3. พบปัญหา PHP7 ถ้าจะใช้ Version 3.0 จะใช้ไม่ได้มี Bug
ถ้าใช้ PHP7.2 ไม่รองรับ 3.0 ต้อง 3.2 ถึงจะรองรับ PHP7
https://www.phpbb.com/customise/db/exte ... pic/162021
https://www.phpbb.com/community/viewtopic.php?t=2353436
https://www.phpbb.com/community/viewtop ... &t=2316556

Blog ไม่ขึ้น เมื่อใช้ที่ Version 3.0.12
เมื่อ Update เป็น 3.0.14 Blog ขึ้นแต่มี Error preg_replace() ใช้ไม่ได้
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4760: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4763: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)


ติดตั้ง Ubunt 18.04 และ PHPBB3 Version 3.0.12 เพื่อ Update เป็น 3.0.14
1. install Ubuntu 18.04.3 ต่อวง 0 เพื่อให้ได้ DHCP แล้วค่อยไปแก้ Network เป็น วง 2
2. copy config เดิมไว้ก่อน
  1. cp /etc/netplan/50-cloud-init.yaml 50-cloud-init.yaml.Backup
3. แก้ Network Fix IP เป็นวง 2
  1. nano /etc/netplan/50-cloud-init.yaml

  1. network:
  2.    version: 2
  3.    renderer: networkd
  4.    ethernets:
  5.       ens160:
  6.          addresses: [192.168.2.114/24]
  7.          gateway4: 192.168.2.2
  8.          nameservers:
  9.             addresses: [8.8.8.8,8.8.4.4,192.168.2.2]

4. Run netplan apply หรือ reboot
5. แก้ apt.conf
  1. nano /etc/apt/apt.conf
Acquire::http { Proxy "http://192.168.2.106:9999"; };
บาง update ไม่ได้ไม่มี Sources ใน 2.106 ให้ปิด apt.conf ไว้ แล้ว update upgrade ใหม่

6. Up และ Set locale
  1. apt-get update
  2. apt-get upgrade
  3. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8

7. Set time zome
  1. sudo timedatectl set-timezone Asia/Bangkok

ดู Time zone
  1. cat /etc/timezone

8. ติดตั้ง ntp
apt install ntp
nano /etc/ntp.conf
เพิ่ม
pool 192.168.2.2
  1. /etc/init.d/ntp restart
  2. ntpq -pn

ดูเวลาที่ sync มา
  1. date

9. สำคัญ ต้องติดตั้ง php5.6 เพื่อใช้งานจะได้ไม่มีปัญหา ตาม Blog
blog.php?u=3&b=1612

10. Database
  1. sudo apt-get install mysql-server


11. Creating phpBB Database and User
  1. sudo mysql -u root -p

ใส่รหัส mysql
เปลี่ยนรหัส root ถ้าจะใช้ root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';

หรือ สร้าง user ใหม่
Create user 'sa'@'localhost' IDENTIFIED BY 'xxxxx';
  1. flush privileges;
  2. exit;


12. ติดตั้ง Phpmyadmin
  1. apt-get install phpmyadmin

เลือก apache
จะสร้าง user phpmyadmin ให้
ใส่รหัส 2 ครั้ง
ลองเข้า
192.168.2.114/phpmyadmin

ด้วย user root ในข้อ 11 หรือ user phpmyadmin ก็ได้

13. นำไฟล์ phpbb3_3.0.12 เข้าเครื่อง download มาหรือ wget มา หรือลง ftp เอาก็ได้
ในไฟล์ไปที่ www แล้วแตกไฟล์

14. ติดตั้งตามขึ้นตอนข้อที่ 19.
https://intranet.sci.com/blog.php?u=281&b=1750

15. จะเข้า Ldap ไม่ได้ จะเป็นหน้า ขาว Bug phpbb3
ดู log จะพบ
  1. tail -f /var/log/apache2/error.log
[Sat Nov 23 10:03:57.894290 2019] [:error] [pid 4332] [client 192.168.0.244:49572] PHP Fatal error: Cannot redeclare ldap_escape() in /var/www/html/includes/auth/auth_ldap.php on line 300, referer: http://192.168.2.114/adm/index.php?sid= ... 215f59d847

วิธีแก้

แก้ไฟล์ auth_ldap.php อยู่ใน Floder includes
/**
* Escapes an LDAP AttributeValue
*/
if (!function_exists('ldap_escape'))
{
function ldap_escape($string)
{
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
}
}

https://www.phpbb.com/community/viewtopic.php?t=2263381

16. ใส่ข้อมูล ldap แล้วไม่ผ่าน Error
Information
Could not find a login identity for admin.
ชื่ออื่นจะไม่ผ่าน login admin ต้องใช้ user administrator เท่านั้น
Information
The specified e-mail attribute does not exist.
ใส่ mail ไม่ผ่าน ไม่ต้องใส่ ถึงจะผ่าน
17. ทดลอง login user domain
18. นำ Database เก่ามา restore database sci_phpbb
จะเอาเข้าไม่ได้เพราะ file ใหญ่
ต้องแก้
  1. nano /etc/php/5.6/apache2/php.ini
แก้ 3 ค่า
upload_max_filesize = 50M
post_max_size = 50M
max_file_uploads = 50
restart apache
  1. /etc/init.d/apache2 restart
สร้าง database sci_phpbb แล้วนำ database เก่ามา Restore

19. ทดลอง copy file จากเครื่องเดิม ยกเว้น sci, file, _install_ ทดลองก่อนยังไม่ต้องเอามาเพราะไฟล์พวกนี้ใหญ่และเยอะ
copy inculde ต้องแก้ auth_ldap.php ตามด้านบนข้อ 15 ด้วย ไม่งั่นจะจอขาว
เอาไฟล์จากเครื่องจริงมาทับ

20. ทดลองเข้าดูจะต้องเข้าได้ก่อน และ Login ได้ แต่เมนูด้านข้างจะไม่มี
ต้อง เข้า ACP ไป Restart Template และ Teme ก่อน ข้อมูลต่าง ๆ Menu Link Blog ก็จะกลับมา พร้อมใช้งาน
ถ้ามีหน้าขาวว่างปล่างต้องดู log ว่ามี Error อะไร

21. Step Upgrade 3.0.12 --> 3.0.14
1. แตกไฟล์ 3.0.14 full ที่ Download มา https://download.phpbb.com/pub/release/3.0/3.0.14/
2. นำ Floder install ไปว่างไว้ใน /var/www/html (หรือ Floder อื่น Root ของ Apache และกำหนด สิทธ์ www-data และ 775)
3. เข้า 192.168.2.114/install/database_update.php
4. ลบหรือเปลี่ยนชื่อ install folder

21. สร้าง Database และนำ Database มา restore database sci และ อื่นๆ ที่จะใช้ แล้วค่อยทดลอง copy ใน Folder sci มาจะนาน
และ copy file มาด้วย
เสร็จขึ้นตอนการ Update ทดลอง ดู Menu ต่าง ๆ อาจจะมี Error ค่อยแก้



PHPmyadmin Error เพราะ Bug php.ini ที่พบตอนจะ Restore

PHPmyadmin Error เพราะ Bug php.ini ที่พบตอนจะ Restore Database พบ 2 Case
1.
Warning in ./libraries/plugin_interface.lib.php#551
count(): Parameter must be an array or an object that implements Countable

Backtrace

./libraries/display_import.lib.php#371: PMA_pluginGetOptions(
string 'Import',
array,
)
./libraries/display_import.lib.php#456: PMA_getHtmlForImportOptionsFormat(array)
./libraries/display_import.lib.php#691: PMA_getHtmlForImport(
string '5dd649bc92f3e',
string 'database',
string 'sci_phpbb',
string '',
integer 8388608,
array,
NULL,
NULL,
string '',
)
./db_import.php#43: PMA_getImportDisplay(
string 'database',
string 'sci_phpbb',
string '',
integer 8388608,
)

วิธีแก้
  1. nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
  1. ctrl+w
count($options)
if ($options != null && count($options) > 0) {
แก้เป็น
if ($options != null && count((array)$options) > 0) {

2.
Warning in ./libraries/sql.lib.php#613
count(): Parameter must be an array or an object that implements Countable

Backtrace

./libraries/sql.lib.php#2128: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#2079: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'sci_phpbb',
string 'phpbb_blogs_plugins',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `phpbb_blogs_plugins`',
NULL,
NULL,
)
./sql.php#221: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'sci_phpbb',
string 'phpbb_blogs_plugins',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `phpbb_blogs_plugins`',
NULL,
NULL,
)

วิธีแก้
  1. nano /usr/share/phpmyadmin/libraries/sql.lib.php

go to line 613
|| (count($analyzed_sql_results['select_expr'] == 1)
&& ($analyzed_sql_results['select_expr'][0] == '*')))
&& count($analyzed_sql_results['select_tables']) == 1;
แทนที่ด้วย
|| count($analyzed_sql_results['select_expr']) == 1
&& ($analyzed_sql_results['select_expr'][0] == '*'))
&& count($analyzed_sql_results['select_tables']) == 1;

แล้ว Restart apache
  1. /etc/init.d/apache2 restart


Fix Bug Phpmyadmin [plugin_interface.lib.php] + Php7.2 + Ubuntu 18.04
http://libtechnophile.blogspot.com/2019/08/m.html
https://medium.com/@chaloemphonthipkasorn/%E0%B9%81%E0%B8%81%E0%B9%89-bug-phpmyadmin-php7-2-ubuntu-16-04-92b287090b01

PHPBB3 : Install PHPBB3 V3.2.8 On Ubuntu 18.04.3

PHPBB3 : Install PHPBB3 V3.2.8 On Ubuntu 18.04.3
1. install Ubuntu 18.04.3 ต่อวง 0 เพื่อให้ได้ DHCP แล้วค่อยไปแก้ Network เป็น วง 2
2. copy config เดิมไว้ก่อน
  1. cp /etc/netplan/50-cloud-init.yaml 50-cloud-init.yaml.Backup
3. แก้ Network Fix IP เป็นวง 2
  1. nano /etc/netplan/50-cloud-init.yaml
  1. network:
  2.    version: 2
  3.    renderer: networkd
  4.    ethernets:
  5.       ens160:
  6.          addresses: [192.168.2.113/24]
  7.          gateway4: 192.168.2.2
  8.          nameservers:
  9.             addresses: [8.8.8.8,8.8.4.4,192.168.2.2]

4. Run netplan apply หรือ reboot
5. แก้ apt.conf
  1. nano /etc/apt/apt.conf
Acquire::http { Proxy "http://192.168.2.106:9999"; };
บาง update ไม่ได้ไม่มี Sources ใน 2.106 ให้ปิด apt.conf ไว้ แล้ว update upgrade ใหม่

6. Up และ Set locale
  1. apt-get update
  2. apt-get upgrade
  3. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8

7. Set time zome
  1. sudo timedatectl set-timezone Asia/Bangkok
ดู Time zone
  1. cat /etc/timezone
8. ติดตั้ง ntp
apt install ntp
nano /etc/ntp.conf
เพิ่ม
pool 192.168.2.2
  1. /etc/init.d/ntp restart
  2. ntpq -pn
ดูเวลาที่ sync มา
  1. date
9. ติดตั้งโปรแกรมที่ต้องใช้
https://hostadvice.com/how-to/how-to-in ... ed-server/
  1. sudo apt-get update
  2. sudo apt-get install apache2

10. Database
  1. sudo apt-get install mysql-server

11. Creating phpBB Database and User
  1. sudo mysql -u root -p

ใส่รหัส mysql
เปลี่ยนรหัส root ถ้าจะใช้ root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';

หรือ สร้าง user ใหม่
Create user 'sa'@'localhost' IDENTIFIED BY 'xxxxx';

  1. flush privileges;
  2. exit;

12. ติดตั้ง Phpmyadmin
  1. apt-get install phpmyadmin

เลือก apache
จะสร้าง user phpmyadmin ให้
ใส่รหัส 2 ครั้ง
ลองเข้า
192.168.2.113/phpmyadmin
ด้วย user root ในข้อ 11 หรือ user phpmyadmin ก็ได้
Bug php Error สีแดง วิธีแก้
https://intranet.sci.com/blog.php?u=281&b=1751

13. ติดตั้ง PHP และโปรแกรมอื่น ๆที่จะใช้
  1. Installing PHP
  2. sudo apt-get install php
  3. sudo apt-get install libapache2-mod-php php-curl php-json php-cgi php-xml php-mysq1

14. Installing phpBB software
download เอาไฟล์ไปใส่เครื่อง
https://www.phpbb.com/downloads/
หรือ wget
15. แตกไฟล์ ย้ายไฟล์ไปไว้ที่ www
  1. cd /tmp
  2. apt-get install unzip
  3. unzip phpBB-3.2.8.zip
  4. cp -R phpBB3/* /var/www/html
  5. cd /var/www/
  6. mv index.html index.html.old
16. เปลี่ยนสิทธิ์
  1. chown -R www-data:www-data /var/www/html/
  2. chmod 660 /var/www/html/images/avatars/upload
  3. chmod 660 /var/www/html/config.php
  4. chmod 770 /var/www/html/store/
  5. chmod 770 /var/www/html/cache
  6. chmod 770 /var/www/html/files
17. ติดตั้ง php ldap
  1. apt-get install php-ldap
  2. /etc/init.d/apapche2 restart

18. สร้าง database phpbb3 ที่ phpmyadmin ในข้อ 12.
19. เข้า เริ่มติดตั้ง
http://192.168.2.113/install/










20. ลบไฟล์ install ทิ้ง หรือเปลี่ยนชื่อ
21. เข้าตั้งค่า LDAP พบ Error ไม่ผ่าน
information
LDAP extension not available admin

ตอนลงต้องใช้ชื่อ administrator เท่านั้น ชื่ออื่นจะไม่ผ่าน

information
The specified email attribute does not exist.

ไม่ต้องใส่ mail ผ่าน

22. ทดลอง login ด้วย user ใน domain
เสร็จ ติดตั้งตัว PHPBB3 V 3.2.8 On Ubuntu 18.04.3

**** นำข้อมูลไฟล์และข้อมูลเก่ามาเข้าไม่ได้ *****
- Database ไม่เหมือนกัน
- ไฟล์ต่าง ๆ Styleไม่เหมือนกัน
- Blog Modไม่รองรับ
จึงต้องใช้วิธี Update เอา
https://intranet.sci.com/blog.php?u=281&b=1753

วันพฤหัสบดีที่ 21 พฤศจิกายน พ.ศ. 2562

Windows 7 Remote RDP ใช้เวลานาน 15-30 วินาที ถึงเข้าได้

Windows 7 Remote RDP ใช้เวลานาน 15-30 วินาที ถึงเข้าได้
จะ Show ข้อความ Securring Remote Connecton นานมาก ประมาณ 15-30 วินาที
วิธีแก้
https://www.batchworks.de/remote-desktop-client-hanging-at-securing-remote-connection/

1. Start Run พิมพ์ mmc แล้ว Enter
2. เลือก Menu File Add/Remove Snap-ins
3. เลือก Group Policy Objects แล้ว Add แตกหัวข้อเข้าไปตามรูป Tab Network Retrieval ติ๊กตามรูป

วันอังคารที่ 19 พฤศจิกายน พ.ศ. 2562

Smart phone : RDP Windows แบบเต็มจอในมือถือ ใช้งานง่าย

Smart phone : RDP Windows แบบเต็มจอในมือถือ ใช้งานง่าย
ด้วยโปรแกรม Microsoft Remote Desktop
https://play.google.com/store/apps/details?id=com.microsoft.rdc.android&hl=en

1. Add Server
2. Add User และ Password จะได้ใส่ครั้งเดียว
3. Remote จะเต็มจอ
4. สามารถ Add ได้มากกว่า 1 เครื่อง

Zimbra : Status Error TLS: SSL

Zimbra : Status Error TLS: SSL
  1. /etc/init.d/zimbra status
Unable to start TLS: SSL connect attempt failed error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed when connecting to ldap master.
Cannot determine services - exiting
ต้อง run คำสั่ง
  1. zmlocalconfig -e ldap_starttls_required=false
  2. zmlocalconfig -e ldap_starttls_supported=0
  3. Zmcontrol start successfully.

ที่มา
https://forums.zimbra.org/viewtopic.php?t=65875
https://tweenpath.net/fix-unable-start-tls-ssl-connect-attempt-failed-error14090086ssl-routinesssl3_get_server_certificatecertificate-verify-failed-connecting-ldap-master-cannot-determine-services-exiting/

แล้ว Restart Service อีกครั้ง ถึงใช้งานได้ตามปกติ

วันอาทิตย์ที่ 17 พฤศจิกายน พ.ศ. 2562

QR Code แผนที่ Google Map

QR Code แผนที่ Google Map เพื่อ Link แผนที่เข้า QR Code และใช้งานใน Google Map
1. เข้า web google map
https://www.google.co.th/maps/@18.3170581,99.3986862,17z?hl=th

2. ค้นหาแผนที่ หรือจุดที่เราต้องการ เช่น sci corporation กด Shared

3. กด Copy link
4. นำ Link ไปวางที่ Address bar เพิ่ม .qr แล้วกด Enter

5. จะได้ QR Code มาแต่มีขนาดเล็ก
6. ปรับขนาด โดยแก้ ที่ Address bar ตรง 150X150 เป็นขนาดที่ต้องการ เช่น 500X500 แล้วกด Enter
7. คลิ๊กขวา ที่ QR Code Save Image ตั้งชื่อ แล้วนำรูปไปใช้งาน

วิธีใช้
1. Scan QR code
2. เลือกโปรแกรม Google Map

วันพฤหัสบดีที่ 7 พฤศจิกายน พ.ศ. 2562

Switch Cisco SG350-28 28-Port

Switch พ่วง Switch แล้วใช้งานไม่ได้ Error (*** รอ Test ***)
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 48:5b:39:ad:2b:35 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 48:5b:39:ad:2b:35 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC d0:2b:20:a4:e7:54 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 00:22:b0:bd:c9:15 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 48:5b:39:ad:2b:35 tried to access through port gi24 which is locked
Warning %2SWPORT-W-LOCKPORTACTIVE: A packet with source MAC 48:5b:39:ad:2b:35 tried to access through port gi24 which is locked


เนื่องจาก Port Lock เพราะ Switch Cisco มีโหมดเรียนรู้ และ Lock Port เพื่อให้มีความปลอดภัยใช้งานได้ใน Mac Address ที่จำกัด โดย Default Port ที่ตั้ง Lock ไว้ให้ผ่านแค่ 10 Mac Address
ทำให้บางเครื่องผ่านได้ใน 10 Mac Address ที่ได้ไปก่อน นอกนั้นจะผ่านไม่ได้ และมี Warning เตือน เพราะเอา Switch ไปพ่วงกันจะมีหลาย Mac Address ที่วิ่งผ่าน Port ที่ใช้ พ่วง ไป Switch ตัวอื่น ทำให้ Ports นั้น Lock และ Mac ที่เกิน 10 ก็จะใช้งานไม่ได้
วิธีแก้
เปลี่ยน Post ที่ใช้เชื่อมโยงระหว่าง Switch ให้รองรับ Mac Address มากขึ้น เช่น 256
เข้าไปที่
Security --> Port Security --> เลือก Port ที่ใช้พ่วงระหว่าง Switch --> Edit
ติ๊ก Interface Status Lock ออก
แล้วแก้ Max No. of Addresses Allowed จาก 10 เป็น 256 แล้วกด Apply
https://www.cisco.com/c/en/us/support/docs/smb/switches/cisco-small-business-200-series-managed-switches/smb85-port-security-configuration-on-the-200-300-series-managed-sw.html



https://sichedelic.wordpress.com/2011/01/02/port-security-by-default-opps/

Mode Ports Security : หน้า 130

Switch Cisco มีปัญหา ไม่ส่งสัญญาณไปที่ Switch ตัวอื่น

Switch Cisco มีปัญหา Ports Switch ปิดตัวเองใช้งานไม่ได้ เมื่อมีการโยกสายเปลี่ยนสาย ตอนที่เปิดเครื่อง
ทำให้ Ports บาง Ports ถูกปิดใช้งานไม่ได้ โยงไปหา Switch ตัวอื่นก็ทำให้ตัวอื่นใช้งานไม่ได้เช่นกัน
เกิดจาก ตัว Switch เปิดโหมด Spanning tree State ไว้
ถ้าเปิดโหมดนี้ไว้แล้วสายไหนที่พ่วงเข้ากับ Swich ตัวอื่น หรือ Server แล้วมีการโยกสายไปต่อ Ports อื่น จะทำให้ Ports เดิมใช้งานไม่ได้
ที่ Ports จะฟ้อง Down (BPDU Guard) ตามรูป
ถ้าเปิดโหมดแล้ว สลับสาย Lan ที่ต่อกับ Switch ตัวอื่นไปมา ก็จะเป็นอีก Ports นั้นจะขึ้น Down (BPDU Guard) และใช้งานไม่ได้
วิธีแก้ ถ้าเป็นแบบนี้
1. ปิด Spanning Tre State แล้ว Apply
2. ไปที่ spanning Tree --> STP Interface Settings
เลือก Ports ที่มีปัญหา สัยเกตุ BPDU Guard จะเป็น Guarding
เลือก Edit ด้านล่าง
แก้ BPDU Guard จะติ๊ก Enable ไว้ให้ติ๊กออก แล้วกด Apply
3. กดเลือก Port Management --> Error Recovery Settings แล้ว ติ๊กเลือก Interface ที่ มี STP BDU Guard แล้วกด Reactivate ตามรูป
4. เข้าไปที่ Port Settings Ports ที่ใช้งานไม่ได้ก็จะใช้ได้ เอาสาย Lan ต่อเข้าจะใช้งานได้
ถ้าติ๊กปิด STP ไปแล้วตามข้อ 1 ก็จะสามารถโยกสาย Lan เปลี่ยน Ports สลับไปมาได้

Axapta : Reports เกินแล้วต้องการลบยอดทิ้ง

Axapta : Reports เกินแล้วต้องการลบยอดทิ้ง
เช่น PD19-019817 : 003016922225 มีการ Reports 1 ตัวเมื่อวันที่ 1/10/2562 ไม่ได้ Pickinglist ทำ Jobcard ยังไม่ได้ Update Costing
ฝผล. ต้องการให้ยกเลิกออก และ ลบ PD ไปเลยเพราะไม่ได้ใช้แล้ว เพราะมีการเปลียน Code ไปทำ PD อื่น แต่ไม่ได้แจ้ง งทส.

ทำได้ 2 วิธี
1. MAA01 ปรับยอดออก และ End PD นั้นไป ควรทำแบบนี้ซึ่งเป็นวิธีที่ถูกต้องและง่ายกว่า
2. ลบและแก้ ไข Transaction ให้เป็นเหมือนว่า PD นี้ไม่ได้ทำขึ้น
วันนี้จะปิด Inventory จึงต้องใช้วิธีที่ 2 ถ้าใช้วิธีที่ 1 ต้องรอทำ MAA01 อนุมัติ (กรณีที่ยังไม่ได้ตัด Pickinglist ถ้าตัด Pickinglist ไปต้องเอายอดกลับคืนมาก่อน และจะใช้วิธีที่ 2 ไม่ได้ เพราะต้องเหลือประวัติว่าของมาจากไหน)
โดย
1. ลบ ข้อมูลออก จาก Inventtrans
2. ลบ ข้อมูลออก จาก InventtransEx
3. Run Job recalcInventSum เพื่อให้ ยอดและมูลค่า Update
4. ลบ Reports ที่ Reports ไปออก ที่ Table ProdJournalProd และ ProdJournalTable
5. ลบ Jobcard ที่ได้ Post ไป ที่ Table ProdJournalRoute และ ProdJournalTable
6. ตรวจสอบรายงาน Stockcard และ รายงาน Inventory ว่าไม่มียอดที่เราลบไป ต้องไม่มีข้อมูล
(สำคัญต้องทำใน Local ก่อน ค่อยทำในของจริง)