centos上如何yum安装git?

需要先添加EPEL(Extra Packages for Enterprise Linux) repository:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

然后使用yum安装即可:

yum install git

From:http://51hired.com/questions/13038/centos%E4%B8%8A%E5%A6%82%E4%BD%95yum%E5%AE%89%E8%A3%85git

参考:什么是EPEL

Posted in Server | Leave a comment

给 git push 和 git pull 设置默认仓库

git config –global branch.master.remote origin
git config –global branch.master.merge refs/heads/master

参考:
git pull的默认地址
How do you get git to always pull from a specific branch?

Posted in Git | Leave a comment

博客文章开启评论

早期主机在国内的时候,由于众所周知的原因, 不得以全面关闭了文章的评论功能。如今已搬迁至香港机房,安全了,所以开启评论,:)

PS:感谢易联主机提供空间!

Posted in Life | Tagged | Leave a comment

Discuz X2 插件设计流程概要

基本方法

  1. 编辑 config/config_global.php,在页面底部新增如下内容以开启插件开发者模式

    // 为2则会在页面上输出所有的嵌入点
    $_config['plugindeveloper'] = 1;

  2. 登录到后台,完成以下工作
    1. 插件 -> 设计新插件,填入插件信息,提交
    2. 插件列表 -> 设计 -> 模块,新增“页面嵌入 – 普通版”类型的模块,程序模块可自定,这里设置为 main.class.php
    3. 插件列表 -> 设计 -> 变量,设置好插件所需要的变量(可选操作)
    4. 插件列表 -> 启用插件,方便后续调试
  3. 在插件目录下新建 main.class.php,包含全局嵌入点类和脚本嵌入点类,查看详细信息

特别注意:调试时注意随时在后台清空页面缓存

手机版

  1. 新建 mobile.class.php,类名前缀改为 mobileplugin_,其余同上
  2. 插件列表 -> 设计 -> 模块,新增“页面嵌入 – 手机版”类型的模块,填入 mobile.class.php
  3. 导出 xml 文件,将插件和 xml 文件上传至服务器,后台执行“升级”操作即可

更新历史

[2012.01.19] 新增手机版插件的开发方法

Posted in PHP | Tagged | Leave a comment

Git Bitbucket 使用方法

将本地代码推送到远程仓库

  1. 本地生成SSH key,并设定密码
    ssh-keygen
  2. 将/.ssh/id_rsa添加到你账户下的公钥列表中
  3. Git 中添加远程仓库
    git remote add <name>  git@bitbucket.org:lanisle/repo_name.git
  4. 推送代码
    git push <name> master

把代码从远程仓库拖回本地

  1. mkdir <repo_dir>
  2. cd <repo_dir>
  3. 初始化
    git init
  4. Git 中添加远程仓库
    git remote add <name> git@bitbucket.org:lanisle/repo_name.git
  5. 拉回代码
    git pull <name> master

PS:

  • <name>表示远程仓库在本地的标识,如果为origin表示为缺省配置,可直接git push,不需要附带标识
  • <repo_name>表示远程仓库名称。
Posted in Git | Leave a comment

使Git for Windows支持中文显示

Git for Windows是基于Cygwin实现的,在安装后的缺省配置下,ls打印出的内容和git log输出的结果都不支持中文显示。

修复方法为编辑<Git installtion dir>/etc/profile,增加如下内容:

# 自定义提示符
export PS1=’[\u@msys \W]$ ‘

# 文件夹和文件名支持中文显示
alias la=’/bin/ls -aF –show-control-chars –color=tty’
alias ll=’/bin/ls -alF –show-control-chars –color=tty’
alias ls=’/bin/ls –show-control-chars -F –color=tty’

# 使git log输出正常显示中文
export LESSCHARSET=utf-8

参考:http://www.cnblogs.com/baizx/archive/2010/08/09/1796120.html

Posted in Git | Leave a comment

Mac OS Lion 编译安装 php(with nginx)

安装nginx(当前版本 1.0.6)

brew install nginx
安装目录 /usr/local/Cellar/nginx/1.0.6

编译安装PHP(当前版本 5.3.8)

主要配置参数来源于Lion自带的php,本处做了部分修改,主要包括:

  • 移除 –with-icu-dir=/usr –enable-suhosin
  • 移除 –with-apxs2=/usr/sbin/apxs
  • 新增 –enable-fpm –enable-force-cgi-redirect
  • 修正libpng和freetype库文件目录错误
  • 移除其他无用参数

For fastcgi usage

./configure –prefix=/opt/php –with-config-file-path=/opt/php/etc –enable-fpm –enable-cgi –enable-cli –with-libxml-dir=/usr –with-openssl=/usr –with-kerberos=/usr –with-zlib=/usr –enable-bcmath –with-bz2=/usr –enable-calendar –with-curl=/usr –enable-dba –with-ndbm=/usr –enable-exif –enable-ftp –with-gd –with-freetype-dir=/usr/X11 –with-jpeg-dir=/usr/local –with-png-dir=/usr/X11 –enable-gd-native-ttf –with-iodbc=/usr –with-ldap=/usr –with-ldap-sasl=/usr –with-libedit=/usr –enable-mbstring –enable-mbregex –with-mysql=mysqlnd –with-mysqli=mysqlnd –without-pear –with-pdo-mysql=mysqlnd –with-mysql-sock=/tmp/mysql.sock –with-readline=/usr –enable-shmop –with-snmp=/usr –enable-soap –enable-sockets –enable-sqlite-utf8 –enable-sysvmsg –enable-sysvsem –enable-sysvshm –with-tidy –enable-wddx –with-xmlrpc –with-iconv-dir=/usr –with-xsl=/usr –enable-zend-multibyte –enable-zip –with-pcre-regex=/usr –with-pgsql=/usr –with-pdo-pgsql=/usr

For apache usage

./configure –prefix=/opt/php –disable-fpm –enable-cgi –with-apxs2=/usr/sbin/apxs –enable-cli…

sudo make
sudo make install

sudo cp php.ini-development /opt/php/etc/php.ini

cd /opt/php
sudo cp etc/php-fpm.conf.default etc/php-fpm.conf

配置PHP

sudo vim etc/php.ini

更新时区配置:

date.timezone = PRC

配置PHP-FPM

sudo vim etc/php-fpm.conf

去除如下选项的注释:

pid = run/php-fpm.pid
error_log = log/php-fpm.log
noticelog_level = notice
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500

sudo ln bin/php.dSYM bin/php
sudo ln sbin/php-fpm.dSYM sbin/php-fpm

配置nginx

vim /usr/local/etc/nginx/nginx.conf

更新内容:

location ~ \.php$ {
root           html;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}

vim /usr/local/etc/nginx/fastcgi_params

新增行:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

启动环境

sudo /opt/php/sbin/php-fpm
sudo nginx

结束环境

sudo kill `cat /opt/php/var/run/php-fpm.pid`
sudo nginx -s stop

关键备忘

1、配置PHP编译选项时候提示

configure: error: png.h not found.
configure: error: freetype.h not found.

表明 –with-freetype-dir 和 –with-png-dir 指向的目录不正确,应当修改为/usr/X11

2、提示 –enable-ndbm 参数无效

修正为 –enable-ndbm=/usr 即可

3、Lion下killall php-fpm 无法终止进程,必须按上文所述方法终止

4、如果与 Apache 搭配,使用上文提供的编译参数重编译后 sudo apachectl restart 即可。

5、如若想恢复自带 PHP 版本 5.3.6 ,找个朋友 Copy 份原始的 /usr/libexec/apache2/libphp5.so 覆盖回去即可。

6、php.dSYM 的后缀含义为 Apple Xcode debug symbols file,应该是编译环境导致的

UPDATE@2011.10.25

去除无用参数–enable-force-cgi-redirect
修正mysql sock文件的路径

TODO

配置 launchctl 使服务开机启动
安装libmcrypt,编译php时指定–with-mcrypt,资料

Posted in Mac OS | Tagged | Leave a comment

find命令-exec参数的使用

在Linux下,find命令用于查找匹配指定规则的文件,那么如果要对匹配的文件进行后续操作时,除了使用pipe结合xargs来处理外,还可以使用其自带的-exec参数。

-exec参数后带一个COMMAND,以分号“;”结尾,但由于“;”在shell下是用于表示单条语句已经结束,为了使我们的命令能够执行,需要使用反斜杠转义“;”,也就是“\;”

在COMMAND表达式中,一对花括号“{}”表示的是find命令匹配到的文件列表,执行时会被自动替换。

实际例子,删除指定目录下三天前的备份文件:

find /backup/daily_db -type f -mtime +3 -exec rm {} \;

Posted in Server | Tagged | Leave a comment