Tag Archives: tips

libpcre.so.1: cannont open shared object file: No such file or directory.

after installed nginx, got some error message when raunch as: `/opt/nginx/sbin/nginx`

/opt/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

still i’m sure i’ve installed the latest pcre. and also i can find the libpcre.so.1 with:

find /usr/ -name "libpcre.so.1"

ok, why cannot found the libpcre.so.1 in `/user/local/lib` ??

strace /opt/nginx/sbin/nginx

So how does the dynamic loader know where to look for executables? As with many things on Linux, there is a configuration file in /etc. In fact, there are two configuration files, /etc/ld.so.conf and /etc/ld.so.cache. Note that /etc/ld.so.conf specifies that all the .conf files from the subdirectory ld.so.conf.d should be included.
Dynamic library configuration

ldconfig -p | grep "libpcre.so.1"

not found any matches.

so the problem is the dynamic loader not serach for my lib dir in /usr/local/lib

Then Use shared libraries in /usr/local/lib??

For the current session you can

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

or to make the change permanent you can add /usr/local/lib to /etc/ld.so.conf (or something it includes) and run `ldconfig` as root.

keep reading. If not, read aboout ldconfig first.

after all, grep it:

ldconfig -p | grep "libpcre.so.1"
libpcre.so.1 (libc6,x86-64) => /usr/local/lib/libpcre.so.1

ok, got it!
run again /opt/nginx/sbin/nginx

that all..

these are some keyword need to read for details: `strace`, `ldconfig`, `/etc/ld.conf`, `/etc/ld.conf.cache`.

osx (mac) 下面在 /home/新建目录或ln -sf 目录问题


因为平时都是用的 linux, 很多项目的配置都是基于 /home/allex/
但是在mac下用户目录为 /Users/allex
想到直接把 symlink 过来

ln -sf /User/allex /home/allex

系统始终提示: foldername: Operation not supported

google logs:

You need to disable automount. Use sudo vi /etc/auto_master to comment out the /home line. My auto_master file looks like:

# Automounter master map
+auto_master        # Use directory service
/net            -hosts      -nobrowse,hidefromfinder,nosuid
# /home         auto_home   -nobrowse,hidefromfinder
/Network/Servers    -fstab
/-          -static

NOTE: The /home directory is a link to a network drive. If the drive doesn’t exist on your network, a dummy drive is in its place with zero capacity. You cannot place anything in that location.

phpMyAdmin – #2002 Cannot log in to the MySQL server

终端下可以登录mysql,但是用phpmyadmin无法登录提示:#2002 Cannot log in to the MySQL server


将$cfg['Servers'][$i]['host'] = ‘localhost’;
改为$cfg['Servers'][$i]['host'] = ’′;

修改 php.ini: mysql.default_socket = /tmp/mysql.sock

ps: 主要原因是因为本地 xampp 的 mysql 服务配置 my.cnf
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock

把路径 ln -sf 到 /tmp/mysql.sock 也可以。

Mac OS X 日常技巧总结(continuous updating)

Restarting the Mac OS X Dock, Finder, Spaces or Menubar

The Finder crashed:
killall -KILL Finder
(you can also restart the Finder by option (=alt) + rightclicking the Finder icon in the Dock and selecting Relaunch. It doesn’t always work though.)

The Dock/Spaces crashed:
killall -KILL Dock

The Menubar crashed/refuses to be clickable:
killall -KILL SystemUIServer

Clean Up Your Mac’s “Open With” Contextual Menu

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

How to: Check the bash shell script is being run by root or not

Sometime it is necessary to find out if a shell script is being run as root user or not.

When user account created a user ID is assigned to each user. BASH shell stores the user ID in $UID variable. Your effective user ID is stored in $EUID variable. You can

Old way…

You can easily add a simple check at the start of a script:


# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1

New way: Using EUID

# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1

Example: Mount /dev/sdb1 only if you are a root


if [[ $EUID -ne 0 ]]; then
  echo "You must be a root user" 2>&1
  exit 1
  mount /dev/sdb1 /mnt/disk2

Reference from http://www.cyberciti.biz/tips/shell-root-user-check-script.html

The final version function checkRoot

checkRoot() {
    if [ "x$EUID" = "x" ] ; then
      EUID=`id -u`
    if [ "$EUID" != 0 ] ; then
      case "`uname 2>/dev/null`" in
          # Cygwin: Assume root if member of admin group
          for g in `id -G 2>/dev/null` ; do
            case $g in
              0|544) root=t ;;
          done ;;
      if [ $root != t ] ; then
        echo "$self: You must run this as root" >&2
        exit 1

YUM Hangs And Won’t Respond

keyword: yum hangs and won’t respond

ssh 到测试机更新subversion1.7, 需要删除之前的老版本,发现yum命令没有响应,提示 “yum hangs and won’t respond”,

rm -f /var/lib/rpm/__*
rpm --rebuilddb -v -v   
yum clean all

If that did not work, you can set a debug level, error level and timeout for yum in /etc/yum.conf:


The timeout is standard 30 seconds. So if a repository does not respond, the error takes 30 seconds to appear. Also try using yum without the plugins (like fastest mirror and priorities) with the option –noplugins. Now starting yum again should give you more info faster. Test with:

yum --verbose --noplugins info

SVN commond tips

SVN undo files added

In Subversion, to cancel an svn add example_folder command before committing to the repository, do not use svn delete or svn remove or made-up stuff like undo or cancel.

Use the svn revert command:

svn revert -R example_folder

How to display a specific user’s commits in svn log?

svn log [SVNPath] --search <USERNAME> -l <LIMIT>

For example:

svn log . --search allex -l 100

Revert changes from specific commit / Undoing Changes

Attempt to revert some changes by a specific commit version: 854

svn merge -r 854:853 l3toks.dtx

Note: 注意版本号之间的顺序,这个叫反向合并 (reverse merger)


svn merge -c -854 l3toks.dtx

The two commands are equivalent.