
夢
狂躁的梦境陡然间结束,激昂的心跳瞬息间平缓,纷叠的记忆呼吸间逝去。
梦已逝,悲欢尽,夜迷朦,君何在?
Opera snapshots checker v3
以前寫的 checker 都是 php 的,早起無事,折騰下,用 shell 重寫個。
- #! /bin/bash
- url=http://snapshot.opera.com/windows/latest
- dir=/ls.tl/check
- win=`curl -s -I $url | grep Location | awk 'BEGIN{ORS=""} {print $2}' | tr -d '\r'`
- #eval `echo $win | awk -F '[-|_|/]' '{print "codename="$5, "ver="$6, "build="$7 }'`
- eval `echo $win | awk -F '[-|.]' '{ print "ver="$(NF-3)"."$(NF-2), "build="$(NF-1) }'`
- if [ ! -f $dir/build ]
- then
- echo 0 > $dir/build
- fi
- if [ $build != `cat $dir/build | awk 'BEGIN{ORS=""} {print $0}'` ]
- then
- echo -n $build > $dir/build
- mac=`echo $win | awk 'BEGIN{ORS=""} {sub(/windows/, "mac"); sub(/exe/, "dmg"); print $0}'`
- unix=`echo $win | awk 'BEGIN{ORS=""} {sub(/windows/, "unix"); sub(/Opera.*$/, ""); print $0}'`
- echo -n '<h2>Opera '$ver' build '$build'</h2><ul><li><a href="'$win'">Windows</a></li><li><a href="'$mac'">Macintosh</a></li><li><a href="'$unix'">Linux/FreeBSD</a></li></ul>' > index.html
- echo -n -e $win"\n"$mac > $dir/dllist
- wget -q -N -P $dir/builds/ -i $dir/dllist
- date +%s > $dir/timestamp
- echo -n 1 > $dir/update
- else
- date +%s > $dir/timestamp
- echo -n 0 > $dir/update
- fi
嗯嗯,只有 php 的三分之一長
—
update – 2011.09.29
1076 更新时 codename 与 ver 之间插入了 “opera”,考虑到以后还会再有变化的可能性,改为从文件名中匹配版本号
- eval `echo $win | awk -F '[-|_|/]' '{print "codename="$5, "ver="$6, "build="$7 }'`
改为
- eval `echo $win | awk -F '[-|.]' '{ print "ver="$(NF-3)"."$(NF-2), "build="$(NF-1) }'`
圖


地球不是繞着太陽轉的
地球不是繞著太陽轉的,地球是繞著太陽系重心轉的,太陽系重心並不總是在太陽内部 =.=!

参考:
debian+nginx+mysql+php 折騰手記
最近用 Amazon EC2 搭了不少環境,記之,以備日後查閱。
Debian 6.0.2 / Nginx 1.0.6 / MySQL 5.5.15 / PHP 5.3.8 編譯安裝。
零-初
- apt-get update
- apt-get upgrade
- apt-get install build-essential vim
- cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- echo '/dev/xvdf /www ext4 defaults,nosuid,noexec,nodev 1 2' >> /etc/fstab
- mount -a
一-Nginx
1,安裝依賴
- apt-get install libpcre3-dev libssl-dev
2,添加用戶
- adduser --system --no-create-home --disabled-login --disabled-password --group www
3,編譯安裝
- wget http://nginx.org/download/nginx-1.0.6.tar.gz
- tar zxvf nginx-1.0.6.tar.gz
- cd nginx-1.0.6
- ./configure --prefix=/opt/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
- make & make install
4,啓動腳本,保存至 /etc/init.d/nginx
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: nginx
- # Required-Start: $local_fs $remote_fs $network $syslog
- # Required-Stop: $local_fs $remote_fs $network $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: starts the nginx web server
- # Description: starts nginx using start-stop-daemon
- ### END INIT INFO
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- DAEMON=/opt/nginx/sbin/nginx
- NAME=nginx
- DESC=nginx
- # Include nginx defaults if available
- if [ -f /etc/default/nginx ]; then
- . /etc/default/nginx
- fi
- test -x $DAEMON || exit 0
- set -e
- . /lib/lsb/init-functions
- test_nginx_config() {
- if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
- return 0
- else
- $DAEMON -t $DAEMON_OPTS
- return $?
- fi
- }
- case "$1" in
- start)
- echo -n "Starting $DESC: "
- test_nginx_config
- # Check if the ULIMIT is set in /etc/default/nginx
- if [ -n "$ULIMIT" ]; then
- # Set the ulimits
- ulimit $ULIMIT
- fi
- start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
- --exec $DAEMON -- $DAEMON_OPTS || true
- echo "$NAME."
- ;;
- stop)
- echo -n "Stopping $DESC: "
- start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
- --exec $DAEMON || true
- echo "$NAME."
- ;;
- restart|force-reload)
- echo -n "Restarting $DESC: "
- start-stop-daemon --stop --quiet --pidfile \
- /var/run/$NAME.pid --exec $DAEMON || true
- sleep 1
- test_nginx_config
- start-stop-daemon --start --quiet --pidfile \
- /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
- echo "$NAME."
- ;;
- reload)
- echo -n "Reloading $DESC configuration: "
- test_nginx_config
- start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
- --exec $DAEMON || true
- echo "$NAME."
- ;;
- configtest|testconfig)
- echo -n "Testing $DESC configuration: "
- if test_nginx_config; then
- echo "$NAME."
- else
- exit $?
- fi
- ;;
- status)
- status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
- ;;
- *)
- echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
- exit 1
- ;;
- esac
- exit 0
5,添加自啓動
- chmod +x /etc/init.d/nginx
- update-rc.d nginx defaults
6,主配置文件,保存至 /opt/nginx/conf/nginx.conf
- user www www;
- worker_processes 1;
- pid /var/run/nginx.pid;
- events {
- use epoll;
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- client_body_buffer_size 1K;
- client_header_buffer_size 2k;
- client_max_body_size 20M;
- large_client_header_buffers 4 8k;
- client_body_timeout 30;
- client_header_timeout 30;
- keepalive_timeout 35;
- send_timeout 30;
- limit_zone slimits $binary_remote_addr 1m;
- limit_conn slimits 5;
- sendfile on;
- tcp_nopush on;
- server_tokens off;
- log_format access '$remote_addr - [$time_local] - $host "$request" - '
- '$status - $body_bytes_sent bytes - "$http_referer" - '
- '"$http_user_agent" - $http_x_forwarded_for';
- access_log /var/log/nginx/access.log access;
- error_log /var/log/nginx/error.log;
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 8 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- gzip on;
- gzip_disable "msie6";
- gzip_vary on;
- gzip_comp_level 3;
- gzip_buffers 4 16k;
- gzip_min_length 1k;
- gzip_http_version 1.1;
- gzip_types text/plain text/richtext text/css text/xsd text/xsl application/json application/x-javascript text/xml application/application/xml+rss text/javascript image/x-icon image/svg+xml;
- index index.html index.php;
- upstream php {
- #server unix:/opt/php/var/run/php-fpm.sock;
- server 127.0.0.1:9000;
- }
- include conf.d/*.conf;
- }
7,站點配置文件,保存至 /opt/nginx/conf/conf.d/
- server {
- server_name ls.tl www.ls.tl;
- root /www;
- if ($host !~ ^(ls.tl|www.ls.tl)$ ) {
- return 444;
- }
- if ($request_method !~ ^(GET|HEAD|POST)$ ) {
- return 444;
- }
- location = /favicon.ico {
- log_not_found off;
- access_log off;
- }
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
- location ~ /\. {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ~ \.php$ {
- try_files $uri =404;
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_index index.php;
- include fastcgi_params;
- fastcgi_pass php;
- }
- }
8,FastCGI 設置,保存至 /opt/nginx/conf/fastcgi_params
- fastcgi_param QUERY_STRING $query_string;
- fastcgi_param REQUEST_METHOD $request_method;
- fastcgi_param CONTENT_TYPE $content_type;
- fastcgi_param CONTENT_LENGTH $content_length;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name;
- fastcgi_param REQUEST_URI $request_uri;
- fastcgi_param DOCUMENT_URI $document_uri;
- fastcgi_param DOCUMENT_ROOT $document_root;
- fastcgi_param SERVER_PROTOCOL $server_protocol;
- fastcgi_param GATEWAY_INTERFACE CGI/1.1;
- fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
- fastcgi_param REMOTE_ADDR $remote_addr;
- fastcgi_param REMOTE_PORT $remote_port;
- fastcgi_param SERVER_ADDR $server_addr;
- fastcgi_param SERVER_PORT $server_port;
- fastcgi_param SERVER_NAME $server_name;
- # PHP only, required if PHP was built with --enable-force-cgi-redirect
- fastcgi_param REDIRECT_STATUS 200;
9,日誌及站點目錄
- mkdir /var/log/nginx
- chown -R www:www /www
10,啓動 Nginx
- /etc/init.d/nginx start
二-MySQL
1,安裝依賴
- apt-get install libncurses5-dev bison cmake
2,添加用戶
- adduser --system --disabled-login --home /opt/mysql --group mysql
3,編譯安裝
- wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://ftp.jaist.ac.jp/pub/mysql/ -O mysql-5.5.15.tar.gz
- tar zxvf mysql-5.5.15.tar.gz
- cd mysql-5.5.15
- cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DINSTALL_DATADIR=/opt/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_MYISAM_STORAGE_ENGINE=1
- make & make install
- sh scripts/mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql
4,配置文件及啓動腳本,並添加自啓動
- cp support-files/my-medium.cnf /etc/mysql/my.cnf
- cp support-files/mysql.server /etc/init.d/mysqld
- chmod +x /etc/init.d/mysqld
- update-rc.d mysqld defaults
5,啓動 MySQL 並設置 root 帳戶密碼
- /etc/init.d/mysqld start
- /opt/mysql/bin/mysqladmin -u root password 'yourpassword'
6,安裝 phpMyAdmin 3.4.4
- wget -O phpMyAdmin-3.4.4-all-languages.tar.xz http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.4/phpMyAdmin-3.4.4-all-languages.tar.xz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1315241108&use_mirror=cdnetworks-kr-1
- tar Jxvf phpMyAdmin-3.4.4-all-languages.tar.xz
- mv phpMyAdmin-3.4.4-all-languages/ /www/phpmyadmin
三-PHP
1,安裝依賴
- apt-get install autoconf2.13 libxml2-dev libbz2-dev libcurl4-gnutls-dev libjpeg-dev libpng12-dev libxpm-dev libfreetype6-dev libmcrypt-dev libmysqlclient15-dev libxslt1-dev
- export PHP_AUTOCONF="/usr/bin/autoconf2.13"
2,編譯安裝
- wget http://jp2.php.net/distributions/php-5.3.8.tar.bz2
- tar jxvf php-5.3.8.tar.bz2
- cd php-5.3.8
- ./buildconf --force
- ./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc --with-config-file-scan-dir=/opt/php/etc/conf.d --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-curl --with-pear --with-gd --with-jpeg-dir --with-png-dir --with-zlib --with-xpm-dir --with-freetype-dir --with-mcrypt --with-mhash --with-pdo-mysql --with-openssl --with-xmlrpc --with-xsl --with-bz2 --with-gettext --disable-debug --enable-exif --enable-wddx --enable-zip --enable-bcmath --enable-calendar --enable-ftp --enable-mbstring --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-shmop --enable-dba --enable-sysvsem --enable-sysvshm --enable-sysvmsg
- make & make install
- cp php.ini-production /opt/php/etc/php.ini
- cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
3,配置文件,保存至 /opt/php/etc/php-fpm.conf
- pid = run/php-fpm.pid
- error_log = log/php-fpm.log
- log_level = notice
- listen = 127.0.0.1:9000
- listen.allowed_clients = 127.0.0.1
- listen.owner = www
- listen.group = www
- listen.mode = 0666
- user = www
- group = www
- pm = dynamic
- pm.max_children = 50
- pm.start_servers = 5
- pm.min_spare_servers = 5
- pm.max_spare_servers = 35
- pm.max_requests = 500
- env[HOSTNAME] = $HOSTNAME
- env[PATH] = /usr/local/bin:/usr/bin:/bin
- env[TMP] = /tmp
- env[TMPDIR] = /tmp
- env[TEMP] = /tmp
4,啓動腳本,保存至 /etc/init.d/php-fpm
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: php-fpm
- # Required-Start: $remote_fs $network
- # Required-Stop: $remote_fs $network
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: starts php-fpm
- ### END INIT INFO
- set -u
- DAEMON="PHP FPM"
- FPM_CMD=/opt/php/sbin/php-fpm
- FPM_CONF=/opt/php/etc/php-fpm.conf
- FPM_PID=/opt/php/var/run/php-fpm.pid
- TIMEOUT=30
- FPM_OPTIONS="--fpm-config $FPM_CONF"
- SSD_OPTIONS="--oknodo --quiet --pidfile $FPM_PID --exec $FPM_CMD"
- . /lib/lsb/init-functions
- #
- # Function to check the correctness of the config file
- #
- do_check()
- {
- [ "$1" != "no" ] && $FPM_CMD $FPM_OPTIONS -t 2>&1 | grep -v "\[ERROR\]"
- FPM_ERROR=$($FPM_CMD $FPM_OPTIONS -t 2>&1 | grep "\[ERROR\]")
- if [ -n "${FPM_ERROR}" ]; then
- echo "Please fix your configuration file..."
- $FPM_CMD $FPM_OPTIONS -t 2>&1 | grep "\[ERROR\]"
- return 1
- fi
- return 0
- }
- case "$1" in
- start)
- log_begin_msg "Starting $DAEMON..."
- if do_check no ; then
- /sbin/start-stop-daemon --start $SSD_OPTIONS -- $FPM_OPTIONS
- log_end_msg $?
- else
- log_end_msg 1
- fi
- ;;
- stop)
- log_begin_msg "Stopping $DAEMON..."
- /sbin/start-stop-daemon --stop $SSD_OPTIONS
- log_end_msg $?
- ;;
- graceful-stop)
- log_begin_msg "Gracefully stopping $DAEMON..."
- /sbin/start-stop-daemon --stop --retry QUIT/$TIMEOUT/TERM $SSD_OPTIONS
- log_end_msg $?
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- reload|force-reload)
- log_begin_msg "Reloading $DAEMON..."
- /sbin/start-stop-daemon --stop --signal USR2 $SSD_OPTIONS
- log_end_msg $?
- ;;
- *)
- echo "Usage: $0 {start|stop|graceful-stop|restart|reload|force-reload}"
- exit 1
- ;;
- esac
5,添加自啓動
- chmod +x /etc/init.d/php-fpm
- update-rc.d php-fpm defaults
6,安裝 Alternative PHP Cache
- /opt/php/bin/pecl install apc
7,APC 配置文件,保存至 /opt/php/etc/conf.d/apc.ini
- extension = apc.so
- apc.enabled = 1
- apc.shm_segments = 1
- apc.shm_size = 128M
- apc.optimization = 0
- apc.num_files_hint = 4096
- apc.ttl = 7200
- apc.user_ttl = 7200
- apc.gc_ttl = 0
- apc.cache_by_default = 1
- apc.filters = ""
- apc.mmap_file_mask = "/tmp/apc.XXXXXX"
- apc.slam_defense = 0
- apc.file_update_protection = 2
- apc.enable_cli = 0
- apc.max_file_size = 10M
- apc.stat = 1
- apc.write_lock = 1
- apc.report_autofilter = 0
- apc.include_once_override = 0
- ;apc.rfc1867 = 0
- ;apc.rfc1867_prefix = "upload_"
- ;apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
- ;apc.rfc1867_freq = 0
- apc.localcache = 0
- apc.localcache.size = 512
- apc.coredump_unmap = 0
- apc.stat_ctime = 0
6,啓動 PHP
- /etc/init.d/php-fpm start
四-終
- reboot
乾淨安裝 Lion 10.7.1 之筆記
- 從 AppStore 下載 Lion 10.7.1。按住 Option 點選 purchased 即可重新選擇安裝。
- 下載完畢後取消安裝,從 “/Applications/Install Mac OS X Lion.app/Contents/SharedSupport” 中提取安裝鏡像 InstallESD.dmg
- 燒製鏡像到 DVD 或恢復鏡像到其他分區/U 盤
- 重啓,按 Option 選擇引導設備,按提示安裝即可
走到最後一步時出現若干問題:
- 安裝完重啓後出現禁止圖標。Google 一下,大神說這是黑蘋果的典型問題,坑爹呢 =.=!
- 再次重裝,安裝程序引導失敗,只是提示“請嘗試再次安裝”。再問 Google 大神,找到一靠譜的答案,參照官方文檔清空 NVRAM (登陸到系統後可使用 nvram 命令讀寫 NVRAM),搞定
- 以上兩個問題出現的根本原因是把 Lion 裝到了加密分區上,只能先裝到非加密分區,進入系統後再啓用 FileVault
- 系統分區亦不可使用大小寫敏感的,否則諸如 Photoshop 之類的 Adobe 系軟件是無法安裝的。話說正是有了上次使用大小寫敏感文件系統的經驗,才有了這次的系統重灌 =.=!
是以為記。