2014年10月14日 星期二

mysql fulltext常用參數...

再my.conf加入下列參數,可分別將stopword關掉與min length設成1

以下為MyISAM
ft_min_word_len=1
ft_stopword_file=''


以下為InnoDB

innodb_ft_min_token_size=1
innodb_ft_server_stopword_table = ''
innodb_ft_enable_stopword=FALSE


官方說明

ft_min_word_len
Command-Line Format--ft_min_word_len=#
System Variable Nameft_min_word_len
Variable ScopeGlobal
Dynamic VariableNo
Permitted Values
Typenumeric
Default4
Min Value1
The minimum length of the word to be included in a FULLTEXT index.
Note
FULLTEXT indexes must be rebuilt after changing this variable. Use REPAIR TABLE tbl_name QUICK.


ft_stopword_file
Command-Line Format--ft_stopword_file=file_name
System Variable Nameft_stopword_file
Variable ScopeGlobal
Dynamic VariableNo
Permitted Values
Typefile name
The file from which to read the list of stopwords for full-text searches. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. All the words from the file are used; comments are not honored. By default, a built-in list of stopwords is used (as defined in the storage/myisam/ft_static.c file). Setting this variable to the empty string ('') disables stopword filtering. See also Section 12.9.4, “Full-Text Stopwords”.
Note:
FULLTEXT indexes must be rebuilt after changing this variable or the contents of the stopword file. Use REPAIR TABLE tbl_name QUICK.

innodb_ft_min_token_size
Introduced5.6.4
Command-Line Format--innodb_ft_min_token_size=#
System Variable Nameinnodb_ft_min_token_size
Variable ScopeGlobal
Dynamic VariableNo
Permitted Values
Typenumeric
Default3
Min Value0
Max Value16
Minimum length of words that are stored in an InnoDB FULLTEXT index. Increasing this value reduces the size of the index, thus speeding up queries, by omitting common word that are unlikely to be significant in a search context, such as the English words a and to. For content using a CJK (Chinese, Japanese, Korean) character set, specify a value of 1.

 innodb_ft_server_stopword_table
Introduced5.6.4
Command-Line Format--innodb_ft_server_stopword_table=db_name/table_name
System Variable Nameinnodb_ft_server_stopword_table
Variable ScopeGlobal
Dynamic VariableYes
Permitted Values
Typestring
DefaultNULL
Name of the table containing a list of words to ignore when creating an InnoDB FULLTEXT index, in the format db_name/table_name.
Note:
The stopword table must be an InnoDB table, containing a single VARCHAR column named VALUE. The stopword table must exist before you specify its name in the configuration option value.

 innodb_ft_enable_stopword
Introduced5.6.4
Command-Line Format--innodb_ft_enable_stopword=#
System Variable Nameinnodb_ft_enable_stopword
Variable ScopeGlobal
Dynamic VariableYes
Permitted Values
Typeboolean
DefaultON
Specifies that a set of stopwords is associated with an InnoDB FULLTEXT index at the time the index is created. If the innodb_ft_user_stopword_table option is set, the stopwords are taken from that table. Else, if the innodb_ft_server_stopword_table option is set, the stopwords are taken from that table. Otherwise, a built-in set of default stopwords is used.


ERROR! The server quit without updating PID file (/usr/local/mysql/data/server.local.pid).

當開啟mysql時遇到以下error
Starting MySQL
.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/server.local.pid).

在網路上查了很多總解法都無效....

後來把ib_logfile0與ib_logfile1砍掉就搞定了
sudo rm -rf /usr/local/mysql/data/ib_logfile0
sudo rm -rf /usr/local/mysql/data/ib_logfile1

2014年8月25日 星期一

mysql upgarde on mac osx 10.9

停止mysql服務
sudo /usr/local/mysql/support-files/mysql.server stop

mysql官網抓取安裝程式
在此安裝了mysql 5.6.20

點選下載下來的.pkg檔案,安裝MySQL Server
 
確認/usr/local/mysql是否指定新版的sql
1.ls -al /usr/local/mysql
2.lrwxr-xr-x  1 root  wheel  27  8 24 23:36 /usr/local/mysql -> mysql-5.6.20-osx10.8-x86_64

將舊版本data複製到新版
1.cd /usr/local
2.sudo cp -rf mysql-5.5.27-osx10.6-x86_64/data/  mysql-5.6.20-osx10.8-x86_64/data/
3.確認權限是否正確,如果不對,利用sudo chown -R 更改權限
 
啟動新版本的MySQL
sudo /usr/local/mysql/support-files/mysql.server start
 
執行升級程序 
1.sudo /usr/local/mysql/bin/mysql_upgrade
2.sudo /usr/local/mysql/support-files/mysql.server restart 
 
更新密碼 
/usr/local/mysql/bin/mysqladmin -u root password 'password' 
 
 
Note:
官方說明文件 

2014年8月14日 星期四

mac OSX 10.9安裝PHP extension

1.抓取php 5.4.24 source code

http://tw1.php.net/get/php-5.4.24.tar.bz2/from/a/mirror

2.Build the PHP XXX extension

cd ~/Downloads
unzip PHP-5.4.17.zip
cd php-src-PHP-5.4.17/ext/XXX/
/usr/bin/phpize
./configure
make
sudo make install

3.Enable the extension

編輯 /etc/php.ini file 並加入
extension=XXX.so

4.Restart apache

2014年7月19日 星期六

The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'

function my_session_start()
{
    $sn = session_name();

    if (isset($_COOKIE[$sn])) {
        $sessid = $_COOKIE[$sn];
    } else if (isset($_GET[$sn])) {
        $sessid = $_GET[$sn];
    } else {
        return session_start();
    }

    if (!preg_match('/^[a-zA-Z0-9,\-]{22,40}$/', $sessid)) {
        return false;
    }

    return session_start();
}

if ( !my_session_start() ) {
    session_id( uniqid() );
    session_start();
    session_regenerate_id();
}

參考來源:
http://stackoverflow.com/questions/3185779/the-session-id-is-too-long-or-contains-illegal-characters-valid-characters-are

2014年7月16日 星期三

Apache Virtual Hosts on Ubuntu 14.04

1.建立新資料夾(放置web source)

預設document root在 /var/www,所以在此目錄下建一個新目錄:
sudo mkdir /var/www/example.com/


2.Grant Permissions


sudo chown -R $USER:$USER /var/www/example.com/
($USER設呈現在登入的user name)

sudo chmod -R 755 /var/www/example.com/

3.建立新的Virtual Host Files

sudo vi /etc/apache2/sites-available/example.com.conf
檔案內容如下:

ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined


4.Enable the New Virtual Host Files

sudo a2ensite example.com.conf

5.Apache重新載入設定:

sudo service apache2 reload
or
sudo service apache2 restart

apache支援.htaccess rewrite (ubuntu 14.04)

如果mod_rewrite.so已經載入,在 /etc/apache2/apache2.conf中,將


Options Indexes FollowSymLinks
AllowOverride None
Require all granted


改成


Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted

就可以了。