2014-01-06 104 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

相关问题