简体   繁体   中英

Configuring a website built with the Zend framework

I'm trying to move a website built with the Zend PHP framework to a new server, and I'm having difficulty getting it up and running. I did not build the site originally and I have never worked with this framework before so it's all quite confusing for me.

The error message I am receiving is:

Error : Invalid controller specified (~iswlp)
Trace info : #0 /home/iswlp/library/Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /home/iswlp/public_html/index.php(80):
Zend_Controller_Front->dispatch() #2 {main}

I have tried removing the trailing slash from the APPLICATION_PATH directory (/home/iswlp/application), but it makes no difference.

Any ideas?

Thanks.

如果/Users/Tim/Sites/iswlp.com.au/是您的项目根目录(包含名为applicationlibrary等的文件夹),则应将APPLICATION_PATH设置为: /Users/Tim/Sites/iswlp.com.au/application/而不是/home/iswlp/application/

The problem looks to be with the routing.

I guess you are accessing the application through mod_userdir like http://somedomain.com/~iswlp/foo , is this correct?

From the error that appears to be what is throwing Zend Framework off because your document root is the same in either case, but your baseUrl is different when called from domain.com vs. anotherdomain.com/~iswlp

As a workaround, you can try modifying the hosts file on your PC and see if the error goes away when you try to access the site.

Try this:

  • Determine the IP address of the server the ZF app is hosted on.
  • Open your hosts file on your system.
  • Add 1.2.3.4 domain.com to the hosts file, where 1.2.3.4 is the server IP, and domain.com is the supposed domain name of the site as it is configured in Apache/IIS/OtherServer
  • Now open your browser and try to go to domain.com

Do you still get the error in that case?

I've never tried but if the ZF app will be hosted on a /~username folder, there may be a small configuration change that must be made to the application.

A Config / Routing problem - couple of things to check:

There are obviously a few ways to install Zend, but most people put the application and library folder outside their www / public_html folder on the server for security. This is in fact how Zend works out the box (or is assumed so). So here are some snippets which may help you, as some of your config may have changed to suit the previous host (again this is ALL assuming your application and library files are one level deep (ie outside your public directory on your server):

index.php file snippet:

// Define path to application directory
if (!defined('APPLICATION_PATH')) {    
    define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
}

// Define the application root
if (!defined('APPLICATION_ROOT')) {    
    define('APPLICATION_ROOT', realpath(dirname(__FILE__) . '/..'));
}

// Ensure library/ is on include_path
set_include_path(    
    APPLICATION_ROOT . '/library' . PATH_SEPARATOR    
    . get_include_path()
);

htaccess file snippet

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(js|css|gif|jpg|png|swf)$ [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

If you do not have a standard Zend install you will have to edit both the index.php and htaccess file to suit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM