CakePHP

     

    NOTE: This guide uses /opt/bitnami to refer to the installation directory for the Bitnami Stack. This is the default installation directory for Bitnami Cloud Hosting, Google Cloud Platform and Microsoft Azure servers and for virtual servers. If you're using a native installer and have installed the Bitnami Stack to a different folder, replace /opt/bitnami in the examples below with your actual installation directory.

    Overview

    The CakePHP framework is installed in the frameworks/cakephp directory of the installation directory. This folder includes an example application. Application files are in the app/ directory and public files, such as HTML pages, CSS and JavaScript files, images and other media assets are stored in the app/webroot directory.

    Activation and Testing

    To enable the example application, edit the Apache configuration file at  /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf and uncomment the following line

    Include "/opt/bitnami/frameworks/cakephp/conf/httpd-prefix.conf"
    

    Then, restart the Apache server.

    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    You can now verify that the example application is working by visiting its URL using your browser. Select your platform below.

    Bitnami Cloud Hosting

    Access the example application via your browser at http://[server-IP-address]/cakephp

    Microsoft Azure / Google Cloud Platform

    Access the example application via your browser at http://[server-IP-address]/cakephp


    Virtual Machine

    Access the example application via your browser at http://[virtual-server-IP-address]/cakephp

    Native Installer

    Access the example application via your browser at http://localhost/cakephp (Windows) or http://localhost:8080/cakephp (Mac OS X and Linux).

    Tabs end

    Here is an example of what you might see:

    cakephp.png


    Configuration

    Before using the example application, here are a few important points to consider:

    1. To secure your application, modify the encryption keys in the app/Config/core.php file. Ideally, use a key that’s 32 characters or longer in length.

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

    On Linux, you can use a command like pwgen 32 to generate a 32-character random key. On Windows, you can use a tool like PWGen.

    2. If your application will use a database, edit the database settings at app/Config/database.php.

    public $default = array(
            'datasource' => 'Database/Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'port' => '3306',
            'login' => 'user',
            'password' => 'password',
            'database' => 'database_name',
            'prefix' => '',
            //'unix_socket' => '/opt/bitnami/mysql/tmp/mysql.sock',
            //'encoding' => 'utf8',
    );
    


    NOTE: If you are using an operating system that supports sockets, such as Linux or Mac OS X, you can optionally specify the ‘unix_socket’ parameter in the above configuration array instead of the ‘host’ and ‘port’ parameters.

    MySQL support is already available by default. If you plan to use PostgreSQL, enable the php_pdo_pgsql extension in the /opt/bitnami/php/etc/php.ini file.

    extension=php_pdo_pgsql
    

    To obtain access credentials for the MySQL database, use user 'root'. For the MySQL password, follow the steps below:

    Bitnami Cloud Hosting

    Google Cloud Platform

    • Browse to the Bitnami Launchpad for Google Cloud Platform dashboard and sign in if required using your Bitnami account.
    • Select the "Virtual Machines" menu item.
    • Select your Bitnami Stack server from the resulting list.
    • Obtain the password by selecting "Show" under "Credentials".


    Microsoft Azure

    To log in, use default password 'bitnami'.

    Virtual Machine

    To log in, use default password 'bitnami'.

    Native Installer

    The password is the one specified by you during the Bitnami Stack installation process.

    Tabs end


    3. To move the CakePHP example application such that it is available at the root URL of the server (without the /cakephp URL suffix), follow these steps:

    • Edit the /opt/bitnami/frameworks/cakephp/conf/httpd-prefix.conf file so that it looks like this:
    DocumentRoot "/opt/bitnami/frameworks/cakephp/app/webroot/"
    #Alias /cakephp/ "/opt/bitnami/frameworks/cakephp/app/webroot/"
    #Alias /cakephp "/opt/bitnami/frameworks/cakephp/app/webroot"
    Include "/opt/bitnami/frameworks/cakephp/conf/httpd-app.conf"
    
    • Edit the /opt/bitnami/frameworks/cakephp/app/webroot/.htaccess file so that the RewriteBase directive is set to the root URL:
    RewriteBase /
    
    • c. Restart the Apache server:
    $ sudo /opt/bitnami/ctlscript.sh restart apache
    

    You should now be able to access the example application at the root URL of your server.

    Upgrading to CakePHP 3.x

    If your Bitnami stack currently uses CakePHP 2.x and you would like to upgrade to CakePHP 3.x, follow these steps:
     

    NOTE: The steps below assume that you have already activated the CakePHP framework and example application, as described here.
    1. Log in to your server console.
    2. If you are using a native installer only, load the Bitnami environment:
      $ cd /opt/bitnami
      $ ./use_lampstack
      
    3. Back up the current version of CakePHP:
      $ cd /opt/bitnami/frameworks
      $ sudo mv cakephp cakephp.old
      
    4. Download and install the latest version of CakePHP (3.0.10 at the time of writing):
      $ cd /opt/bitnami/frameworks
      $ sudo wget https://github.com/cakephp/cakephp/archive/3.0.10.tar.gz
      $ sudo tar -xzvf 3.0.10.tar.gz
      $ sudo mv cakephp-3.0.10 cakephp
      
    5. Create a demo application:
      $ cd /opt/bitnami/frameworks/cakephp
      $ sudo composer self-update
      $ sudo composer create-project --prefer-dist cakephp/app app
      
    6. Copy the necessary configuration files from the previous CakePHP installation:
      $ sudo cp -R /opt/bitnami/frameworks/cakephp.old/conf /opt/bitnami/frameworks/cakephp/
      $ sudo cp /opt/bitnami/frameworks/cakephp.old/app/webroot/.htaccess /opt/bitnami/frameworks/cakephp/app/webroot/
      
    7. Change file ownerships of the CakePHP directory:
      $ cd /opt/bitnami/frameworks/
      $ sudo chown -R bitnami:root cakephp
      

    You should now be able to access the example application and verify that it is using CakePHP 3.x, as shown below:

    cakephp-upgrade.png

    More Information

    Learn more about developing applications with CakePHP at http://book.cakephp.org/

    Tag page (Edit tags)
    • No tags
    Pages that link here
    Page statistics
    131859 view(s), 18 edit(s) and 10281 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments