Symfony2 open_basedir限制生效

时间:2016-01-18 15:59:45

标签: php symfony liipimaginebundle

我试图将symfony 2.7项目部署到共享主机。在localhost上一切正常,但在服务器上我出现了很大的错误......

当我尝试访问该网站时:

http://infinityproperty.sitetester.biz/

我收到了一个错误:

警告:is_dir():open_basedir限制生效。文件(/srv/www/infinityproperty.sitetester.biz/web)不在允许的路径中:

当我尝试输入3-4次时,它会删除错误,我可以看到结构。但问题出在那里。此外,没有显示liipimage的图像。

我已删除对区域设置的检查,可以看到错误:

http://infinityproperty.sitetester.biz/app_dev.php

我知道这很危险,我会在解决问题后彻底删除它。

app,bin等是私人文件夹中的一个目录。

这是基本配置:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: bg
    kernelRootDir: %kernel.root_dir%
    web: "/../../web"
framework:
    #esi:             ~
    translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    #serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    globals:
        kernelRootDir: %kernel.root_dir%
    form_themes:
        # other form themes
        - 'CoreBundle:VichForm:fields.html.twig'
# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [CoreBundle,FOSUserBundle,PagesBundle]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #     path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }
fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: George\UserBundle\Entity\User
simple_things_entity_audit:
    audited_entities:
        - George\PageBundle\Entity\Page
        - George\UserBundle\Entity\User
stof_doctrine_extensions:
    orm:
        default:
            sluggable: true
            sortable: true
            timestampable: true
vich_uploader:
    db_driver: orm
    mappings:
        product_image:
            uri_prefix:         /images/products
            upload_destination: %kernel.root_dir%/../../web/images/products
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        apartment_image:
            uri_prefix:         /images/apartment
            upload_destination: %kernel.root_dir%/../../web/images/apartment
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        slide_image:
            uri_prefix:         /images/slider
            upload_destination: %kernel.root_dir%/../../web/images/slider
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        point_image:
            uri_prefix:         /images/point
            upload_destination: %kernel.root_dir%/../../web/images/point
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        object_image:
            uri_prefix:         /images/object
            upload_destination: %kernel.root_dir%/../../web/images/object
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        gallery_image:
            uri_prefix:         /images/gallery
            upload_destination: %kernel.root_dir%/../../web/images/gallery
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
        company_image:
            uri_prefix:         /images/company
            upload_destination: %kernel.root_dir%/../../web/images/company
            inject_on_load:     false
            delete_on_update:   true
            delete_on_remove:   true
liip_imagine:
    resolvers:
       default:
          web_path: ~

    filter_sets:
        cache: ~
        my_thumb:
            quality: 75
            filters:
                thumbnail: { size: [120, 90], mode: outbound }
        720x534:
            quality: 75
            filters:
                thumbnail: { size: [720,534],  mode: outbound }
        1920x1440:
            quality: 75
            filters:
                thumbnail: { size: [1920,1440],  mode: outbound }
oneup_uploader:
    mappings:
        gallery:
            frontend: fineuploader # or any uploader you use in the frontend
            allowed_mimetypes: [image/jpeg,image/png,image/gif]
            namer:  oneup_uploader.namer.uniqid

a2lix_translation_form:
    locale_provider: default       # [1]
    locales: [bg, en]          # [1-a]
    default_locale: bg             # [1-b]
    required_locales: [bg]         # [1-c]
    manager_registry: doctrine      # [2]
    templating: "A2lixTranslationFormBundle::default.html.twig"      # [3]
swiftmailer:
    transport: '%mailer_transport%'
    host:      '%mailer_host%'
    username:  '%mailer_user%'
    password:  '%mailer_password%'
stfalcon_tinymce:
        tinymce_jquery: true
        selector: ".tinymce"
        # Get current language from the parameters.ini
        language: %locale%
        # Custom buttons
        tinymce_buttons:
            stfalcon: # Id of the first button
                title: "Stfalcon"
                image: "http://stfalcon.com/favicon.ico"
        theme:
            # Simple theme: same as default theme
            simple: ~
            # Advanced theme with almost all enabled plugins
            advanced:
                 plugins:
                     - "advlist autolink lists link image charmap print preview hr anchor pagebreak"
                     - "searchreplace wordcount visualblocks visualchars code fullscreen"
                     - "insertdatetime media nonbreaking save table contextmenu directionality"
                     - "emoticons template paste textcolor"
                 toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
                 toolbar2: "print preview media | forecolor backcolor emoticons | stfalcon | example"
                 image_advtab: true
                 templates:
                     - {title: 'Three columns', content: '<div class="firstColumn">aaaaaa</div><div class="secondColumn">aaaaaa</div><div class="thirdColumn">ccccc</div>'}
                     - {title: 'checklist', content: '<ul><li>Chek 1</li><li>Chek 1</li></ul>'}
            # BBCode tag compatible theme (see http://www.bbcode.org/reference.php)
            bbcode:
                 plugins: ["bbcode, code, link, preview"]
                 menubar: false
                 toolbar1: "bold,italic,underline,undo,redo,link,unlink,removeformat,cleanup,code,preview"

修改

这不是open_basedir的问题......这是项目的第一次部署,所以路径有一些问题......所以解决方案是清除所有缓存并使所有目录也具有适当的权限配置文件需要有点基本上应该保留核心symfony。

2 个答案:

答案 0 :(得分:1)

请注意,使用“ open_basedir”指令将禁用“ realpath_cache”的使用。

  

当您设置PHP的open_basedir限制时,PHP将停用真实路径缓存。   这将降低任何使用多个文件(包括WordPress,Drupal和Magento)的PHP应用程序(包括include_once,require_once)的性能-仅举几例。   当PHP团队修复了CVE-2006-5178时,决定使用open_basedir(和以前的safe_mode)限制停用真实路径缓存。有关更多信息,请参见PHP的错误报告52312。

我已经挖掘了几天,直到发现了。 Symfony在很大程度上依赖于缓存,这使我的项目从约1000ms到约60ms的性能飞速上升。但是您必须考虑可能的安全风险...

答案 1 :(得分:0)

您可以完全删除open_basedir限制。手动修改 php.ini 文件或在WebSites -> Your Site -> Options -> Custom php.ini settings找到的控制面板中将其修改为:

open_basedir =

这应该可以解决您的问题。如果您仍然担心这是危险的,您也可以手动将基目录设置为您的文件夹:

open_basedir = /srv/www/infinityproperty.sitetester.biz/web