初始Cakephp,新手入门安装与配置

来源:互联网 发布:java流行开源框架 编辑:程序博客网 时间:2024/06/04 20:08

一、什么是CakePHP?

CakePHP是一个开源的PHP on rails的full-stack framework。最开始从Ruby On Rails框架里得到灵感。程序员可使用它来快速创建的Web应用程序。我们的首要目的是使你以一种预置的快速且不失灵活性的方式开展工作。

二、安装、配置CakePHP

1、httpd.conf 文件中的定义

<Directory “/webroot”>
       Options Indexes MultiViews
       AllowOverride All
       Order allow,deny
       Allow from all
</Directory>

2、确认 .htaccess 文件是否存在?

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

①首先确认.htaccess覆写是被允许的:在apache配置文件中检查配置下的AllowOverride是不是设置为All。
②确认你修改的是server的配置文件而不是当前用户或者特定站点的配置文件。
③确认你是否成功加载了mod_rewrite!察看配置文件中是否有’LoadModule rewrite_module libexec/httpd/mod_rewrite.so’ 和 ‘AddModule mod_rewrite.c’。
④有的时候,可能你得到的CakePHP副本缺少了必须的.htaccess文件。因为有的操作系统会将以.开头的文件视作隐藏文件,因而不会拷贝它们。确定你的CakePHP副本是我们网站上下载或者是我们的SVN repository上checkout的。

2、根据错误信息配置

① Notice (1024): Please change the value of ‘Security.salt’ in app/config/core.php to a salt value specific to your application [CORE\cake\libs\debugger.php, line 557]

设置自己的’Security.salt’

/**
* A random string used in security hashing methods.
*/
Configure::write(‘Security.salt’, ‘DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi’);

更改为:

Configure::write(‘Security.salt’, ‘ABDCDEFGHIKLMNOPQRSTUVWXYZ’);

注:ABDCDEFGHIKLMNOPQRSTUVWXYZ 为测试使用的,用户根据自己的需要独立设置。

② 设置写权限

Your tmp directory is writable.

windows平台可不用设置,tmp目录是可写的。
在Linux中需要设置一下当前目录为0777

③ 设置Caching

The FileEngine is being used for caching. To change the config edit APP/config/core.php

Cakephp自带已经设置为:

Cache::config(‘default’, array(‘engine’ => ‘File’));

注:CakePHP支持 File、APC、Xcache、Memcache,具体配置看我以前的博文。

④ 设置数据库

Your database configuration file is NOT present.
Rename config/database.php.default to config/database.php

CakePHP默认的是database.php.default,更改为:database.php

查看源代码打印帮助1classDATABASE_CONFIG {2 3    var$default= array(4        'driver'=> 'mysql',5        'persistent'=> false,6        'host'=> 'localhost',7        'login'=> 'root',8        'password'=> '123456',9        'database'=> 'cakephp',10        'prefix'=> '',11    );12}

注:用户根据自己的数据库进行配置 var $test 用于测试可不用。

设置后:

Your database configuration file is present.
Cake is able to connect to the database.

OK,配置完成。开始你的CakePHP之旅吧!

⑤ 开始学习使用Cakephp

原创粉丝点击