How to deploy and run a zend project on a server?

后端 未结 1 1776
误落风尘
误落风尘 2021-02-10 00:00

I have a question about deploying Zend project on a server. On localhost I used virtual host to set the document root to the public/index.php folder.

  • How should I
相关标签:
1条回答
  • 2021-02-10 00:17

    Simply copy your project on your server and set the domain directory pointer to the public folder. In most cases that should do the job.

    Another approach is to setup a vhost file and set the document root. You need this if you want a zf project to be accessible with a subdomain.

    But this is more a server configuration question.

    Application.ini:

    [production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    includePaths.library = APPLICATION_PATH "/../library"
    bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
    bootstrap.class = "Bootstrap"
    appnamespace = "Application"
    resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
    resources.modules = ''
    
    resources.frontController.params.displayExceptions = 1
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
    resources.frontController.defaultControllerName = "home"
    resources.frontController.params.prefixDefaultModule = "1"
    
    //some db setup
    
    [staging : production]
    
    [testing : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    
    [development : production]
    phpSettings.display_startup_errors = 1
    phpSettings.display_errors = 1
    resources.frontController.params.displayExceptions = 1
    

    .htaccess:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    

    I hope you didn't change the index.php file because you shouldn't:

    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
    
    // Define application environment
    defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    
    // Ensure library/ is on include_path
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        get_include_path(),
    )));
    
    /** Zend_Application */
    require_once 'Zend/Application.php';
    
    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini'
    );
    $application->bootstrap()
                ->run();
    
    0 讨论(0)
提交回复
热议问题