LNMP-php-fpm定义open_basedir


在php-fpm的pool池中,定义open_basedir限制用户访问文件的活动范围限制在指定的区域,通常是指站点的home目录路径。
1:编写conf文件
[root@host2 ~]# vim /usr/local/php-fpm/etc/php-fpm.d/test.conf
加入以下红色内容
[test]
listen = /tmp/test.sock
listen.mode=666
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
request_slowlog_timeout = 1
slowlog = /usr/local/php-fpm/var/log/test-slow.log
php_admin_value[open_basedir]=/data/www/test_com:/tmp/
2:重新启动服务
[root@host2 ~]# /etc/init.d/php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
Nginx虚拟主机事先已经配置完成,不需要进行操作,配置如下
[root@host2 ~]# cat /usr/local/nginx/conf/vhosts/test.conf
server{
listen 80;
server_name www.test.com;
access_log /tmp/test.com-access.log;
error_log /tmp/test.com-error.log;
root /data/www/test_com;
location ~ \.php$ {
root html;
fastcgi_pass unix:/tmp/test.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/test_com$fastcgi_script_name;
include fastcgi_params;
}
}
3:curl测试访问定义open_basedir站点中的文件
[root@host2 ~]# curl -x127.0.0.1:80 www.test.com/1.php
test php scripts.

长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn