[英]404 after deploying zend application
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. 我已经在本地服务器(ubuntu)上部署了一个zend应用程序,默认页面工作正常,但是所有其他应用程序都抛出404 not found页面。
my index.php 我的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 的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 Bootsrap文件中的_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;
}
the apache2.conf contains 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>
the htaccess file contains 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]
the virtual host code 虚拟主机代码
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/
<Directory /var/www/>
Options +FollowSymlinks +SymLinksIfOwnerMatch
AllowOverride All
</Directory>
</VirtualHost>
How did you deploy it? 您是如何部署的? You used Zend Server Deployment? 您使用过Zend Server Deployment吗? Have you setup a virtual host? 您是否设置了虚拟主机? What URL are you calling? 你在叫什么URL? What is the projects path? 项目的路径是什么?
Do you have your htaccess file set up? 您是否设置了htaccess文件?
Does your server allow htaccess files to be run (check that AllowOverride is set to All in your server configuration file). 您的服务器是否允许htaccess文件运行(检查服务器配置文件中的AllowOverride设置为All)。
As an example, here is the htaccess file from one of my projects: 例如,这是我的一个项目的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]
Please check if you have a virtual host, if not create something like this example: 请检查您是否有虚拟主机,如果没有,请创建以下示例:
<VirtualHost *:80>
ServerName helloWorld.dev
DocumentRoot /Users/myuser/Sites/HelloWorld/public
<Directory /Users/myuser/Sites/HelloWorld/public>
Options +FollowSymlinks +SymLinksIfOwnerMatch
AllowOverride All
</Directory>
</VirtualHost>
Also on your hosts files 也在您的主机文件上
127.0.0.1 helloWorld.dev
I would recomend to check the folder permissions too 我也建议检查文件夹权限
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$
Add the following definition on the file /etc/apache2/users/myuser.conf. 在文件/etc/apache2/users/myuser.conf中添加以下定义。 If this file don't exist create it 如果此文件不存在,请创建它
<Directory "/Users/myuser/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.