發表文章

目前顯示的是 2017的文章

設定Server IP位置

/etc/network/interface 連結

安裝Server版Ubuntu

參考連結

網頁字型的來源

有三種 使用現有的通用字型:最常見的就是細明體、微軟正黑體等字體,讀取速度快。 使用線上字型:Goog??線上的字體,目前只有試用版字體,中文字有點破破的,因為是免費提供測試用的,有查到中文字正式版目前都是要收費 使用自己上傳的字型:上傳自己的字體,寫法會稍微複雜一些 otf檔案為例 @font-face {     font-family: Test;     src: url("path/test.otf") format("opentype"); } woff  -->  woff ttf  -->  truetype 參考資料   免費字型

Views fieldsets 讓views的架構更完整

可讓多組field包起來加一個class或id

網頁上莫名藍框的消除方式

input,button,select,textarea{outline:none} *:focus { outline: none; }

圖片按鈕下莫名的空白區塊解決方案

hover and white space I was wondering if it was possible to make this blue hover in the drop down list cover 100% of the box so it looks like the gamesworld hover. Is there anyway I can fill that white space so that the blue hover effect reaches the end of the box like the gamesworld? Answer the problem is that a is an in-line element so it'll take only the space it needs, you should try to give the background-color to the parent element or add display:block; to the a element 將此圖片連結的<a>標籤css加入display:block;的屬性,另外也將<img>加入width:100%;的屬性即可解決。 參考資料

點閱次數歸零

進資料庫搜尋node_counter資料表,清空內容即可。

同時上傳多個檔案

請下載以下套件 圖片 Multiupload Imagefield Widget 檔案 Multiupload Filefield Widget

檔案下載模組

要讓檔案能夠直接做下載動作,請安裝File Force Download模組 如果想要加上計次功能的最佳唯一選擇還是Track da files 在Views裡的檔案欄位,Formatter選擇tdf:Generic file,並把Force download勾選起來 如要將檔案及計次文字欄位分開,得以暴力修改css方可行,新增兩個同樣的檔案欄位,各別將檔案或計次文字display:none即可。 修改計次文字可至翻譯尋找displayed @count times修改為@count即可只留下計次數字。

Disable Breadcrumbs 正常使用於MySQL5.7

去drupal搜尋以下diff檔,打進drupal即可正常運作 patch < Fix-compatibility-with-MySQL-5.7.x.diff

新增 刪除 使用者

此新增方式會在家目錄自動加入該使用者的資料夾 新增使用者 adduser id 刪除使用者 deluser id

利用Ubuntu的crontab做自動備份

在資料夾 /etc 裡面有一個 crontab 檔案,在這個檔案裡,可加入一些敘述來讓主機按時自動完成一些任務,好比說讓主機做複製壓縮等動作,可做出簡單的自動備份功能。 以編輯器檢視 crontab 這個檔案,可以看到許多行指令,其中可找出有同一規則的幾條指令,前面會有五欄以數字或是*字編寫,和使用者的ID、shh指令等等,這就是我們要了解,也可參考、編輯的地方。 製作不用密碼可立即登入的 ssh 用戶 參考資料   參考資料2   參考資料3

drupal簡潔網址設定

簡潔網址要怎麼設定?看了網路上的一些參考資料有點迷糊了!這裡簡單敘述一下該怎麼做? cd /etc/apache2 sudo nano apache.conf 修改裡面的Directory <Directory /var/www/>  …  AllowOverride None  … </Directory> 改成 <Directory /var/www/>  …  AllowOverride All  … </Directory> 好了以後 查看rewrite_mod是否有開啟? apache2ctl -M 或 apachectl -M 沒有看到rewrite_mod要輸入以下指令讓它開啟 a2enmod rewrite 再回到Drupal資料夾,將.htaccess檔案裡# RewriteBase / 井字拿掉,沒有Domain在斜線後加上資料夾名稱,有Domain斜線後面空著,重啟apache即可。(不一定要設定這部分)

Drupal移機

將系統檔與sql搬移至新主機,把setting.php刪掉,輸入對應的網址,會自動進入安裝畫面,按照新主機的資訊輸入,即可完成,直接進入首頁。

查詢Ubuntu目前啟用的服務

service --status-all

停啟用SSL

 啟用 sudo a2enmod ssl 停用 How to Disable SSL? sudo a2dismod ssl sudo a2dissite default-ssl sudo service apache2 restart 功能設定檔 啟用/停用 : a2enconf / a2disconf 模組 啟用/停用 : a2enmod / a2dismod 網站 啟用/停用 : a2ensite / a2dissite

主機分散風險管理

資料庫與網頁DATA分別存放於兩台伺服器,其中Mysql的設定,如何允許外部網頁服務取得資料庫存取權? 查詢3306 port是開放狀態可使用以下指令查詢 netstat -ntlp | grep LISTEN 剛架好的伺服器,預設是會開啟的,再來更改MySQL設定檔 sudo nano /etc/mysql/my.cnf or sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf 找到 bind-address = 127.0.0.1,把ip位置改掉,通常兩台伺服器內網是可通聯的,改為本機內部ip位置即可,以內部ip取用較為安全。 Mysql使用者帳號的權限,主機名稱要設為%,如果覺得%太危險,可設定為指定主機ip或是localhost。

Ubuntu16.04 安裝Drush 相關套件

以drush下載drupal主程式出現  Directory /home/user/.drush/cache/default exists, but is not writable. Please check directory           [error] permissions. PHP Fatal error:  Uncaught Error: Call to undefined function simplexml_load_file() in /usr/share/php/drush/commands/pm/release_info/updatexml.inc:402 Stack trace: #0 /usr/share/php/drush/commands/pm/release_info/updatexml.inc(45): updatexml_get_release_history_xml(Array) #1 /usr/share/php/drush/commands/pm/download.pm.inc(92): release_info_fetch(Array, '', 'auto', false) #2 /usr/share/php/drush/includes/command.inc(334): drush_pm_download('drupal') #3 /usr/share/php/drush/includes/command.inc(208): _drush_invoke_hooks('pm-download', Array, 'pm') #4 /usr/share/php/drush/includes/command.inc(175): drush_command('drupal') #5 /usr/share/php/drush/drush.php(92): drush_dispatch(Array) #6 /usr/share/php/drush/drush.php(61): _drush_bootstrap_and_dispatch() #7 /usr/share/php/drush/drush.php(...

學校Moodle平台以openLDAP部屬管理帳號策略

每學期開學該做的事情: 1.建立好新生的帳號於LDAP伺服器 2.將舊生班級、座號、學年度更新 3.將轉學生做上標記,在Moodle上以此標記篩選出來停用 4.建立好班級,以學年度為單位,下學期需再做一次調整 5.新學年度則將班級開設新的架構,上一學年度則可保留至上學年的課程 缺點:課程會越開越多,DATA則會吃掉越來越多伺服器的空間 優點:管理起來學生名單比較單純,只有該學年度之學生

LDAP與AD之對應欄位

Name in AD LDAP Name (header in CSV file) First Name givenName Middle Name / Initials initials Last Name sn Logon Name userPrincipalName Logon Name (Pre Windows 2000) sAMAccountName Display Name displayName Full  Name name/cn Description description Office physicalDeliveryOfficeName Telephone Number telephoneNumber Email mail Web Page wWWHomePage Password password Street streetAddress PO Box postOfficeBox City l State/Province st Zip/Postal Code postalCode Country  co Country 2 Digit Code - eg. US c Country code -eg. for US country code is 840 countryCode Group memberOf Account Expires (use same date format as server) accountExpires User Account Control  userAccountControl Profile Path profilePath Login Script scriptPath Home Folder homeDirectory Home Drive homeDrive Log on to userWorkstations Home homePhone Pager pager Mobile mobile Fax facsimileTelephoneNumber IP Phone ipPhone Notes info Title title Department department Company co...

用openLDAP來做Moodle帳號管理

在Moodle的網站管理輸入LDAP搜尋,找到使用一個LDAP伺服器,將其啟用。 輸入主機網址,輸入可區辨的名稱(base_dn),以及密碼。 用戶類型使用posixAccount(rfc2307bis)。 情境輸入使用者群的ou位置,搜尋子條件選擇是(我是在使用者群裡再分群所以選是)。 用戶屬性輸入cn,密碼格式選擇MD5加密。 其他欄位可以依所好新增對應。 即可成功連線。 原有想過以S牌NAS來架設LDAP,因為想要有停用功能,但經過測試後,其停用功能僅限於該系統內部,停用後,在moodle平台上,還是能以停用後的帳號登入,就此作罷。

安裝Moodle

資料庫設定好後,開始安裝,會遇到php套件擴展的問題,看缺什麼安裝一下就好了 php-curl、php-zip、php-xmlrpc、php-soap、php-intl

OpenLDAP帳號管理

帳號管理,以表格的方式來製作會比較方便,但要輸入至LDAP伺服器裡時,卻只能以ldif及LDAP格式的xml匯入,此時,我們需要的是一個轉檔程式,能夠將csv格式的檔案轉製成ldif。 一開始,登入phpLDAPadmin後,先找到帳號的類別(底下即為帳號群),將其匯出為csv,編輯csv檔,先將'|'替換為',',可輸入sed -i 's/ | /,/g' sample.csv。 再將帳號類別的列位刪除,只屬於帳號類別的欄位也刪除,隨後將objectclass欄位底下的資料拆開,也加上objectclass的標題。 好了以後再使用轉檔程式 csv2ldif ,使用AddData2.pl(輸入perl ./AddData2.pl,出現Name of file to be converted from CSV to LDIF 'Add' File:輸入檔案位置)先產生ldif的內容。 隨後以FixData2.pl(輸入perl ./FixData2.pl)加入修改內容的標記(因為phpLDAPadmin沒有選項讓你選擇是否要覆蓋既有帳號),出現Will these attributes be in replace or add mode?[replace]: 直接按 Enter,覆蓋原本的檔案。 接著,回到phpLDAPadmin使用import,將檔案上傳,即可加入帳號。

管理OpenLDAP

Apache Directory 會是一個不錯的選擇,它可支援三大系統Windows、Mac、Linux。

Ubuntu & OpenLDAP & Drupal

在Ubuntu架設OpenLDAP Server,使用於drupal,成功取出群組資料,關鍵在於LDAP資料屬性結構名稱。 群組的objectClass使用posixGroup 帳號的objectClass就要使用posixAccount 在群組也要將memberUid加上去 Drupal就能找到帳號與群組的關聯

在Ubuntu裡安裝中文輸入法

安裝好系統後,在系統設定值裡,找到語言支援,安裝搜尋完的支援檔,登出系統再登入,進入小鍵盤裡的ConfigureFcitx選項,按下"加號",就可以看到"新酷音"輸入法,把它加入即可。

memberof overlay設定

在openldap預設裡是沒有memberof這個overlay,要自己去手動新增,可參考 此篇 。 First install the openldap package sudo apt-get install slapd Then add the memberOf module and overlay to the schema. vi member.ldif Add the following to the file: dn: cn=module,cn=config cn: module objectclass: olcModuleList objectclass: top olcmoduleload: memberof.la olcmodulepath: /usr/lib/ldap dn: olcOverlay={0}memberof,olcDatabase={1}hdb,cn=config objectClass: olcConfig objectClass: olcMemberOf objectClass: olcOverlayConfig objectClass: top olcOverlay: memberof P.S. 要自己切換成BDB,HDB,MDB 我是用mdb所以要改成{1}mdb,下面也是 Save the file and add it to the OpenLDAP config with the following command: ldapadd -Y EXTERNAL -H ldapi:/// -f member.ldif [AdSense-B] Add referential integrety to the ldap config vi refint.ldif Add the following to the file: dn: cn=module,cn=config cn: module objectclass: olcModuleList objectclass: top olcmoduleload: refint.la olcmodulepath: /usr/lib/ldap dn: olcOverlay={1}refint,olcDatab...

Moodle測驗學生做完了但從未繳交該怎麼處理?

請參考以下資料 Re: Moodle Quiz: How to submit a quiz with "Never Submitted" status Tim Hunt 2014年 02月 13日(四) 16:58 Try this: Work out the ids for the 4 problem attempts. You can get this by going to the quiz reports, and reviewing the 4 attempts. The URL will end .../mod/quiz/review.php?attempt={id here}. Change the quiz settings to When time expires: attempts are submitted automatically. (being very careful) edit the data in the database. In the quiz_attempts table, matching the ids with the id column, find the rows for those 4 attempts. Edit the value in the 'state' column from 'abandoned' to 'inprogress'.(我是改為finished) Wait until cron runs. The attempts should then be submitted. I think that will work, but it is just an educated guess. Proceed at your own risk. The sensible thing would be to try this on a test server, with a dummy quiz and attempt you created just for testing, before trying it wilt real data. 連結 將測驗設定裡的"當作答時間限制已到時...

以Synology DiskStation架設LDAP Sever

安裝Directory Sever套件,啟動LDAP伺服器,設定好FQDN、密碼,新增一些使用者、群組,利用phpLDAPadmin來查看結構,登入時的Login DN為uid=root,cn=users,dc=網域名稱。

Track da files

檔案下載次數計數器 唯一選擇 Track da files

Calendar

Views搭配Calendar模組可做出以年、月、週、日分頁的效果,可用於排課、營養餐點、聯絡簿等用途。 行列轉換可用Views Flipped Table模組 官方參考資料

Mail Server

要在網站裡做郵件伺服器直接安裝 sudo apt-get install postfix

Rules、VBO與Cron

當Rules、VBO與Cron一起使用時 在Cron debug log裡面出現 Views Bulk Operations action load list not working 請去下載相關patch 官方解決方案

Sever 資料權限 分類別設定

只修改 /var/www/html/abc 底下所有資料夾的權限 find /var/www/html/abc -type d -exec chmod 755 {} \; 只修改 /var/www/html/abc 底下所有資料夾的權限 find /var/www/html/abc -type f -exec chmod 644 {} \;

LDAP安裝於Ubuntu

就我所知有三個需要注意的地方: 安裝LDAP主程式 安裝LDAP圖形化介面 安裝LDAP網頁服務相關應用套件 以Ubuntu主機為例LDAP為OpenLDAP,圖形化介面為phpldapadmin 步驟 安裝OpenLDAP sudo apt-get install slapd ldap-utils 設定admin的密碼 sudo dpkg-reconfigure slapd 做詳細設定 Omit OpenLDAP server configuration? No DNS domain name: localhost Organization name: localhost Administrator password: ******* Confirm password: ******* Database backend to use: MDB Do you want the database to be removed when slapd is purged? No Move old database? Yes Allow LDAPv2 protocol? No 設定LDAP的ldap.conf 把BASE跟URI改一改 安裝phpldapadmin sudo apt-get install phpldapadmin 修改phpldapadmin config裡的資訊(紅色部分) sudo nano /etc/phpldapadmin/config.php $servers->setValue('server','host',' server_domain_name_or_IP '); $servers->setValue('server','base',array(' dc=test,dc=com ')); $servers->setValue('login','bind_id',' cn=admin,dc=test,dc=com '); $config->custom->appearance[...

LDAP運用於Drupal

要使用Drupal裡的LDAP模組,在伺服器上須先安裝一套件 sudo apt-get install php-net-ldap 安裝好後重新啟動apache2 sudo service apache2 restart 進入Drupal資料夾安裝相關模組即可成功啟用此模組 sudo drush dl ldap ctools entity

Drush

Drush就是Drupal跟Shell的合體,讓Drupal可用指令來進行安裝。 安裝Drush sudo apt-get install drush 用Drush來安裝Drupal 首先要先到Web的目錄底下 cd /var/www/html 安裝Drupal sudo drush dl drupal 進到Drupal的資料夾裡 sudo drush site-install standard --clean-url=0 --site-name='示範中' --account-pass='新密碼' --db-url=mysql://資料庫帳戶名稱:'資料庫帳戶密碼'@localhost/資料庫名稱 Drush Commands 版本更新 drush安裝教學 最新版drush php7安裝教學

安裝phpMyAdmin

安裝的一開始要確認我們所使用的網頁伺服器,因為我們架設的LAMP sever是使用Apache作為網頁伺服器,所以要選擇 apache2 ,切記一定要用鍵盤的空白鍵(Space)來選擇項目,再用Enter鍵確認選擇,不然會安裝失敗。 參考連結

架設LAMP server

LAMP 為 Linux + Apache + MySQL + PHP 的伺服器組合,只需要透過一個套件就可以輕鬆安裝LAMP server: 安裝tasksel套件 sudo apt-get install tasksel 開啟tasksel選單 sudo tasksel 直接使用tasksel安裝lamp-server sudo tasksel install lamp-server Mysql密碼設定

Ubuntu灌好的第一步

請輸入以下指令讓所有套件為最新版本,以免遇到有安全更新沒更新到的情形 sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

開發網站的利器 VirtualBox

開發網站常常發生一些情況會需要伺服器端的一些支援,如果伺服器已有某站、某系統在運作時,實在是不方便在伺服器上莽撞的做一些套件的測試、安裝或更新,此時可使用虛擬伺服器來測試囉!p.s.還是強調一個伺服器做一件事情會比較單純一點! VirtualBox