How to Install CakePHP on Ubuntu 24.04
CakePHP is a free web framework that keeps your database work, design, and code in separate layers. It uses an MVC (Model-View-Controller) design, a pattern that separates data, user interface, and application logic. That separation keeps larger projects easy to navigate on Ubuntu 24.04.
Before you start, you need PHP, Composer, and a terminal with a user that can run commands with sudo. A web server such as Apache is only needed for a production-style setup. For local development and testing, the built-in CakePHP server used later in this guide is enough.
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 depends on PHP and a handful of PHP extensions, so install those first. Ubuntu’s apt package manager installs PHP, Composer, and the extensions the framework needs, including curl, sqlite, and xml. Using apt means Ubuntu handles dependencies and security updates for you.
- Open a terminal.
- Run the command below to install the essential PHP packages. If apt asks you to confirm the download, type Y and press Enter.
You should see apt list the packages and unpack them. If you get a “permission denied” or “unable to lock” error, the command was run without sudo, or another package tool is still running. Wait a minute and try again.
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.
Ubuntu keeps separate configuration files for the command line and for Apache. The built-in CakePHP server runs from the command line, so make sure you edit the file for the command-line PHP. You need root rights to save changes to it.
sudo nano /etc/php/8.3/cli/php.ini
- Wait for the file to open in your text editor.
- Find the highlighted line shown below and change it. This setting turns on assertions, which gives you better error handling while you develop.
# line 1614: adjust the value
; Default Value: 1
; Development Value: 1
; Production Value: -1
; https://php.net/zend.assertions
zend.assertions = 1
;
;
- Save the file and exit the editor.
PHP reads this file each time the command-line interpreter starts, so no restart is needed for the built-in server. If you later use Apache, edit Apache’s own PHP file too and restart Apache. To undo the change, open the same file and set the line back to its original value.
Create CakePHP project
With PHP ready, create a folder for the project and let Composer download the application files into it. Composer builds the framework inside your folder and pulls in every library CakePHP needs. This prepares the web app for local development and testing.
- Run the command below to create a new directory for the project.
mkdir project
- Change into the project folder.
- Run the Composer command to create the CakePHP app, as shown below.
Composer downloads a lot of packages, so this step can take a few minutes depending on your connection. It may also ask whether to set folder permissions. Answering yes is the normal choice for a development setup.
cd project
composer create-project cakephp/app MyApp
Successful execution produces output similar to the example below. If Composer stops with a missing-extension error, go back to the package installation step and install the extension it names.
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.
- Run the command below to start CakePHP’s built-in server.
The terminal stays busy while the server runs, and that is expected. Leave this window open. Press Ctrl+C in it when you want to stop the server.
cd MyApp
./bin/cake server -H 0.0.0.0 -p 8765
- Open a browser.
- Enter the server’s hostname or IP address followed by port # 8765.
If the browser is on the same machine as the server, use localhost. By default the development server listens only on the local machine, so another computer cannot reach it unless you start the server bound to an external address. If you do open it to the network, also check that your firewall allows 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`

The development server is now up and running. You should see the CakePHP welcome page, which also lists checks for your PHP version, extensions, and folder permissions. If any item is marked as failing, fix it before you start building. Keep in mind that this built-in server is for development only. Use a proper web server such as Apache or Nginx for production.
Getting CakePHP running on Ubuntu 24.04 comes down to a few core tasks:
- Install PHP and required packages: Ensure PHP and the necessary PHP extensions are installed with apt. CakePHP will not install cleanly if an extension is missing.
- Configure PHP settings: Modify the PHP configuration file to enable assertions for better error handling. Edit the command-line file, since that is the one the built-in server uses.
- Create a project directory: Set up a dedicated folder for your CakePHP project.
- Use Composer to create a CakePHP application: Generate a new CakePHP application within the project directory. Composer downloads the framework and its dependencies for you.
- Run the application: Start the CakePHP server and verify it by opening port 8765 in your web browser.
Following these steps sets up a working CakePHP web application on Ubuntu 24.04, so you can turn your attention to development.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!