开发者

Running a CakePHP project on Localhost

I have downloaded a CakePHP project from an online server and need to make it work locally, to do some changes. I'm facing a problem similar to this one and have tried all possible solutions, with no luck.

Here's the situations:

  • Site home is in localhost/xpto (c:\xampp\htdocs\xpto) -> here, the site appears unformatted (no CSS) and too slow.
  • If I access localhost/xpto/something, I get the site with the CSS, but some links wont work.

I have mod_rewrite loaded (phpinfo()) together with the 3 .htaccess files, but still experience this problem.

Is there any known issue that I can explore to fix my s开发者_开发技巧ite? Please redirect me to any guides or tutorials that you may feel relevant to my issue


Use RewriteBase directive in .htaccess.

e.g my dev space is on my localhost, is located in /home/ati/public_html/cakerbs, under a subdir in my userdir. The rewriteBase looks like as follows in the root of the cake:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /~ati/cakerbs
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

in the app directory .htacces:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /~ati/cakerbs
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

in the webroot directory:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~ati/cakerbs
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>


Check your XAMPP apache settings, it's very likely your current config is blocking things like the .htaccess files (I know EasyPHP does this by default with Cake). What I do to get around this error is to add a VirtualHost to my config like such:

<VirtualHost *>
DocumentRoot "C:/xampp/htdocs/xpto/"
ServerName xpto.dev
ServerAlias www.xpto.dev
ErrorLog "logs/xpto-error.log"
CustomLog "logs/xtpo-access.log" common
<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>
</VirtualHost>

It may be better to update your whole config properly, but seeing as it's a dev environment for me, this does just fine. (Don't forget to add any hosts to your windows hosts file)

Then just open your favourite browser and go to http://xpto.dev/ and it should load up.

This may help your more: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜