在裝cakephp時 我真的算吃足了苦頭
畢竟從沒用過 只好從頭學起 再加上nginx的rewrite的設定 一整個暈
其實假如真的都知道步驟 一步步來大概5分鐘搞定吧
所以特別寫下來 好好記錄一下

官網位置:http://cakephp.org/
下載最新版:https://github.com/cakephp/cakephp/archives/2.0
我這次安裝是以cakephp 2.2.2為例

下載tar檔案
cakephp-cakephp-2.2.2-48-gfe5b49e.tar
丟到mnt下
解壓縮
tar -zxvf cakephp-cakephp-2.2.2-48-gfe5b49e.tar

把資料夾rename 為cake(自己決定)

mv cakephp-cakephp-2.2.2-48-gfe5b49e/ cake/

改權限
chown -R nginx:nginx /mnt/cake/
chmod -R 775 /mnt/cake/

接著到/etc/nginx/conf.d/ 新增一個設定檔
這裡也叫test.conf
要注意的是
root 要指對位置 要指到/解壓後的路徑/app/webroot
內容如下

server {

  listen   80;
  server_name localhost;
  access_log   /var/log/nginx/dev.testapp.devlocal.access.log;
  error_log    /var/log/nginx/dev.testapp.devlocal.error.log;
  rewrite_log on;
  root     /mnt/cake/app/webroot;
  index    index.php;


  # Not found this on disk?
  # Feed to CakePHP for further processing!

  if (!-e $request_filename) {
    rewrite ^/(.+)$ index.php?url=$1 last;
    break;
  }
  # Pass the PHP scripts to FastCGI server
  # listening on 127.0.0.1:9000

  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_intercept_errors on; # to support 404s for PHP files no$
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
  # Deny access to .htaccess files,
  # git & svn repositories, etc

  location ~ /(\.ht|\.git|\.svn) {
    deny  all;
  }
}

重啟服務

service nginx restart
service php-fpm restart

此時就可以輸入 http://yourdomain/
就可以看到頁面了 畫面會提示有問題沒意外應該會有三個位置要再改

1.增加DB設定檔
cd 你的路徑/app/Config/
cp database.php.default database.php
vi 你的路徑/app/Config/database.php (在最下面)
內容填入你的mysql相關設定 改host login password database
 public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'user',
    'password' => 'password',
    'database' => 'database_name',
    'prefix' => '',
    'encoding' => 'utf8',
    );

2.調整hash值

vi 你的路徑/app/Config/core.php
找到下面的內容
Security.salt 後面自己填入你的值 英數混合均可
Security.cipherSeed 後面自己填入你的值 只能填數字

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

/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
    Configure::write('Security.cipherSeed', '768593096574535424967496836455678');


service nginx restart
service php-fpm restart

大概就是這樣了
記得mysql服務也得先啟動開好相關帳號與db才能把步驟都做完
這篇文章除了讓自己記憶外 也希望能幫上需要相關資訊的人




 

arrow
arrow
    全站熱搜

    紐士比 發表在 痞客邦 留言(0) 人氣()