How to Install CakePHP on Ubuntu 24.04
You install CakePHP on Ubuntu 24.04 by first ensuring all its necessary prerequisites are met and then using Composer to initiate a new project.
CakePHP is a free, open-source PHP framework designed to speed up web development. It adheres to the Model-View-Controller (MVC) architectural pattern, making your code more organized and your applications more robust.
This powerful framework streamlines database management with its Object-Relational Mapping (ORM) feature. This allows you to interact with your data using objects, bypassing the need for complex SQL commands.
To begin, confirm you have PHP, a web server (like Apache or Nginx), and Composer installed on your Ubuntu 24.04 system. Once these are ready, you’ll create your CakePHP application with a single Composer command.
Install CakePHP by first updating apt and installing composer and PHP extensions. Then, create a project directory and use composer create-project cakephp/app MyApp. Finally, run the built-in server with ./bin/cake server.
Install PHP requirements
CakePHP uses the PHP language. You’ll need PHP on your machine to use CakePHP.
Run the command below to install some essential PHP packages.
sudo apt update
sudo apt install composer php8.3-curl php8.3-sqlite3 php8.3-xml php8.3-mysql
Once PHP is installed, open its configuration file. PHP 8.3 is the current version available in Ubuntu 24.04 as of this writing.
sudo nano /etc/php/8.3/cli/php.ini
When the file opens, change the highlighted line.
# line 1614: adjust the value
; Default Value: 1
; Development Value: 1
; Production Value: -1
; https://php.net/zend.assertions
zend.assertions = 1
;
;
Save and exit.
Create CakePHP project
With PHP packages installed, run the command below to create a CakePHP project folder.
mkdir project
Change into the project folder and create your CakePHP app.
cd project
composer create-project cakephp/app MyApp
If everything works, you should see an output similar to the one below.
Permissions set on /home/richard/project/MyApp/tmp/cache
Permissions set on /home/richard/project/MyApp/tmp/cache/models
Permissions set on /home/richard/project/MyApp/tmp/cache/persistent
Permissions set on /home/richard/project/MyApp/tmp/cache/views
Permissions set on /home/richard/project/MyApp/tmp/sessions
Permissions set on /home/richard/project/MyApp/tmp/tests
Permissions set on /home/richard/project/MyApp/tmp
Permissions set on /home/richard/project/MyApp/logs
Updated Security.salt value in config/app_local.php
Change to the MyApp folder and run CakePHP.
cd MyApp
./bin/cake server -H 0.0.0.0 -p 8765
Open your browser and navigate to the server’s hostname or IP address followed by port # 8765.
Welcome to CakePHP v5.1.6 Console
-------------------------------------------------------------------------------
App : src
Path: /home/richard/project/MyApp/src/
DocumentRoot: /home/richard/project/MyApp/webroot
Ini Path:
-------------------------------------------------------------------------------
built-in server is running in http://0.0.0.0:8765/
You can exit with `CTRL-C`
That should do it!
Conclusion:
So, installing the CakePHP framework on Ubuntu 24.04 involves these key steps:
- Install PHP and required packages: Ensure PHP and necessary PHP extensions are installed using the appropriate commands.
- Configure PHP settings: Modify the PHP configuration file to enable assertions for better error handling.
- Create a project directory: Set up a dedicated folder for your CakePHP project.
- Use Composer to create a CakePHP application: Easily generate a new CakePHP application within the project directory.
- Run the application: Start the CakePHP server and verify it by accessing the designated port in your web browser.
By following these steps, you can have your CakePHP web application up and running efficiently. Enjoy building your application!
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!