Cakephp 2.5.0 安装配置

安装环境如下:

httpd-2.2.21-win32-x86-openssl-0.9.8r.msiApache2.2.21 openssl版本)

mysql-5.5.20-win32.msiMySQL5.5.20

php-5.3.10-Win32-VC9-x86.zipPHP5.3.10 thread safe版本)

Windows 7 Ultimate 32bit

 

1. 安装和配置cakephp

 

cakephp的官方网站( http://cakephp.org )下载一个最新版本(cakephp-cakephp-2.5.0-0-g780132f.zip),

解压后把applibpluginsvendorsindex.php等复制或剪切到apache服务器的documentroot或者它下面的某个目录,我这里假设放在E:/htdocs目录下。

 

1.1 进入app/config/目录,把database.php.default重命名为database.php,打开这个文件就可以看到关于数据库用户名密码之类的设置了。

Note:Makesure the database has been created in MySQL, and tMy configurations are asbelow.

                public $default = array(

                        'datasource'=> 'Database/Mysql',

                        'persistent' =>false,

                        'host' =>'127.0.0.1',

                        'login' => 'root',

                        'password' =>'yourpassword',,

                        'database' =>'testcakephp',  //Makesure the table hasbeen created in MySQL

                        'prefix' => '',

                        //'encoding' =>'utf8',

);

        public $test = array(

                        'datasource' =>'Database/Mysql',

                        'persistent' =>false,

                        'host' =>'127.0.0.1',

                        'login' => 'root',

                        'password' => ''yourpassword'',

                        'database' =>'testcakephp',

                        'prefix' => '',

                        //'encoding' => 'utf8',

        );

 

1.2 进入app/config/目录,修改core.php文件中的Security.saltSecurity.cipherSeed变量,对应后面的字符串没有限制,只要不与原来相同即可。

Before:

 Configure::write('Security.salt','DYhG93b0q365475676niR2G0FgaC9mi');
 Configure::write('Security.cipherSeed','7685930965745sfdgdfgh35424963645');

After:

Configure::write('Security.salt','DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaCvob');

Configure::write('Security.cipherSeed','76859309657453542496749683123');

2 配置Apache

2.1 Change thedirectory

Note: Please notice that thedirectory in your side may be different with that of me.

 

将原来的目录,

DocumentRoot "E:/htdocs "

<Directory "E:/htdocs">

修改为

DocumentRoot"E:/htdocs/app/webroot"

<Directory"E:/htdocs/app/webroot">

 

1.2 Enable Rewrite

Cakephpurl传参数的时候不是用平常的get格式,而是用controlleraction名后面的“/”分隔的字符作为这个controlleraction的参数(action是一个函数)。也因为这样,需要apache服务器支持rewrite,

 

First,

httpd.conf里使能LoadModulerewrite_module modules/mod_rewrite.so,即把前面的#去掉,或者直接添加一句。

 

Second,

httpd.conf找到<Directory>,有两处:

Change the following settings

<Directory />

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

    Deny from all

</Directory>

 

to

<Directory />

    Options FollowSymLinks

    AllowOverride all

#    Order deny,allow

#    Deny from all

</Directory>

 

Change the following settingsto

<Directory"E:/htdocs/app/webroot">

    Options FollowSymLinks

    AllowOverride None

    Order deny,allow

    Deny from all

</Directory>

 

to

<Directory"E:/htdocs/app/webroot">

    Options FollowSymLinks

    AllowOverride all

#    Order deny,allow

#    Deny from all

</Directory>

 

3 安装调试工具

如果不安装,则测试的时候会看到下面的内容。不过如果不需要调试也可以不安装。

 

DebugKit is not installed. Itwill help you inspect and debug different aspects of your application.
You can install it from GitHub

 

下载:从GitHub 下载最新的release branch上的2.2.3

安装: GitHubInstaller步骤

------------------------------------------------------------------------------------------------------------

  • Clone/Copy the files in this directory into app/Plugin/DebugKit

Thiscan be done with the git submodule command

git submodule addhttps://github.com/cakephp/debug_kit.git app/Plugin/DebugKit

  • Ensure the plugin is loaded in app/Config/bootstrap.php by calling CakePlugin::load('DebugKit');
  • Include the toolbar component in your app/Controller/AppController.php:

class AppController extends Controller{

         public $components = array('DebugKit.Toolbar');

}

  • Set Configure::write('debug', 1); in app/Config/core.php.
  • Make sure to remove the 'sql_dump' element from your layout (usually app/View/Layouts/default.ctp if you want to experience the awesome that is the debug kit SQL log.

----------------------------------------------------------------------------------------------------------

3.1 解压到app/Plugin/下,并且把文件名更名为DebugKit

3.2 修改app/Config/bootstrap.php文件,添加以下两行代码:

CakePlugin::loadAll(); // Loads all plugins at once  

CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit  

 

3.3 app/Controller/AppController.php文件,改为如下代码:

class AppController extendsController {

                public $components = array('DebugKit.Toolbar'); //添加此句

}

3.4 修改app/Config/core.php文件,找到Configure::write('debug',2),将其修改为1,即开发级别

Configure::write('debug', 1);  

 

3.5 如果你希望能够看到sqllog的话,打开app/View/Layouts/default.ctp文件,找到如下代码并将其删掉即可:

<?php echo $this->element('sql_dump'); ?>  

 

4 测试

打开http://127.0.0.1/,看到“CakePHPis able to connect to the database”的说明配置成功了。

Release Notes for CakePHP2.5.0

Your version of PHP is 5.2.8or higher.

Your tmp directory iswritable.

The FileEngine is being usedfor core caching. To change the config edit APP/Config/core.php

Your database configurationfile is present.

CakePHP is able to connect tothe database.

DebugKit plugin is present

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值