|
真不好意思了,
http://www.hostloc.com/viewthrea ... p;page=1&extra=
这篇文章,以前写的时候不怎么认真,代码没仔细看。
前两天用到自己的站上(我的站流量还是有一些的,虽然不算大站,也不能算小站了),开始的时候一切正常,今天下午发现浏览全是502.504等。。。遂系统重启,故障依旧,再重启,还是老样子,想想可能是代码不对,重新仔细看了一下,写得马虎啊,有严重的内存泄漏问题,原来在站点正常运行的情况下,编译覆盖上去,重启nginx和php,可能缓存或者用户没有集中刷新压力小暂时正常,时间长了就出问题了。重启操作系统用户全都在拼命刷新,压力大,所以一重启问题也暴露出来了。
现在已经完全修正,我站点正在使用,完全正常,编译后重启完全OK,其实加上的代码流程很简单,马虎所致,现在没有内存泄漏了。请使用了的同学重新修改,重新编译。另附上freebsd port安装的办法。
freebsd port安装的软件,通常都会给七七八八的加上一些补丁,所以用make extract,然后修改源码,编译的方法可能会有问题,所以以前我一直没给自己服务器装上这个东西。我站点系统是 FreeBSD的。
make extract ==》你手工修改源码 ==》make ==> freebsd开始给你装补丁。//这样补丁起来也许会有问题,因为补丁的是你修改过的文件了。
tar vxfz php-5.2.10-fpm-0.5.13.tar.gz --directory /usr/ports/lang
cd /usr/ports/lang/php5-fpm
我的办法是 make ,不要make install,然后
ee /usr/ports/lang/php5-fpm/work/php-5.2.10/main/fopen_wrappers.c
把下面两个 // add by anxsoft.com 之间的代码加上.然后拷贝到其他位置。
cp /usr/ports/lang/php5-fpm/work/php-5.2.10/main/fopen_wrappers.c ~
make clean //这里一定要先清理,接下来make就能重新编译了
make install clean//上面清理掉work什么的目录了,这里在系统make的过程中,你要另开一个控制台。以迅雷不及掩耳之势,把修改过的 fopen_wrappers.c 覆盖回去。注意观察,/usr/ports/lang/php5-fpm/work/php-5.2.10/main/fopen_wrappers.c 文件扩展开来后,覆盖回去。
cp -f ~/fopen_wrappers.c /usr/ports/lang/php5-fpm/work/php-5.2.10/main/
等待编译完成,结束。
下面的是FreeBSD的。CentOS的请到 http://www.hostloc.com/viewthrea ... p;page=1&extra= 查看。- /* {{{ php_check_open_basedir
- */
- PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
- {
- /* Only check when open_basedir is available */
- if (PG(open_basedir) && *PG(open_basedir)) {
- char *pathbuf;
- char *ptr;
- char *end;
- char path_copy[MAXPATHLEN];
- int path_len;
- /* Special case path ends with a trailing slash */
- path_len = strlen(path);
- if (path_len >= MAXPATHLEN) {
- errno = EPERM; /* we deny permission to open it */
- return -1;
- }
- if (path_len > 0 && path[path_len-1] == PHP_DIR_SEPARATOR) {
- memcpy(path_copy, path, path_len+1);
- while (path_len > 1 && path_copy[path_len-1] == PHP_DIR_SEPARATOR) path_len--;
- path_copy[path_len] = '\0';
- path = (const char *)&path_copy;
- }
- // add by anxsoft.com
- char *env_doc_root;
- if(PG(doc_root)){
- env_doc_root = estrdup(PG(doc_root));
- }else{
- env_doc_root = sapi_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);
- }
- if(env_doc_root){
- int res_root = php_check_specific_open_basedir(env_doc_root, path TSRMLS_CC);
- efree(env_doc_root);
- if (res_root == 0) {
- return 0;
- }
- if (res_root == -2) {
- errno = EPERM;
- return -1;
- }
- }
- // add by anxsoft.com
- pathbuf = estrdup(PG(open_basedir));
- ptr = pathbuf;
- while (ptr && *ptr) {
- int res;
- end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
- if (end != NULL) {
- *end = '\0';
- end++;
- }
- res = php_check_specific_open_basedir(ptr, path TSRMLS_CC);
- if (res == 0) {
- efree(pathbuf);
- return 0;
- }
- if (res == -2) {
- efree(pathbuf);
- errno = EPERM;
- return -1;
- }
- ptr = end;
- }
- if (warn) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s)", path, PG(open_basedir));
- }
- efree(pathbuf);
- errno = EPERM; /* we deny permission to open it */
- return -1;
- }
- /* Nothing to check... */
- return 0;
- }
- /* }}} */
复制代码
[ 本帖最后由 freebsd 于 2010-1-13 21:32 编辑 ] |
评分
-
查看全部评分
|