Zend Framework on shared hosting

后端 未结 12 1417
孤独总比滥情好
孤独总比滥情好 2020-12-04 17:01

I\'m new to Zend Framework. I would like to know how to implement zend framework on a shared hosting. Because of the zend framework folder structure all view files are put i

相关标签:
12条回答
  • 2020-12-04 17:52

    Actually I've searched for it and found a lot of answers (most of them here on SO), but none of them worked for me. So I finally found a solution - .htaccess on root dir:

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php
    

    This one from http://framework.zend.com/wiki/display/ZFDEV/Configuring+Your+URL+Rewriter and index.php on root dir:

    <?php 
    define('RUNNING_FROM_ROOT', true);
    include 'public/index.php';
    ?>
    

    This one from http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/ And it works for me even if there are other project dir in root folder - like forum or so. Thought it might be useful to someone :)

    0 讨论(0)
  • 2020-12-04 17:52

    . . . How Magento uses Zend framework??? I'm using XAMPP and I did install Magento locally without modify php.ini, http.conf nor virtual host.

    0 讨论(0)
  • 2020-12-04 17:53

    You should place your project's Public folder to www folder in the host, so your address will become yourdomain.com/. Your source code folder such as library, applications... should be place at same level with www folder, not within it. This method will promote the security of your site

    0 讨论(0)
  • 2020-12-04 17:53

    I encountered this problem recently and through this thread i was able to find a solution. I am using zf2. So all i had to do was have the zend related files in a directory we can name say src. This directory will reside in the public or root directory (such as /www)

    1. Create a .htaccess file in the 'src' dir and add the Deny from All directive.

    2. In the index file, change the working directory to the src folder by doing the following:

      define('SRC_ROOT', 'src');
      chdir(SRC_ROOT);
      

    ...and you are good to go!

    0 讨论(0)
  • Also Rob Allen wrote a good solution

    I'm using Zend Framework 2 and it worked for me. Alghough I haven't done part "Referencing public facing files" from above link.

    I just changed code in my layout.phtml from:

    $basePath = $this->basePath();
    

    to:

    $basePath = $this->basePath();
    if (defined('RUNNING_FROM_ROOT')) {
        $basePath .= 'public/';
    }
    
    0 讨论(0)
  • 2020-12-04 17:55

    Indeed it's not the best idead to run Zend Framework applications on a shared hosting. I would really recommend getting a virtual private hosting (VPS). There are very good and inexpensive hostings out there with Zend Framework and other frameworks already installed and regularly updated. I'm on servergrove and it has been great so far!

    But this doesn't mean that you can't make it work on a shared hosting. You just have to rather work with .htacess. Put the content of the public folder into your webroot and adjust your paths in the bootstrap.php, make sure all other folders cannot be accesses directly and use the usual ZF approach of routing everything through your index.php.

    0 讨论(0)
提交回复
热议问题