2013年12月19日 星期四

FreeBSD指令

安裝時必須設定管理者群組為wheel,否則使用者將無管理者權限可用。

切換管理者    su
關機命令    shutdown -p now
重開機命令    shutdown -r now

新增使用者    adduser
刪除使用者    rmuser
變更使用者密碼    passwd

查看系統版本
uname -a

下載安全性更新
# freebsd-update -r 9.2-RELEASE fetch
安裝安全性更新
# freebsd-update -r 9.2-RELEASE install

ls -l | more 僅顯示一個螢幕之內容

下載檔案
fetch ftp://ftp.rs.internic.net/domain/named.root

查詢硬碟使用容量
# df -h

查詢檔案使用容量清單
du -h -d 1 /home/

清理 ports 編輯期間所產生的暫存資料
cd /usr/ports
# make clean

清理 ports 編輯期間所產生的暫存資料,以及 tarball 檔
# cd /usr/ports
# make distclean

FTP指令
ls     查看 Server 端的目錄或檔案
cd     變更 Server 端目前的目錄
???    查看 Local 端的目錄或檔案
lcd    變更 Local 端目前的目錄
put    將 Local 端的檔案拷貝至 Server 端現在目錄下
get    將 Server 端的檔案拷貝至 Local 端現在目錄下
mput   拷貝多個 Local 端的檔案至 Server 端現在目錄下
mget   拷貝多個 Server 端的檔案至 Local 端現在目錄下

vi命令
a寫入文字
d刪除文字
u復原 U全部復原
:w儲存
:q關閉
:q!強制關閉但不儲存
:set number 顯示行數
:set nonumber 不顯示行數

gzip
壓縮:
$ gzip FileName
解壓縮1:
gunzip FileName.gz
解壓縮2:
gzip -d FileName.gz

Log檔案位置
var/log

轉移log檔目錄
tar cf - * | (cd /usr/var/log; tar xf -)
mv /var/log /var/log.old
ln -s /usr/var/log /var/log

網路設定
# vi /etc/rc.conf

複製檔案
cp 來源路徑 目標路徑

安裝 Apache
    # cd /usr/ports/www/apache24
    # make install clean
    
    備份設定檔
    # cp /usr/local/etc/apache24/httpd.conf /path/to/backupfolder/
    
    echo 'apache24_enable="YES"' >> /etc/rc.conf
    啟動Apache
    /usr/local/etc/rc.d/apache24 start

安裝 MySQL
    # cd /usr/ports/databases/mysql56-server
    # make WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_unicode_ci BUILD_OPTIMIZED=yes install clean
    # echo 'mysql_enable="YES"' >> /etc/rc.conf
    # /usr/local/etc/rc.d/mysql-server start
    # /usr/local/bin/mysqladmin -u root password 'cad23342'

安裝 PHP
    # cd /usr/ports/lang/php5
    增加安裝 Build Apache module
    # make config
    # make install clean
    
安裝 PHP Extensions
    # cd /usr/ports/lang/php5-extensions/
    增加安裝 MySQL database support
    # make config
    # make install clean

安裝 PHPMyAdmin
    # cd /usr/ports/databases/phpmyadmin/
    增加兩項 MySQL
    MYSQL M(DB_connect): PHP MySQL support via mysql client
    MYSQLI M(DB_connect) PHP Improved MySQL client support
    # make config
    # make install clean

設定 PHP
    # cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini

設定Apache
    # vi /usr/local/etc/apache24/httpd.conf
        信箱(非必要)
        ServerAdmin you@your.address
        網域
        ServerName www.example.com
        www路徑
        DocumentRoot "/usr/local/www/apache24/data"
        修改此行
        <IfModule dir_module>
            DirectoryIndex index.html index.htm index.php
        </IfModule>
        
        增加以下幾行
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
        
        Alias /phpmyadmin "/usr/local/www/phpMyAdmin"
        
        <Directory "/usr/local/www/phpMyAdmin">
        Options None
        AllowOverride None
        Require all granted
        </Directory>
    重新啟動Apache
    # /usr/local/etc/rc.d/apache24 restart
    建立一個暫存設定用的資料夾並給予權限
    # mkdir /usr/local/www/phpMyAdmin/config && chmod o+w /usr/local/www/phpMyAdmin/config
    進入 http://localhost/phpmyadmin/setup 進行設定
        建立伺服器
            選擇http認證方式
            刪除認證帳號
        設定檔案按下儲存以建立config/config.inc.php檔案
    
    將設定移至目錄
    # mv /usr/local/www/phpMyAdmin/config/config.inc.php /usr/local/www/phpMyAdmin
    
    移除暫存資料夾
    # rm -r /usr/local/www/phpMyAdmin/config
    重新啟動伺服器
    # /usr/local/etc/rc.d/apache24 restart
    # /usr/local/etc/rc.d/mysql-server restart

設定防火牆
    啟動防火牆
    # ipfw enable firewall
    關閉防火牆
    # ipfw disable firewall

    # vi /etc/rc.conf
        firewall_enable="YES"
        firewall_type="simple"
        firewall_script="/etc/ipfw.rule"
        firewall_quiet="YES"

    # vi /etc/ipfw.rule
        阻擋123.123.123.123埠號任意
        阻擋123.123.123.*埠號80
        /sbin/ipfw -f flush%%
        /sbin/ipfw add deny all from 123.123.123.123 to any
        /sbin/ipfw add deny tcp from 123.123.123.0/24 to any 80

2013年11月5日 星期二

如何下載node.h、v8.h

首先Node.js官方網站下載Source Code: http://nodejs.org/download/
node.h
在壓縮檔內的 src > node.h
v8.h
在壓縮檔內的 deps > v8 > include > v8.h

2013年10月3日 星期四

JavaScript extTypes

副檔名對應檔案類型。
var extTypes = { 
    "3gp"     : "video/3gpp",
    "a"       : "application/octet-stream",
    "ai"      : "application/postscript",
    "aif"     : "audio/x-aiff",
    "aiff"    : "audio/x-aiff",
    "asc"     : "application/pgp-signature",
    "asf"     : "video/x-ms-asf",
    "asm"     : "text/x-asm",
    "asx"     : "video/x-ms-asf",
    "atom"    : "application/atom+xml",
    "au"      : "audio/basic",
    "avi"     : "video/x-msvideo",
    "bat"     : "application/x-msdownload",
    "bin"     : "application/octet-stream",
    "bmp"     : "image/bmp",
    "bz2"     : "application/x-bzip2",
    "c"       : "text/x-c",
    "cab"     : "application/vnd.ms-cab-compressed",
    "cc"      : "text/x-c",
    "chm"     : "application/vnd.ms-htmlhelp",
    "class"   : "application/octet-stream",
    "com"     : "application/x-msdownload",
    "conf"    : "text/plain",
    "cpp"     : "text/x-c",
    "crt"     : "application/x-x509-ca-cert",
    "css"     : "text/css",
    "csv"     : "text/csv",
    "cxx"     : "text/x-c",
    "deb"     : "application/x-debian-package",
    "der"     : "application/x-x509-ca-cert",
    "diff"    : "text/x-diff",
    "djv"     : "image/vnd.djvu",
    "djvu"    : "image/vnd.djvu",
    "dll"     : "application/x-msdownload",
    "dmg"     : "application/octet-stream",
    "doc"     : "application/msword",
    "dot"     : "application/msword",
    "dtd"     : "application/xml-dtd",
    "dvi"     : "application/x-dvi",
    "ear"     : "application/java-archive",
    "eml"     : "message/rfc822",
    "eps"     : "application/postscript",
    "exe"     : "application/x-msdownload",
    "f"       : "text/x-fortran",
    "f77"     : "text/x-fortran",
    "f90"     : "text/x-fortran",
    "flv"     : "video/x-flv",
    "for"     : "text/x-fortran",
    "gem"     : "application/octet-stream",
    "gemspec" : "text/x-script.ruby",
    "gif"     : "image/gif",
    "gz"      : "application/x-gzip",
    "h"       : "text/x-c",
    "hh"      : "text/x-c",
    "htm"     : "text/html",
    "html"    : "text/html",
    "ico"     : "image/vnd.microsoft.icon",
    "ics"     : "text/calendar",
    "ifb"     : "text/calendar",
    "iso"     : "application/octet-stream",
    "jar"     : "application/java-archive",
    "java"    : "text/x-java-source",
    "jnlp"    : "application/x-java-jnlp-file",
    "jpeg"    : "image/jpeg",
    "jpg"     : "image/jpeg",
    "js"      : "application/javascript",
    "json"    : "application/json",
    "log"     : "text/plain",
    "m3u"     : "audio/x-mpegurl",
    "m4v"     : "video/mp4",
    "man"     : "text/troff",
    "mathml"  : "application/mathml+xml",
    "mbox"    : "application/mbox",
    "mdoc"    : "text/troff",
    "me"      : "text/troff",
    "mid"     : "audio/midi",
    "midi"    : "audio/midi",
    "mime"    : "message/rfc822",
    "mml"     : "application/mathml+xml",
    "mng"     : "video/x-mng",
    "mov"     : "video/quicktime",
    "mp3"     : "audio/mpeg",
    "mp4"     : "video/mp4",
    "mp4v"    : "video/mp4",
    "mpeg"    : "video/mpeg",
    "mpg"     : "video/mpeg",
    "ms"      : "text/troff",
    "msi"     : "application/x-msdownload",
    "odp"     : "application/vnd.oasis.opendocument.presentation",
    "ods"     : "application/vnd.oasis.opendocument.spreadsheet",
    "odt"     : "application/vnd.oasis.opendocument.text",
    "ogg"     : "application/ogg",
    "p"       : "text/x-pascal",
    "pas"     : "text/x-pascal",
    "pbm"     : "image/x-portable-bitmap",
    "pdf"     : "application/pdf",
    "pem"     : "application/x-x509-ca-cert",
    "pgm"     : "image/x-portable-graymap",
    "pgp"     : "application/pgp-encrypted",
    "pkg"     : "application/octet-stream",
    "pl"      : "text/x-script.perl",
    "pm"      : "text/x-script.perl-module",
    "png"     : "image/png",
    "pnm"     : "image/x-portable-anymap",
    "ppm"     : "image/x-portable-pixmap",
    "pps"     : "application/vnd.ms-powerpoint",
    "ppt"     : "application/vnd.ms-powerpoint",
    "ps"      : "application/postscript",
    "psd"     : "image/vnd.adobe.photoshop",
    "py"      : "text/x-script.python",
    "qt"      : "video/quicktime",
    "ra"      : "audio/x-pn-realaudio",
    "rake"    : "text/x-script.ruby",
    "ram"     : "audio/x-pn-realaudio",
    "rar"     : "application/x-rar-compressed",
    "rb"      : "text/x-script.ruby",
    "rdf"     : "application/rdf+xml",
    "roff"    : "text/troff",
    "rpm"     : "application/x-redhat-package-manager",
    "rss"     : "application/rss+xml",
    "rtf"     : "application/rtf",
    "ru"      : "text/x-script.ruby",
    "s"       : "text/x-asm",
    "sgm"     : "text/sgml",
    "sgml"    : "text/sgml",
    "sh"      : "application/x-sh",
    "sig"     : "application/pgp-signature",
    "snd"     : "audio/basic",
    "so"      : "application/octet-stream",
    "svg"     : "image/svg+xml",
    "svgz"    : "image/svg+xml",
    "swf"     : "application/x-shockwave-flash",
    "t"       : "text/troff",
    "tar"     : "application/x-tar",
    "tbz"     : "application/x-bzip-compressed-tar",
    "tcl"     : "application/x-tcl",
    "tex"     : "application/x-tex",
    "texi"    : "application/x-texinfo",
    "texinfo" : "application/x-texinfo",
    "text"    : "text/plain",
    "tif"     : "image/tiff",
    "tiff"    : "image/tiff",
    "torrent" : "application/x-bittorrent",
    "tr"      : "text/troff",
    "txt"     : "text/plain",
    "vcf"     : "text/x-vcard",
    "vcs"     : "text/x-vcalendar",
    "vrml"    : "model/vrml",
    "war"     : "application/java-archive",
    "wav"     : "audio/x-wav",
    "wma"     : "audio/x-ms-wma",
    "wmv"     : "video/x-ms-wmv",
    "wmx"     : "video/x-ms-wmx",
    "wrl"     : "model/vrml",
    "wsdl"    : "application/wsdl+xml",
    "xbm"     : "image/x-xbitmap",
    "xhtml"   : "application/xhtml+xml",
    "xls"     : "application/vnd.ms-excel",
    "xml"     : "application/xml",
    "xpm"     : "image/x-xpixmap",
    "xsl"     : "application/xml",
    "xslt"    : "application/xslt+xml",
    "yaml"    : "text/yaml",
    "yml"     : "text/yaml",
    "zip"     : "application/zip"
}

2013年8月20日 星期二

2013年7月24日 星期三

MySQL伺服器設定使用mysqld

my.ini內容
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = D:/MySQL
datadir = D:/MySQL/data
port = 3306
# server_id = .....
character-set-server = utf8
collation-server = utf8_general_ci


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

Batch啟動檔
cd bin
mysqld --install
net start mysql

Batch停止檔
net stop mysql
bin\mysqld --remove

設定密碼
mysqladmin -u root password YOUR-PASSWORD

修改密碼
cd bin
rem mysqladmin -u root password '123456'
mysql -u root -p
rem use mysql
rem update user set password=PASSWORD('123456') where user='root';

備份資料庫 - 方法1
cd bin
mysqldump test -u root -p > d:\test.sql.bak

備份資料庫 - 方法2
mysqldump -u username -p database --single-transaction >dump.sql

還原資料庫
cd bin
mysql test -u root -p < d:\test.sql.bak
自動安裝
mysqld --install
手動安裝
mysqld --install -manual

2013年7月12日 星期五

背景執行Node.JS的套件

安裝指令:
npm install -g forever
執行指令:
forever start app.js
查看指令:
forever list
停止指令:
forever stop 0

2013年6月22日 星期六

MFC重繪指令

重繪指令:
Invalidate(true); //true:清除畫面包含背景 false:清除畫面不含背景
UpdateWindow(); //更新整個視窗
RedrawWindow(); //等同Invalidate + UpdateWindow的效果

2013年6月20日 星期四

在VC++中int整數轉CString字串

程式碼如下:
int num = 123;
CString str;
str.Format(_T("%d"), num);
MessageBox( str, TEXT("Num"), MB_OK );

2013年6月18日 星期二

當Win32使用Console application而出現編譯錯誤時

Error    2    error LNK1120: 1 unresolved externals    D:\XXX\testglut\Debug\testglut.exe    1    1    testglut
Error    1    error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup    D:\XXX\testglut\libcmtd.lib(crt0.obj)    testglut

出現該錯誤時,如下圖修改:

2013年5月15日 星期三

Ubuntu中PHPMyAdmin新建的使用者無權限問題

編輯使用者權限,
由任意主機『%』改成本機『localhost』。

舊版UniformServer中PHPMyAdmin密碼錯誤無法連線MySQL問題

Error

MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password: YES) 
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.


無解,
1. 內部密碼還原無效。
2. 任何指令都無效。
3. bin內無相關重置用控制執行檔。

解法:
直接複製MySQL的Data到新版UniformServer即可。

Ubuntu建置PHPMyAdmin捷徑

sudo ln -s /usr/share/phpmyadmin /var/www