Install CakePHP Framework on Ubuntu 18.04 / Ubuntu 16.04 / Debian 9
source link: https://computingforgeeks.com/install-cakephp-framework-on-ubuntu-18-04-ubuntu-16-04-debian-9/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How can I install the latest CakePHP Framework on Ubuntu 18.04 / Ubuntu 16.04 / Debian 9?. CakePHP is a rapid development framework for PHP which uses popular design patterns like Front Controller, Associative Data Mapping and MVC. CakePHP aims at providing a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss of flexibility.
Below are the steps to install CakePHP on Ubuntu 18.04 / Ubuntu 16.04 / Debian 9.
Step 1: Install System Dependencies
To run CakePHP, you’ll need to have PHP, Web Server and Database server installed on the host machine.
Install PHP and Extensions
Install PHP by running the command:
sudo apt install php php-cli php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-intl
Install MariaDB Database Server:
How to Install MariaDB 10 on Debian 9 / Debian 8
How to install MariaDB 10.x on Ubuntu 16.04 (Xenial Xerus) LTS
Install MariaDB 10.3 on Ubuntu 18.04 and CentOS 7
Once you have a running database server, login to MySQL shell as root user:
$ mysql -u root -p
Create a database for CakePHP.
CREATE DATABASE myproject; GRANT ALL ON myproject.* to 'myproject_user'@'localhost' IDENTIFIED BY 'StrongPassword'; FLUSH PRIVILEGES; QUIT;
Install Apache Web Server
Also install Apache2 web server dependency by running the commands below in your terminal.
sudo apt -y install apache2 libapache2-mod-php
The service should be started and enabled to start on boot.
Step 2: Install Composer
Ensure wget is installed
sudo apt -y install wget
Download Composer installer:
wget https://getcomposer.org/installer -O composer-installer.php
Run the installer script to deploy Composer globally:
sudo php ./composer-installer.php --install-dir=/usr/local/bin --filename=composer
You should see output like below:
All settings correct for using Composer Downloading... Composer (version 1.8.0) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer
You should be able to use composer
command
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.8.0 2018-12-03 10:31:16 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
To check for the installed version of composer, type the command:
# composer -V Composer version 1.8.0 2018-12-03 10:31:16
Whenever you want to update the composer, just type:
$ sudo composer self-update You are already using composer version 1.8.0 (stable channel).
You now have a Composer PHP dependency Manager installed on your Ubuntu / Debian server.
Step 3: Create a CakePHP Project
For a new Project, you can use CakePHP Application Skeleton.
mkdir /srv/projects cd /srv/projects composer create-project --prefer-dist cakephp/app
In case you want to use a custom app dir name (e.g. /myapp/):
composer create-project --prefer-dist cakephp/app myapp
Your Application directory setup should look something like the following:
$ ls -1 bin composer.json composer.lock config index.php logs phpunit.xml.dist plugins README.md src tests tmp vendor webroot
Set database connection settings on config/app.php
*/ 'Datasources' => [ 'default' => [ 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Database\Driver\Mysql', 'persistent' => false, 'host' => 'localhost', /* * CakePHP will use the default DB port based on the driver selected * MySQL on MAMP uses port 8889, MAMP users will want to uncomment * the following line and set the port accordingly */ //'port' => 'non_standard_port_number', 'username' => 'myproject_user', 'password' => 'StrongPassword', 'database' => 'myproject', /* * You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6). */ //'encoding' => 'utf8mb4', 'timezone' => 'UTC', 'flags' => [], 'cacheMetadata' => true, 'log' => false,
Start the development server to check that your installation is working as expected.
cd /srv/myapp bin/cake server
This will start PHP’s built-in webserver on port 8765
. Open up http://localhost:8765
in your web browser to see the welcome page.
Reference:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK