如何在托管服务器上配置 Zend 2? [英] How to configure Zend 2 on a hosting server?

查看:29
本文介绍了如何在托管服务器上配置 Zend 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 xampp 中创建了一个虚拟主机:www.attila-naghi.ro.我把我的项目放在那里,它工作得很好.现在我想把它放在网上,在一个托管服务器上.我观察到我的 css 和 js 没有加载,如果我访问控制器,我得到 404.这是 URL.谁能帮我?谢谢

I created a virtual host: www.attila-naghi.ro in the xampp. I put my project there and it works perfectly. Now I want to put it online, on a hosting server. I observed that my css and js are not loaded and if I access the controllers, I get the 404. This is the URL. Can anyone help me? thx

这是我的 module.config.php 文件:

This is my module.config.php file:

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

return array(
    'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'Application\Controller\Index',
                        'action'     => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'default' => array(
                        'type' => 'Segment',
                        'options' => array(
                            'route' => '[:controller[/:action]][/:param1]',
                            'constraints' => array(
                                'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
                            ),
                            'defaults' => array(
                                'action' => 'index',
                                '__NAMESPACE__' => 'Application\Controller',
                               // 'param1' => 'tralala'
                            )
                        )
                    )
                )
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
    ),
    'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'Application\Controller\Index'          => 'Application\Controller\IndexController',
            'Application\Controller\Create'         => 'Application\Controller\CreateController',
            'Application\Controller\Blog'           => 'Application\Controller\BlogController',
            'Application\Controller\Portofolio'     => 'Application\Controller\PortofolioController',
            'Application\Controller\User'           => 'Application\Controller\UserController',
        ),
    ),
    'view_manager' => array(
        'base_path' => 'http://www.attila-naghi.com/',
        'display_not_found_reason' => true,
        'display_exceptions'       => true,
        'doctype'                  => 'HTML5',
        'not_found_template'       => 'error/404',
        'exception_template'       => 'error/index',
        'template_map' => array(
            'layout/layout'           => __DIR__ . '/../view/layout/layout.phtml',
            'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
            'error/404'               => __DIR__ . '/../view/error/404.phtml',
            'error/index'             => __DIR__ . '/../view/error/index.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../view',
        ),
    ),
    // Placeholder for console routes
    'console' => array(
        'router' => array(
            'routes' => array(
            ),
        ),
    ),
);

推荐答案

如果您查看 Skeleton Application,您可以看到 /public 目录.这些内容应该放入您服务器的公共目录中.例如,对于带有 cPanel 的服务器,它是 public_html.其他托管服务器可能有 www 或其他内容.

If you take a look at the Skeleton Application you can see the /public directory. The contents of those are supposed to go into whatever your server's public directory is. For example, for servers with cPanel it's the public_html. Other hosting servers may have www, or something else.

我最近上传了一个与上面完全一样的 Zend 骨架应用程序,它运行良好.如果您想知道如何处理原始(骨架的)目录 /public - 我将它与我的 public_html 一起留下,但您可以将其删除,因为它是空的.

I've recently uploaded a zend skeleton app doing exactly as above and it worked perfectly. If you wonder what to do with the original (Skeleton's) directory /public - I left it along with my public_html but you can remove it as it is empty.

这篇关于如何在托管服务器上配置 Zend 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆