$ curl -O http://sphinxsearch.com/files/sphinx-2.0.3-release.tar.gz $ tar zxvf sphinx-2.0.3-release.tar.gz $ cd sphinx-2.0.3-release $ ./configure --with-mysql-includes=/usr/local/mysql/include/mysql --with-mysql-libs=/usr/local/mysql/lib/mysql $ make $ sudo make install
How to
การติดตั้ง Sphinx บน Mac OS X
การติดตั้ง Nginx, Passenger และ Rails 3 บน CentOS
1. ติดตั้ง Nginx
$ rvmsudo passenger-install-nginx-module
2. ติดตั้ง Rails
$ gem install rails
3. เนื่องจากต้องใช้คำสั่ง start-stop-daemon แต่ใน CentOS ไม่มีจึงต้องลงเพิ่ม
$ wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz $ tar xvfz apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz $ cd apps/sys-utils/start-stop-daemon-IR1_9_18-2/ $ gcc start-stop-daemon.c -o start-stop-daemon $ cp start-stop-daemon /usr/sbin/
4. ติดตั้ง script สำหรับใช้งาน Nginx
$ cd /etc/init.d
การติดตั้ง RVM + Ruby บน CentOS 5.6
1. ติดตั้ง git และ curl โดย
$ sudo yum install git $ sudo yum install curl
2. สร้าง group ชื่อ rvm และเพิ่ม root เข้าใน rvm
$ su - $ groupadd rvm $ usermod -a -G rvm root $ logout
3. ติดตั้ง RVM เข้า system สำหรับใช้แบบผู้ใช้หลายคน
$ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) $ echo '[[ -s "/usr/local/lib/rvm" ]] && . "/usr/local/lib/rvm" # This loads RVM into a shell session.' >> ~/.bash_profile $ source ~/.bash_profile $ type rvm | head -1 # should print 'rvm is a function'
การใช้ session ใน cancan
โดยปกติแล้วไม่สามารถใช้ session ใน cancan ได้ แต่หากจำเป็นต้องใช้ Ryan Bates บอกให้สร้าง method เพื่อส่ง session ใน application_controller.rb ก่อน
# in application_controller.rb def current_ability @current_ability ||= Ability.new(current_user, session) end
แก้ไข initialize ใน ability.rb
# in ability.rb def initialize(user, session) # ... can :update, Comment, :id => session[:comments_ids].to_a end
เพียงเท่านี้ก็สามารถใช้ session ใน cancan ได้แล้ว
เปลี่ยน Encoding จาก Latin1 เป็น UTF8
1. export ฐานข้อมูลที่ต้องการด้วยคำสั่ง
$ mysqldump --user=username --password=password --default-character-set=latin1 --skip-set-charset database_name > database_latin1.sql
2. เปลี่ยน CHARSET จาก Latin1 ให้เป็น UTF8
$ sed -e 's/latin1/utf8/g' database_latin1.sql > database_utf8.sql
3. ลบฐานข้อมูลเดิมและสร้างฐานข้อมูลใหม่ ดังนี้
$ mysql --user=username --password=password --execute="DROP DATABASE database_name;" $ mysql --user=username --password=password --execute="CREATE DATABASE database_name CHARACTER SET utf8 COLLATE utf8_general_ci;"
ติดตั้ง PHP และ PEAR บน Mac OS X Lion
ติดตั้ง PHP
1. ดาวน์โหลด Xcode จาก App Store แล้วติดตั้งให้เรียบร้อย
2. เปิดไฟล์ที่ /etc/apache2/httpd.conf แล้วเอา comment ในบรรทัดด้านล่างนี้ออก
LoadModule php5_module libexec/apache2/libphp5.so
3. เริ่มการทำงาน Apache ใหม่ด้วยคำสั่ง
$ sudo apachectl restart
การติดตั้ง GCC-4.2.1
วันนี้ลง RVM แต่มีปัญหาเพราะมันฟ้องว่าไม่เจอ gcc ทั้ง ๆ ที่ลงพร้อม xcode ไปแล้ว จากนั้นลองค้นใน google หลายบอกให้เพิ่ม CC=/usr/bin/gcc-4.2 เข้าไปด้วย แต่มันก็ฟ้องว่า
ERROR: The provided CC(/usr/bin/gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.
จากนั้นลองค้นไปอีกพบว่าต้องลง GCC-4.2 โดยทำดังนี้


