Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[已解决] 完美解决nginx环境下服务器上多站点WebShell访问限制问题

[复制链接]
junhan 发表于 2009-11-27 23:50:55 | 显示全部楼层 |阅读模式
本帖最后由 junhan 于 2009-12-1 16:15 编辑

本办法是修改php来实现的,故使用范围应该不限于nginx,也可以应用到其他的web服务器上。
本人测试环境:centos 5 64bit   nginx/0.7.63 PHP 5.2.10
  1. wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror
  2. wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz
  3. tar zxvf php-5.2.10.tar.gz
  4. gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
  5. cd php-5.2.10/
  6. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-ftp --without-pear
复制代码
  1. vi main/fopen_wrappers.c
复制代码
找到:
  1. /* {{{ php_check_open_basedir
  2. */
  3. PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
  4. {
  5. /* Only check when open_basedir is available */
  6. if (PG(open_basedir) && *PG(open_basedir)) {
  7. char *pathbuf;
  8. char *ptr;
  9. char *end;
  10.   
  11. 下面加上:
  12. char *env_document_root = sapi_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);
  13. if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) {
  14. efree(env_document_root);
  15. return 0;
  16. }
复制代码
然后保存,退出。

php.in的open_basedir配置:
修改:
;open_basedir =

open_basedir = "/tmp/:/var/tmp/"

重启
/usr/local/php/sbin/php-fpm restart

方法转载于安兴软件工作室: http://www.anxsoft.com

http://www.hujunhan.cn/post/12/
 楼主| junhan 发表于 2009-12-1 16:16:17 | 显示全部楼层
以前用NGINX很担心权限问题现在总于解决啦`好贴没人顶啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-2 07:04 , Processed in 0.119936 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表