【问题标题】:How to deploy Symfony3 Application on CentOS如何在 CentOS 上部署 Symfony3 应用程序
【发布时间】:2017-11-23 10:46:01
【问题描述】:

我仍然无法理解我的服务器中发生了什么 当我将代码推送到 /public_html 中的服务器并想像这样获取我的应用程序的主页时:

http://www.example.com/web/

服务器向我显示 /web 的内容(/web 中存在的文件和目录

这是在我按照步骤的命令行在该链接中部署 symfony 3 之后发生的: https://symfony.com/doc/3.1/deployment.html

我仍然无法理解那里发生了什么!

任何帮助将不胜感激!

【问题讨论】:

    标签: php symfony deployment symfony-3.2


    【解决方案1】:

    1-) yum install nginx

    2-)service nginx start

    3-) 将 Nginx 配置添加到/etc/nginx/conf.d/project_name.conf

    server{
        set $web_host "domain_name";
        set $web_root "web_directory";
    
        server_name $web_host;
        root $web_root;
    
        location / {
            try_files $uri /app.php$is_args$args;
        }
        # DEV
        # This rule should only be placed on your development environment
        # In production, don't include this and don't deploy app_dev.php or config.php
    #    location ~ ^/(app_dev|config)\.php(/|$) {
    #        fastcgi_pass 127.0.0.1:9000;
    #        fastcgi_split_path_info ^(.+\.php)(/.*)$;
    #        include fastcgi_params;
            # When you are using symlinks to link the document root to the
            # current version of your application, you should pass the real
            # application path instead of the path to the symlink to PHP
            # FPM.
            # Otherwise, PHP's OPcache may not properly detect changes to
            # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
            # for more information).
    #        fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
    #        fastcgi_param DOCUMENT_ROOT $realpath_root;
    #    }
        # PROD
        location ~ ^/app\.php(/|$) {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            # When you are using symlinks to link the document root to the
            # current version of your application, you should pass the real
            # application path instead of the path to the symlink to PHP
            # FPM.
            # Otherwise, PHP's OPcache may not properly detect changes to
            # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
            # for more information).
            fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT $realpath_root;
            # Prevents URIs that include the front controller. This will 404:
            # http://domain.tld/app.php/some-path
            # Remove the internal directive to allow URIs like this
            internal;
        }
    
        error_log /var/log/nginx/project_error.log;
        access_log /var/log/nginx/project_access.log;
    }
    

    4-) `chmod -R nginx:nginx /var/www/html/project`

    5-) service nginx restartservice php-fpm restart

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-03
      • 2021-11-28
      • 1970-01-01
      • 2016-01-24
      • 1970-01-01
      • 2010-10-11
      • 2018-07-20
      • 2021-03-16
      相关资源
      最近更新 更多