doumao1047 2016-11-22 17:55
浏览 105

我尝试在部署到Ubuntu VPS后访问我的Symfony应用程序时出现fsockopen()错误500

EDIT2: APC is installed and enabled. what would be the solution?

I'm trying to deploy a symfony app to a VPS. I deployed the code from git ok, I installed vendors and check /web/config.php to fix all the major and recommended issues on Symfony requirements. It's all green.

However, when I try to access the [VPS_IP]/my_project/web/app.php I get a page isn't working. [my_ip] is currently unable to handle the request.

I also tried to configure virtual host and try to access my Symfony app on the [my_ip] only as URL address and I get the same result.

I've enabled apache 2 mod rewrite, I've added and enabled all the necessary php extensions, I've set date.timezone in php.ini, I've also looked in the dev.log files and tehre I have this error which may be the cause:

[2016-11-22 14:45:49] php.DEBUG: fsockopen(): unable to connect to 127.0.0.1:800           0 (Connection refused) {"type":2,"file":"/var/www/html/giftbundle/vendor/symfony           /symfony/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php","line":59           ,"level":28928} []

Could anyone provide some help?

config.yml

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: "@MyVendorBundle/Resources/config/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: en

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:  ~
        save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
    fragments:       ~
    http_method_override: true
    assets: ~

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes:
        - 'bootstrap_3_layout.html.twig'

# 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 }

# app/config/config.yml
#knp_menu:
    # use "twig: false" to disable the Twig extension and the TwigRenderer
#    twig:
#        template: knp_menu.html.twig
    #  if true, enables the helper for PHP templates
#    templating: false
    # the renderer to use, list is also available by default
#    default_renderer: twig

assetic:
    debug:          '%kernel.debug%'
    use_controller: '%kernel.debug%'
    filters:
        cssrewrite: ~

gregwar_captcha: ~

liip_imagine:
    filter_sets:
        cover_filter:
            filters:
                thumbnail:
                    size: [600, 400]
                    mode: inset
        prod_thumbnail:
            filters:
                thumbnail:
                    size: [50, 50]
                    mode: inset

#web_profiler:
#    toolbar: true
#    position: bottom
#    intercept_redirects: false
#    excluded_ajax_paths:  ^/bundles|^/_wdt    

parameters.yml

# This file is auto-generated during the composer install
parameters:
    database_host: [another remote DB IP]
    database_port: 3306
    database_name: [remote DB name]
    database_user: [Remote DB user]
    database_password: [remote DB PSW]
    mailer_transport: sendmail
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    secret: rodacsoft
    facebook_app_id: [fb_app_ID] 
    facebook_app_secret: [fb_secret]

VPS /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>

    DocumentRoot /var/www/html/giftbundle/web
    <Directory /var/www/html/giftbundle/web>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ app.php [QSA,L]
        </IfModule>
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog /var/log/apache2/symfony_error.log
    CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>

EDIT: in the Symfony_error.log I have this. No clue how to fix it or if it's related.

[Tue Nov 22 14:46:06.216187 2016] [:error] [pid 21788] [client 159.153.60.77:18035] PHP Fatal error:  Uncaught Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: The service "validator.builder" has a dependency on a non-existent service "validator.mapping.cache.apc". in /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:58
Stack trace:
#0 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)
#1 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)
#2 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnIn in /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php on line 58
  • 写回答

1条回答 默认 最新

  • dozc1071 2016-11-23 21:23
    关注

    Check if cache folder is writable by apache (www-data) user. You cannot access [VPS_IP]/my_project/web/app.php because you already defined web/ folder as root folder in apache config. You should define ServerName and ServerAlias in apache config with your domain name or try direct access to [VPS_IP]/app.php. Also enter your IP to app_dev and access [VPS_IP]/app_dev.php for more clear errors.

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮