Knowledge Base

How to install CakePHP manually

This article describes how to manually install the CakePHP web application framework on your A2 Hosting account.

Installing CakePHP

CakePHP is compatible with all A2 Hosting accounts.

Although A2 Hosting servers are compatible with a wide variety of software applications, we cannot provide troubleshooting assistance for application-specific issues.

To install CakePHP manually, follow these steps:

  1. Download the CakePHP installation .zip file at http://cakephp.org to your local computer.
  2. Extract the .zip file on your computer.
  3. Use FTP to upload the contents of the extracted cakephp-cakephp-3d0ed9b directory to the public_html directory of your A2 Hosting account. (The exact name of the extracted directory differs based on the CakePHP version you download.)
    • This step assumes that you want to install CakePHP in your account's document root directory. If you want to install CakePHP in a subdirectory instead, upload the files to the subdirectory instead.
    • If you have a semi-managed product (such as a Cloud VPS, dynamic VPS, or Flex Dedicated Server), your document root directory may be in a different directory, such as /var/www/html. Consult your Linux distribution's documentation for the document root directory location.
  4. Create a MySQL database and database user for CakePHP. You will need this information during the configuration process.

    • If your account includes cPanel, please see this article for information about how to create a MySQL database and user.
    • If your account does not include cPanel, you can create a MySQL database and user from the command line. For information about how to do this, please see this article.
  5. Using the cPanel File Manager or the SSH command prompt, from the document root directory rename the app/Config/database.php.default file to app/Config/database.php.
  6. Using the cPanel File Manager or the SSH command prompt, open the app/Config/database.php file in your preferred text editor.
  7. Locate the following lines in the database.php file:

        public $default = array(
            'datasource' => 'Database/Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'user',
            'password' => 'password',
            'database' => 'database_name',
            'prefix' => '',
            //'encoding' => 'utf8',
        );
    
  8. Modify the lines as follows:

    • In the 'login' => 'user' line, replace user with the name of the database user you created in step 4.
    • In the 'password' => 'password' line, replace the second instance of password with the password of the database user you created in step 4.
    • In the 'database' => 'database_name' line, replace database_name with the name of the database you created in step 4.
    • If you want to use a table prefix in the database, specify a value in the 'prefix' => '' line.
    You can also configure an optional test database. To do this, modify the $test array with the values for your test database.
  9. Save your changes to the database.php file and exit the text editor.
  10. Using the cPanel File Manager or the SSH command prompt, open the app/Config/core.php file in your preferred text editor.
  11. Locate the following lines in the core.php file:

    /**
     * A random string used in security hashing methods.
     */
            Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
    
    /**
     * A random numeric string (digits only) used to encrypt/decrypt strings.
     */
            Configure::write('Security.cipherSeed', '76859309657453542496749683645');
    
  12. Modify the lines as follows:

    • In the Configure::write('Security.salt' line, modify or completely replace the salt value. The salt value can be anything you want.
    • In the Configure::write('Security.cipherSeed' line, modify or completely replace the cipher seed value. The cipher seed value can be anything you want, but it must contain only digits.
  13. Save your changes to the core.php file and exit the text editor.
  14. Use your web browser to go to the CakePHP URL.

    If you copied the CakePHP files to the document root directory in step 3, the installation URL is your domain name (for example, http://www.example.com). If you copied the CakePHP files to a subdirectory in step 3, add the subdirectory's name to the URL.
  15. The CakePHP default page appears. You should receive a series of green notification messages about the configuration. You should not receive any red error notification messages.

    You may receive a notification message about DebugKit. This is an optional component that you can install separately.
  16. CakePHP is now installed and configured.

Configuring the CakePHP console

CakePHP includes a command-line console for creating and managing applications. To configure your shell environment so you can start the console from any directory, follow these steps:

  1. Log in to your account using SSH.
  2. To make sure you are in your home directory, type the following command at the command line:
    cd ~
  3. Edit the .bash_profile file in your home directory using your preferred text editor. The .bash_profile file should contain the following configuration:

    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    
    # Set path for CakePHP console:
    PATH=$PATH:$HOME/public_html/lib/Cake/Console
    export PATH
    
    # END
    You may need to modify the PATH line above to match the exact path to the lib/Cake/Console directory on your own account.
  4. Save your changes to the .bash_profile file and exit the text editor.
  5. To make the settings in the .bash_profile file take effect immediately, type the following command:

    source ~/.bash_profile
  6. To verify that the CakePHP console starts, type the following command:

    cake

    You should see the Welcome to CakePHP Console message.

    For more information about how to use the CakePHP console, please visit http://book.cakephp.org/2.0/en/console-and-shells.html.

More Information

For more information about CakePHP, please visit http://cakephp.org.