2015年8月31日 星期一

Nginx PHP MySQL

Install ngix

sudo apt-get update
sudo apt-get install nginx nginx-extras php5  php5-fpm  php5-curl

Config it

sudo vim /etc/nginx/nginx.conf

sudo vim /etc/nginx/sites-available/default


Config php-fpm
sudo vim /etc/php5/fpm/pool.d/www.conf



sudo /etc/init.d/php-fpm restart
sudo /etc/init.d/ nginx restart

http://blog.toright.com/posts/3890/%E7%84%A1%E5%A0%85%E4%B8%8D%E6%91%A7%EF%BC%8C%E5%94%AF%E5%BF%AB%E4%B8%8D%E7%A0%B4%EF%BC%81%E5%BF%AB%E6%94%B9%E7%94%A8-nginx-php-fpm-%E5%8F%96%E4%BB%A3-apache-%E5%90%A7%EF%BC%81.html

http://blog.teatime.com.tw/1/post/383

https://www.howtoforge.com/installing-nginx-with-php5-and-mysql-support-on-debian-squeeze

https://www.linode.com/docs/websites/nginx/how-to-install-nginx-on-debian-7-wheezy


install phpmyadmin

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04-server


error message:
php5-fpm.serviceJob for php5-fpm.service failed

check configure file
php5-fpm -y /etc/php5/fpm/php-fpm.conf






Install Moodle

Reference
https://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm

2015年8月30日 星期日

Windows ACL 權限調整心得

windows ACL 權限調整:
若不想讓特定使用者 讀取文件 (但可以列出所有資料夾與檔案)
則進入進階設定   將  讀取權限  設定為拒絕  (列出資料夾/讀取資料  不能設為拒絕)

再開放其某子資料夾 讀取與執行  權限


windows認證過後的user 都隸屬於 Authenticated Users


若要讓建立檔案的人可以刪除 其他人不能修改  需設定CREATOR OWNER
要將其他人 修改的權限  移除

104暑假8月工作記錄

20150829
製作電腦教室汰換下來電腦的印象檔
準備將 PCB-A01~04 作為備用機


20150828
將幼兒園 花鹿班 E102-1 E102-2 加入網域
設定印表機連線  將小熊班印表機X64 driver加入 printer 主機
所用word軟體列印時 會發生錯誤  轉換成PDF再列印即OK

檢查C302教室電腦 與 網路電話(被鎖定!?)
重新插拔電腦電源後 即可開機 

使用PXE開機還原C103電腦 C槽  (需先進BIOS 開啟 NIC Boot ROM)
使用PXE還原後 因接收到PXE server 所發送DHCP 無法順利加入網域


20150827
重新設定 幼兒園 白兔班 電腦名稱
E201-2 設定訊號分配器將訊號投影至單槍

E102 教室電源與網路需重新拉線
E102-1 ASUS MD570 安裝軟體 並進行備份

C棟網路不通 經確認 為廠商進行C棟2F電源施工
網路設備無法正常運作

確認F301網路電話正常
建議 將F402 電腦 C槽資料搬移至 D槽
確認 B403 教室鍵盤


20150826
學務處 體育組 開機緩慢
確認後 發現備份硬碟無法讀取  更換後即可正常使用


20150825
Promise VessR2600i 教育訓練
操作過程造成 VM iscsi 通訊中斷

回復方式:
所有在該datastore的VM 必須全部停止運作
到個別主機 HOST 組態  儲存區  重新整理  (該datastore 應該會自動消失)
到 組態 儲存裝置介面 (修改iscsi介面卡任何一個 靜態路由) 讓VM 重新掃描VHA

參考資料
http://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=2004684

(簡體中文) http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2082207

20150822
使用PXE方式 還原電腦教室A


20150822
使用USB碟方式 還原電腦教室A


20150819
還原電腦教室B

20150818
建立電腦教室B 電腦映像檔

20150809
颱風過後確認機房與資訊中心狀況
將主機開機


20150807
智慧光網路施工需停機
將主機關機

發現 cms ipam無法下達暖關機指令

cms 安裝 VM tool 並清除舊版kernel image 釋放boot空間
ipam 安裝 VM tool 並清除舊版kernel image 釋放boot空間



參考資料
Ubuntu 移除舊版本 Linux 核心

Read more: http://www.arthurtoday.com/2013/05/ubuntu-remove-all-older-linux-kernels.html#ixzz3nHOKcKyk

http://www.arthurtoday.com/2013/05/ubuntu-remove-all-older-linux-kernels.html

2015年8月29日 星期六

Support tools

https://support.microsoft.com/en-us/kb/838079
  •  
  • Ipseccmd.exe
  • Httpcfg.exe
  • Replmon.exe
  • Iadstools.dll
  • Extract.exe
  • Bitsadmin.exe
  • Netdom.exe
BITSAdmin is a command-line tool that you can use to create download or upload jobs and monitor their progress.


repadmin.exe on 2008/2008 R2, or to use replmon.exe from a Windows Server 2003 server.

You can find the command reference for repadmin.exe in Windows Server 2008/2008 R2 here.A few examples:
repadmin.exe /showrepl shows the replication-status for the domain controller the tool are being run from.
repadmin.exe /showrepl servername shows the replication-status for the domain controller with the provided servername,
repadmin.exe /queue shows the replication-queue for the domain controller the tool are being run from.
repadmin.exe /queue servername shows the replication-queue for the domain controller with the provided servername,
repadmin.exe /replsummary shows a brief summary of the replication status.
I also checked if there are any PowerShell cmdlets for checking replication status in Windows Server 2008 R2, but its not. Hopefully this will be implemented some time in the future.
PS: I did test installing the Windows Server 2003 Support tools on a Windows Server 2008 domain controller in a lab environment, and it does work.

2015年8月28日 星期五

Clonezilla 隨身碟 一鍵還原設定

參考資料:
http://clonezilla.org/fine-print-live-doc.php?path=./clonezilla-live/doc/05_Preseed_options_to_do_job_after_booting&fullmode=1

http://wdpsestea.blogspot.tw/search?q=clonezilla

http://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/99_Misc

https://raymii.org/s/tutorials/Customize-your-clonezilla-live-CD.html#example


EFI開機選項設定檔:
/EFI/boot/grub.cfg

BIOS
syslinux/isolinux.cfg   (光碟開機專用)
syslinux/syslinux.cfg



menuentry "clonezilla live with img 2015-08-18-04-imgca (Default settings, VGA 1024x768) ram nokey"{
  search --set -f /live/vmlinuz

  linux /live/vmlinuz boot=live union=overlay username=user config components  noswap edd=on nomodeset nodmraid noeject locales=zh_TW.UTF-8 keyboard-layouts=NONE ocs_live_run="ocs-sr --batch -g auto -e1 auto -e2 -r -j2 -k -p poweroff restoredisk 2015-08-18-04-imgca sda" ocs_live_extra_param="" ocs_live_batch=yes vga=791 ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 toram=filesystem.squashfs  ocs_prerun1="dhclient -v eth0" ocs_prerun2="sleep 2" ocs_prerun3="mount -t cifs //172.22.100.16/images /home/partimag" ocs_prerun4="sleep 3"

  initrd /live/initrd.img
}








menuentry "clonezilla live with img 2015-08-18-04-imgca (Default settings, VGA 1024x768) ram nokey"{
  search --set -f /live/vmlinuz

  linux /live/vmlinuz boot=live union=overlay username=user config components  noswap edd=on nomodeset nodmraid noeject locales=zh_TW.UTF-8 keyboard-layouts=NONE ocs_live_run="ocs-sr --batch -g auto -e1 auto -e2 -r -j2 -k -p poweroff restoredisk 2015-08-18-04-imgca sda" ocs_live_extra_param="" ocs_live_batch=yes vga=791 ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 toram=filesystem.squashfs  ocs_prerun1="dhclient -v eth0" ocs_prerun2="sleep 2" ocs_prerun3="mount -o user=admin -t cifs //172.22.100.16/images /home/partimag" ocs_prerun4="sleep 3"

  initrd /live/initrd.img
}


















參考資料


GRUB format:

menuentry "Clonezilla live (Default settings, VGA 1024x768)"{
  search --set -f /live/vmlinuz

   linux /live/vmlinuz boot=live username=user hostname=utopic config quiet union=overlayfs noswap edd=on nomodeset nodmraid noeject vga=788 toram=filesystem.squashfs  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1  locales=zh_TW.UTF-8 ocs_live_keymap="NONE" ocs_live_batch="no" ip= ocs_prerun1="dhclient -v eth0" ocs_prerun2="sleep 2" ocs_prerun3="mount 10.241.97.252:/volume1/ntpcimg /home/partimag" ocs_prerun4="sleep 2" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -c -r -j2 -p poweroff restoredisk ntpcU-last-img sda "

  initrd /live/initrd.img
}




label Clonezilla live
  MENU DEFAULT
  # MENU HIDE
  MENU LABEL Clonezilla live restore ntpc img (To RAM. Boot media can be removed later)
  # MENU PASSWD
  kernel /live/vmlinuz
  append initrd=/live/initrd.img boot=live username=user hostname=utopic config quiet union=overlayfs noswap edd=on nomodeset nodmraid noeject vga=788 toram=filesystem.squashfs  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1  locales=zh_TW.UTF-8 ocs_live_keymap="NONE" ocs_live_batch="no" ip= ocs_prerun1="dhclient -v eth0" ocs_prerun2="sleep 2" ocs_prerun3="mount 10.241.97.252:/volume1/ntpcimg /home/partimag" ocs_prerun4="sleep 2" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -c -r -j2 -p poweroff restoredisk ntpcU-last-img sda "
  TEXT HELP
  All the programs will be copied to RAM, so you can
  remove boot media (CD or USB flash drive) later
  ENDTEXT

PXE 一鍵還原 pxelinux.cfg\default 設定

無法正確下載 Sysnology tftp  filesystem.squashfs 檔案
所以另用它法 http  或  ftp

PXE\tftpboot\clonezilla-live-2.4.2-32-amd64\pxelinux.cfg\default

label clonezilla
MENU DEFAULT
  # MENU HIDE
  MENU LABEL pxelinux Clonezilla DEFAULT 800*600
  # MENU PASSWD
 
  kernel vmlinuz
   #append initrd=initrd.img boot=live union=overlay  username=user config components  noswap edd=on nomodeset nodmraid noeject  ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1   vga=791 locales=zh_TW.UTF-8 keyboard-layouts=NONE  ocs_prerun1="mount -t cifs -o user=clone //172.22.100.16/images /home/partimag" fetch=tftp://172.22.100.16/filesystem.squashfs


   append initrd=initrd.img boot=live union=overlay  username=user config components  noswap edd=on nomodeset nodmraid noeject  ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1   vga=791 locales=zh_TW.UTF-8 keyboard-layouts=NONE  ocs_prerun1="mount -t cifs -o user=clone //172.22.100.16/images /home/partimag" fetch=ftp://???:???@172.22.100.16/images/PXE/tftpboot/clonezilla-live-2.4.2-32-amd64/filesystem.squashfs


   #append initrd=initrd.img boot=live union=overlay  username=user config components  noswap edd=on nomodeset nodmraid noeject  ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1   vga=791 locales=zh_TW.UTF-8 keyboard-layouts=NONE  ocs_prerun1="mount -t cifs -o user=clone //172.22.100.16/images /home/partimag" fetch=http://172.22.100.2/filesystem.squashfs
  TEXT HELP
  * Clonezilla version: 3.16.26-drbl1. (C) 2003-2015, NCHC, Taiwan
  ENDTEXT




一鍵還原

label Clonezilla Live 
MENU LABEL Clonezilla Live Computer ClassA restore 2015-08-18-04-imgca to disk sda shutdown
kernel vmlinuz
append initrd=initrd.img boot=live union=overlay username=user config components  noswap edd=on nomodeset nodmraid noeject locales=zh_TW.UTF-8 keyboard-layouts=NONE ocs_live_run="ocs-sr --batch -g auto -e1 auto -e2 -r -j2 -k -p shutdown restoredisk 2015-08-18-04-imgca sda" ocs_live_extra_param="" ocs_live_batch=yes vga=791 ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1  ocs_prerun1="dhclient -v eth0" ocs_prerun2="sleep 2" ocs_prerun3="mount -t cifs -o user=clone //172.22.100.16/images /home/partimag" ocs_prerun4="sleep 5" fetch=http://172.22.100.2/filesystem.squashfs 
# append initrd=initrd.img boot=live live-config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 nosplash fetch=tftp://172.22.100.16/filesystem.squashfs
  TEXT HELP
  * Clonezilla version: 3.16.26-drbl1. (C) 2003-2015, NCHC, Taiwan
  * One key restore Computer Room A  Disk 1
  ENDTEXT    

2015年8月25日 星期二

20150825 Drupal 模組開發與偵錯

模組開發偵錯:


PHP 錯誤訊息 寫在   /var/log/message
callback 錯誤

Drupal 邏輯錯誤   寫在Dashboard >  報告  >  Recent log messages
(Watchdog  table)


模組相容性錯誤


JS   AJAX
確認 JQuery
(獨立執行 被呼叫的PHP程式)


CSS



PHP偵錯
phpfilter
print_r  (Array only)
var_dump  可以印出任何元素 印在螢幕上
var_export 印在檔案




建議安裝模組:
Translation template extractor   (翻譯 模組內語系檔)
JQuery Update
Backup and Migrate
Localization update (自動更新語系)
IMC (檔案管理)

Code review
Advanced help  (可在前台直接瀏覽 模組 README)


Entity Registration
1. 報名限制  (人數   日期)
2. 檢查衝突



Drush 可用command line mode execute script

20150824 Drupal研習 note

path
node
menuroute



無障礙
1.改寫Render 模組 (非常費時費力)
2.改寫最後結果 (使用版型)


中文化
http://drupaltaiwan.org/localized
http://drupaltaiwan.org/forum/20110728/5398



1.把下列程式碼 加入 template.php 讓輸出結果 符合無障礙
drupal\themes\bartik\template.php
------------------

$tab_index = 1;

function 版型名稱_for_taiwan($content) {

global $tab_index;$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'.$content);

$images = $dom->getElementsByTagName('img');
$links = $dom->getElementsByTagName('a');
$objs = $dom->getElementsByTagName('object');
$applets =  $dom->getElementsByTagName('applet');
$img_maps = $dom->getElementsByTagName('area');
$ems = $dom->getElementsByTagName('i');
$strongs = $dom->getElementsByTagName('b');
$tables = $dom->getElementsByTagName('table');
$table_headers = $dom->getElementsByTagName('th');

foreach ($images as $img) {
$myalt=$img->getAttribute('alt');
if (!$myalt) $img->setAttribute('alt','排版用裝飾圖片');}foreach ($links as $lnk) {
$mytitle=$lnk->getAttribute('title');
if (!$mytitle) $lnk->setAttribute('title', $lnk->nodeValue);
$lnk->setAttribute('tabindex', $tab_index);
$tab_index++;
}

foreach ($links as $lnk) {
$mytitle=$lnk->getAttribute('title');
if (!$mytitle) $lnk->setAttribute('title', $lnk->nodeValue);
$lnk->setAttribute('tabindex', $tab_index);
$tab_index++;
}


foreach ($objs as $obj) {
$myalt=$obj->nodeValue;
if (!$myalt) $obj->nodeValue=$obj->getAttribute('data');
}

foreach ($applets as $app) {
$myalt=$app->nodeValue;
if (!$myalt) {
 $app->setAttribute('alt', '多媒體互動物件');
 $app->nodeValue='多媒體互動物件';
}
else {
 $app->setAttribute('alt', $myalt);
}
}

foreach ($img_maps as $area) {
$myalt=$area->getAttribute('alt');
if (!$myalt) $area->setAttribute('alt',$area->getAttribute('href'));
}

foreach ($ems as $em) {
$newem=$dom->createElement('em',$em->nodeValue);
$em->parentNode->replaceChild($newem, $em);
}

foreach ($strongs as $strong) {
$newstrong=$dom->createElement('strong',$strong->nodeValue);
$strong->parentNode->replaceChild($newstrong, $strong);
}

foreach ($tables as $table) {
$mytitle=$table->getAttribute('title');
$mysummary=$table->getAttribute('summary');
$caption=FALSE;
if ($table->hasChildNodes()) {
 if ($table->firstChild->nodeName=='caption') $caption=$table->firstChild->nodeValue;
}
if (!$mytitle && $caption) $table->setAttribute('title',$caption);
if (!$mysummary && $caption) $table->setAttribute('summary',$caption);
if (!$mytitle && !$mysummary && !$caption) $table->setAttribute('summary','排版用表格');
}

foreach ($table_headers as $myth) {
$myscope=$myth->getAttribute('scope');
$myheaders=$myth->getAttribute('headers');
if (!$myscope && !$myheaders) $myth->setAttribute('scope','col');
}
$content = $dom->saveHTML();
$content = preg_replace('/<!DOCTYPE .+>/', '', preg_replace('/<meta .+?>/', '', str_replace( array('<html>', '</html>', '<head>', '</head>', '<body>', '</body>'), array('', '', '', '', '', ''), $content)));
return $content;
}

------------------


2.在相同檔案中 將版型名稱_process_html加入下列程式碼

function 版型名稱_process_html(&$vars) {
$vars['page_top'] = 版型名稱_for_taiwan($vars['page_top']);
$vars['page_bottom'] = 版型名稱_for_taiwan($vars['page_bottom']);
$vars['page'] = 版型名稱_for_taiwan($vars['page']);
}

2015年8月19日 星期三

讓Ezgo所有使用者都可以存取arduino


sudo vi /etc/udev/rules.d/90-arduino.rules


SUBSYSTEMS=="usb",ATTRS{idVendor}=="2341",SYMLINK+="ttyUSB%n",MODE="0666"


Save, exit and replug and you should be up and running. Setting the permission to 666 allows anybody to write to the device.

http://askubuntu.com/questions/112568/how-do-i-allow-a-non-default-user-to-use-serial-device-ttyusb0