寻觅生命中的那一片浅草......

每日存档 九月 18th, 2015

WordPress更新设置

今天更新,老提示输入ftp连接信息,实在不想开ftp,于是搜索了些资料,记录如下

一、确保Nginx和PHP-FPM用同一个用户运行
本例中是nginx用户

grep user /etc/nginx/nginx.conf
egrep 'user|group' /etc/php-fpm.d/www.conf

二、设置WordPress为nginx用户所有

chown -R nginx.nginx /data/web/wp

三、修改WordPress配置

vi wp-config.php
define('FS_METHOD', 'direct');

现在去后台更新,就不会提示输入ftp信息了。

Using flock() in Bash without invoking a subshell

我们目前利用了flock来限制并发,通常是用一个小括号把需要执行的代码包含起来,这样就会产生一个子shell,带来的问题是父shell无法获得子shell的返回值,昨天刚好Google到这个文章,在这里贴下。

#!/bin/bash

(
flock -s 200

# … commands executed under lock …

) 200>/var/lock/mylockfile
Unfortunately, this invokes a subshell which has the following drawbacks:

You cannot pass values to variables from the subshell in the main shell script.
There is a performance penalty.
The syntax coloring in “vim” does not work properly. :)
This motivated my colleague zImage to come up with a usage form which does not invoke a subshell in Bash:

#!/bin/bash

exec 200>/var/lock/mylockfile || exit 1
flock -n 200 || { echo “ERROR: flock() failed.” >&2; exit 1; }

# … commands executed under lock …

flock -u 200

原文见:Using flock() in Bash without invoking a subshell

2015年九月
« 8月   10月 »
 123456
78910111213
14151617181920
21222324252627
282930