2016-11-22 19 views
0

EDIT2:安裝並啓用了APC。解決方案是什麼?fsockopen()錯誤500當我在部署到Ubuntu VPS後嘗試訪問我的Symfony應用程序

我正在嘗試將一個symfony應用程序部署到VPS。 我從git中部署了代碼,我安裝了供應商並檢查/web/config.php來修復Symfony需求中的所有主要和推薦問題。這全是綠色的。

但是,當我嘗試訪問[VPS_IP] /my_project/web/app.php時,我得到一個頁面無法正常工作。 [my_ip]目前無法處理該請求。

我也嘗試配置虛擬主機,並嘗試訪問我的[my_ip]上的Symfony應用程序只作爲URL地址,我得到相同的結果。

我已經啓用了apache 2 mod重寫,我已經添加並啓用了所有必需的php擴展,我在php.ini中設置了date.timezone,我也查看了dev.log文件和tehre我有這個錯誤可能是原因:

[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} [] 

任何人都可以提供一些幫助嗎?

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> 

編輯:在Symfony_error.log我有這個。不知道如何解決它或如果它是相關的。

[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\nStack trace:\n#0 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)\n#1 /var/www/html/giftbundle/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php(51): Symfony\\Component\\DependencyInjection\\Compiler\\CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(Array)\n#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 
+0

從錯誤日誌中,我認爲您的Symfony項目啓用了APC緩存,並且您的服務器沒有安裝apc緩存 –

+0

@Szanto apcache從我在phpinfo中看到的狀態啓用。我怎麼去解決這個問題呢?改變它使用的Symfony應用緩存與別的東西,以防我的服務器不在我認爲的東西之外? –

+0

@SzántóZoltán或者更好的是,我如何配置Symfony使用服務器Memcache? –

回答

0

檢查緩存文件夾是否可由apache(www-data)用戶寫入。您無法訪問[VPS_IP] /my_project/web/app.php,因爲您已將web /文件夾定義爲apache配置中的根文件夾。您應該使用您的域名在apache配置中定義ServerName和ServerAlias,或嘗試直接訪問[VPS_IP] /app.php。 也輸入您的IP到app_dev並訪問[VPS_IP] /app_dev.php以獲取更明確的錯誤。

+0

緩存文件夾是可寫的,我解決了權限問題。我也嘗試過使用IP而不是Web文件夾,因爲我配置了我的虛擬主機。同樣的問題。我會嘗試獲取app_dev.php來檢查,但是,如果供應商使用--no-dev安裝,會給我提供信息? –

+0

我添加了app_dev.php,當我訪問頁面加載時,但沒有格式和資源,即使它們存在於Web文件夾中。 那麼,爲什麼沒有app_dev它不工作? –

+0

我修復了app_dev上的文檔根路徑和資產加載問題。PHP,但是當我嘗試訪問定期prod我得到**頁面無法正常工作。 [my_ip]目前無法處理該請求。** –

相關問題