2014-01-06 105 views
1

我在本地服務器(ubuntu)上部署了一個zend應用程序,默認頁面正常工作,但應用程序的其餘部分都拋出404找不到頁面。在Bootsrap部署zend應用程序後的404

我的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函數文件

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; 
    } 

的apache2.conf包含

<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> 

htaccess的文件包含

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] 

虛擬主機代碼

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

    <Directory /var/www/> 
     Options +FollowSymlinks +SymLinksIfOwnerMatch 
     AllowOverride All 
    </Directory> 
</VirtualHost> 

回答

0

你有你的htaccess文件設置?

您的服務器是否允許運行htaccess文件(檢查服務器配置文件中的AllowOverride是否設置爲全部)。

作爲一個例子,這裏是我的一個項目的htaccess文件:

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] 
+0

這是我的.htaccess RewriteEngine敘述在 的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] – user3166336

+0

我做了它,但現在我無法訪問公共文件夾,它不可見,並出現內部服務器錯誤頁面 – user3166336

+0

我把我的一個htaccess文件的例子在這裏供您比較。 – Elie

0

你是怎麼部署的?您使用Zend Server Deployment嗎?你有沒有設置虛擬主機?你在打什麼網址?什麼是項目路徑?

+0

我沒有使用Zend服務器 我有我作爲服務器使用,基於Ubuntu的服務器和Apache上的機器。我將所有文件複製到www目錄。 的URL是192.168.1.30,應用程序路徑是默認的一個「公共」,當我輸入192.168.1.30/public時,前臺被重播,但是當我想導航到其他路徑時,像192.168.1.30/public/authentification /登錄404頁面出現,並且與所有其他頁面相同 – user3166336

+0

然後確認AllowOverride。你的VirtualHost配置必須設置AllowOverride才能看到Elie的評論。 – CBergau

+0

我做了它,但現在我無法訪問公用文件夾,它不可見並且出現內部服務器錯誤頁面 – user3166336

0

請檢查您是否有一個虛擬主機,如果不能創造這樣的例子:

<VirtualHost *:80> 
    ServerName helloWorld.dev 
    DocumentRoot /Users/myuser/Sites/HelloWorld/public 

    <Directory /Users/myuser/Sites/HelloWorld/public> 
     Options +FollowSymlinks +SymLinksIfOwnerMatch 
     AllowOverride All 
    </Directory> 
</VirtualHost> 

還在你的主機上的文件

127.0.0.1  helloWorld.dev 

我會建議檢查文件夾權限

myuser:HelloWorld myuser$ ll 
total 0 
drwxr-xr-x 8 myuser staff 272B Jan 6 11:54 application 
drwxr-xr-x 3 myuser staff 102B Jan 6 11:54 docs 
drwxr-xr-x 4 myuser staff 136B Dec 28 20:54 library 
drwxr-xr-x 4 myuser staff 136B Jan 6 11:54 public 
drwxr-xr-x 6 myuser staff 204B Jan 6 11:54 tests 
myuser:HelloWorld myuser$ pwd 
/Users/myuser/Sites/HelloWorld 
myuser:HelloWorld myuser$ 

在文件/etc/apache2/users/myuser.conf中添加以下定義。如果這個文件不存在,創建它

<Directory "/Users/myuser/Sites/"> 
    Options Indexes MultiViews 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory> 
+0

我不知道如何使用虛擬主機,因爲我有一臺機器,我用作服務器,我的應用程序是在這根/ var/www /,並且url是192.168.1.30 – user3166336

+0

我試圖添加虛擬主機但總是公用文件夾不出現,我把虛擬主機的代碼請求 – user3166336

+0

我很久以前用公用文件夾遇到同樣的問題我在/ etc/apache2/users上創建了一個名爲myuser.conf的文件,其定義如下 選項索引MultiViews AllowOverride無 Ord呃允許,否認 全部允許 – ELavicount

相關問題