开发者

cakePHP - 404- page not found error, when deploying on a different machine

I'm trying to deploy a cakephp application into my peers system and i get 404 error, for all requests. This is not cakephp 404 error, but a normal webserver 404 page not found error. :( . We both use MAC OS 10.6. The same code works on my machine and on the production system. I have followed the steps to deploy on his machine. I'm using cakephp advanced installation, i.e, webroot contain only index.php, css, js,etc. The APP folder and CAKE folder is located elsewhere.

  1. uncommented the line "LoadModule php5_module...." in /etc/apache2/httpd.conf
  2. Changed to AllowOverride All to the Directory - "Library/WebServer/Documents" in /etc/apache2/httpd.conf
  3. uncommented and set date.timezone in /etc/php.ini
  4. Copied the we开发者_如何转开发broot contents to "Library/WebServer/Documents" and modified index.php to adapt to his machine (setup 3 relevant paths to the CORE, APP and CAKE folder)
  5. made sure the DB connection is good.
  6. For debugging purpose, Modified core.php and set Configure::write('debug',3);

The homepage get data from an AJAX call. WHen i goto http://localhost, the header and footer contents from the layouts/default.ctp are rendered, but the ajax call which is for example http://localhost/posts/showmyposts gets a 404 (Not Found) error. If I goto to other URLs like http://localhost/users/login, I get the normal webserver 404 error.

Not Found

The requested URL /users/login/ was not found on this server.

In my apache error log, i get the error as

[Mon May 16 16:19:48 2011] [error] [client ::1] File does not exist: /Library/WebServer/Documents/users, referer: http://localhost/ Is my cakephp installation correct ?


Sounds like an issue with mod_rewrite not working on that machine. What happens when you try to run a default Cake install? Does it load the CSS and all?

Is there a .htaccess file in your app directory (and in your webroot directory)?

Do you have FollowSymLinks turned on in your Apache config files?


I had the same problem.

I solved it by creating an .htaccess in public_html folder, with the following content:

<IfModule mod_rewrite.c>
        RewriteEngine On
        #Rewrite CakePHP
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !server-status
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

It works for me.


I had to modify my httpd.conf file (it's location varies on your Linux installation-- mine was at /etc/httpd/conf/httpd.conf) in two places to get this to work on CentOS.

In addition to the <Directory /var/www> as mentioned in the CakePHP docs, if you go a little further down you'll see <Directory "/var/www/html"> which does not allow rewriting.

Change AllowOverride None to AllowOverride All.

Be sure to reset apache using sudo /sbin/service httpd restart.


If the above solutions have no effect, make sure the apache rewrite module is enabled

On debian it is disabled by default

a2enmod rewrite
service apache2 restart


In my case I ran into the fact that all posts controller requests (/posts/*) were returning 404. Other controller pages were working fine.

Turns out it was because I had a posts.sql file floating around in my web root. As soon as I moved the file, everything worked. Even with the .sql extension, Cake's rewrite rules made the request map to a non-existent posts folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜