douwen1929 2014-01-06 17:44
浏览 36
已采纳

404部署zend应用程序之后

I've deployed a zend application on a local server(ubuntu), the default page works fine, but all the rest of application throw the 404 not found page.

my index.php

    // 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();

application.ini

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.params.displayExceptions = 0



resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
resources.frontController.params.prefixDefaultModule = "1"

resources.db.adapter = mysqli
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = ""
resources.db.params.dbname = assalam

[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

_initAutoLoader function in the Bootsrap file

protected function _initAutoLoad(){
        $modelLoader = new Zend_Application_Module_Autoloader(array(
                               'namespace'=>'',
                               'basePath'=>APPLICATION_PATH . '/modules/default'
                             ));
        if(Zend_Auth::getInstance()->hasIdentity()){
            Zend_Registry::set('role',Zend_Auth::getInstance()->getStorage()->read()->role);

        }else {
            Zend_Registry::set('role','Visiteurs');
        }

        $this->_acl = new Model_UsersAcls();
        $this->_auth = Zend_Auth::getInstance();

        $fc = Zend_Controller_Front::getInstance();
        $fc->registerPlugin(new Plugin_AccessCheck($this->_acl));

        return $modelLoader;
     }

the apache2.conf contains

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

the htaccess file contains

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

the virtual host code

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /var/www/

  <Directory /var/www/>
      Options +FollowSymlinks +SymLinksIfOwnerMatch
      AllowOverride All
  </Directory>
</VirtualHost>
  • 写回答

3条回答 默认 最新

  • doutan1970 2014-01-06 17:53
    关注

    Do you have your htaccess file set up?

    Does your server allow htaccess files to be run (check that AllowOverride is set to All in your server configuration file).

    As an example, here is the htaccess file from one of my projects:

    Options +FollowSymLinks 
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(.*)/(.*)$ index.php [NC,L]
    RewriteRule ^(.*)/(.*)/(.*)$ index.php [NC,L]
    RewriteRule ^(.*)/(.*)/(.*)/(.*)$ index.php [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    
    RewriteCond %{REQUEST_FILENAME} !^(.*)\.css$
    RewriteCond %{REQUEST_FILENAME} !^(.*)\.js$
    RewriteCond %{REQUEST_FILENAME} !public/gateway/(.*)$
    RewriteRule ^.*$ - [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line