debian / ubuntu 裝 memcached 跟 pecl memcache

裝 memcached :

apt-get install memcached

/etc/default/memcached 裡面設 yes –> 啟用 設定檔 /etc/memcached.conf

裝 php5 的 memcache extension

apt-get install php5-memcache

會產生 /etc/php5/conf.d/memcache.ini 內容是

extension=memcache.so

[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0

—– 以下是舊的方法, 2010.0630 前

裝 pecl memcache

aptitude install libevent-dev

因為 pecl 要用到 phpize , 所以要裝 php5-dev 套件

apt-get install php5-dev

apt-get install php-pear

pecl install memcache

裝好了, 要在 /etc/php5/conf.d 設一個檔 memcache.ini

cat > /etc/php5/conf.d/memcache.ini
extension=memcache.so

Google 提供 Public 的 DNS , IP 是 8.8.8.8 帥氣又好記!

URL: http://code.google.com/speed/public-dns/

有 unix server 的人 /etc/resolv.conf 可以設它
nameserver 8.8.8.8
windows 使用者也可看這篇說明來設定
http://code.google.com/speed/public-dns/docs/using.html
好處是
Why should you try Google Public DNS?

By using Google Public DNS you can:

    * Speed up your browsing experience.
    * Improve your security.
    * Get the results you expect with absolutely no redirection.

ssh 免輸入 password 登入的方式 , ssh-keygen , rsa better

Once an SSH key has been created, the ssh-copy-id command can be used to install it as an authorized key on the server. Once the key has been authorized for SSH, it grants access to the server without a password.
—>
ssh-copy-id -i ~/.ssh/mykey user@host

Test the new key —>
ssh -i ~/.ssh/mykey user@host

 

#產生 ssh key pair (普遍使用 RSA)
ssh-keygen
可以再用 password 增加保護, 但也可略過 password , 之後會產生兩個檔 , id_rsa . id_rsa.pub (公鑰)

把公鑰 貼到目標 server 的 ~/.ssh/authorized_keys 即可

2020.0926
ssh-copy-id USER@SERVER

PHP / MySQL 一些容易被忽略的 Optimization

URL : http://www.dublish.com/articles/10.html

  • Use NOT NULL as default value as much as you can, it speeds up execution and saves one bit.
  • 一個 <? … ?> 比多個 <? .. ?><? .. ?><? .. ?> 還快
  • 少用 . 去串接字串, 改用這樣的較快 “select addr,name from tbl_addr where id=$id
  • 或者用 ‘ “ 區分出 需要 PHP 不解譯/解譯的字串
  • echo 比 print 快
  • 在 loop 前就把終值先算好, 放變數裡,NG: for($i=0; $i<strlen($str); $i++) ….

ADSL / DDWRT 動態 IP 用 DynDNS 設定 DNS 及 Google Apps

DYNDNS URL :

DynDNS Update Clients : https://www.dyndns.com/support/clients/

command liek this :

/bin/inadyn -u userid -p userpassword -a xxx.blogdns.net --update_period_sec 30 --log_file /tmp/dyn.log --background &

先到 https://www.dyndns.com/ 申請 “Custom DNS Service” (每年USD$29元)

9a0f558b84a2fc2fc37bc48cac6bc8cc

69a4e8e3d3a4b2e669d7a1cebe8c3099

  • The domain is registered elsewhere: You will need to log into your account with the domain’s current registrar, and change the nameserver list to the following:

Custom DNS Nameservers

Server IP Address
ns1.mydyndns.org   (Required) 204.13.248.76
ns2.mydyndns.org   (Required) 204.13.249.76
ns3.mydyndns.org 208.78.69.76
ns4.mydyndns.org 91.198.22.76
ns5.mydyndns.org 203.62.195.76

328bb1a335f9c817287b5d8c2a4790e7

在 router (我的是ddwrt) 設定 DDNS – ADSL 每次換 IP 時 ddwrt 就會通知 dyndns 改 DNS 的 IP address , 其他的 DN 也可以用 CNAME 設成跟這個 host name 一樣.

f277b6d220032cfb73de9035297d66ad

去 google apps 申請一個

361a485a50b729989390eb79680c6764

除了 mail 要設 MX record 比較複雜, 其他的只要設 CNAME record 就可以了, 很簡單!

34dc58a397d612b8f7c90915cc305bb9

mail.monster.tw 是 web mail 界面的網址 跟 收信的 domain 是不同的

ee0ae7e24f93714f64fa2338133b211e