<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CakePHP Archives - LinuxTuto</title>
	<atom:link href="https://www.linuxtuto.com/tag/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.linuxtuto.com/tag/cakephp/</link>
	<description>Linux Sysadmin and DevOps blog</description>
	<lastBuildDate>Mon, 29 May 2023 13:00:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://www.linuxtuto.com/wp-content/uploads/2022/01/cropped-LT_faveicon-32x32.png</url>
	<title>CakePHP Archives - LinuxTuto</title>
	<link>https://www.linuxtuto.com/tag/cakephp/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">201456972</site>	<item>
		<title>How to Install CakePHP on Ubuntu 22.04</title>
		<link>https://www.linuxtuto.com/how-to-install-cakephp-on-ubuntu-22-04/</link>
					<comments>https://www.linuxtuto.com/how-to-install-cakephp-on-ubuntu-22-04/#respond</comments>
		
		<dc:creator><![CDATA[LinuxTuto]]></dc:creator>
		<pubDate>Mon, 29 May 2023 13:00:04 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Composer]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://www.linuxtuto.com/?p=1368</guid>

					<description><![CDATA[<p>CakePHP is an open-source web application framework written in PHP. It follows the Model-View-Controller (MVC) architectural pattern, which provides a structured approach to developing web...</p>
<p>The post <a href="https://www.linuxtuto.com/how-to-install-cakephp-on-ubuntu-22-04/">How to Install CakePHP on Ubuntu 22.04</a> appeared first on <a href="https://www.linuxtuto.com">LinuxTuto</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>CakePHP is an open-source web application framework written in PHP. It follows the Model-View-Controller (MVC) architectural pattern, which provides a structured approach to developing web applications. CakePHP aims to simplify and speed up the development process by offering a set of conventions and built-in features.</p>
<p>CakePHP has gained popularity for its simplicity, convention-driven approach, and robust feature set. It has been used to build a wide range of web applications, from small websites to large-scale enterprise systems.</p>
<p>In this tutorial, we will show you how to install CakePHP on Ubuntu 22.04 OS.</p>
<h2><span class="has-inline-color has-vivid-purple-color">Step 1: Update Operating System</span></h2>
<p>Update your <strong>Ubuntu</strong> <strong>22.04</strong> operating system to the latest version with the following command:</p>
<pre><code># apt update &amp;&amp; sudo apt upgrade</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 2: Install Apache webserver</span></h2>
<p>You can install it via <code>apt</code> package manager by executing the following command.</p>
<pre><code># apt install apache2</code></pre>
<p>Verify the status of the <code>Apache</code> service using <code>systemctl status</code> command:</p>
<pre><code># systemctl status apache2</code></pre>
<p>Output:</p>
<pre><code><span style="color: #00ff00;">●</span> apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: <span style="color: #00ff00;">active (running)</span>
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 2773 (apache2)
      Tasks: 55 (limit: 2193)
     Memory: 4.8M
        CPU: 35ms
     CGroup: /system.slice/apache2.service
             ├─2773 /usr/sbin/apache2 -k start
             ├─2775 /usr/sbin/apache2 -k start
             └─2776 /usr/sbin/apache2 -k start
</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 3: </span><span class="has-inline-color has-vivid-purple-color">Install PHP and PHP extensions for CakePHP</span></h2>
<p>To install PHP and additional PHP extensions which are essential for create CakePHP project, run the following command:</p>
<pre><code># apt-get install php libapache2-mod-php php-{cli,common,curl,zip,gd,mysql,xml,mbstring,json,intl,bcmath,sqlite3}</code></pre>
<p>Verify if PHP is installed.</p>
<pre><code># php -v</code></pre>
<pre><code>Output:
PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 4: Install MySQL and create a database</span></h2>
<p>You can install the MySQL server with the following command:</p>
<pre><code># apt install mysql-server</code></pre>
<p>Verify the status of the <code>MySQL</code> service using <code>systemctl status</code> command:</p>
<pre><code># systemctl status mysql</code></pre>
<p>Output:</p>
<pre><code><span style="color: #00ff00;">●</span> mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: <span style="color: #00ff00;">active (running)</span>
    Process: 806 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 938 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2193)
     Memory: 421.3M
        CPU: 3.314s
     CGroup: /system.slice/mysql.service
             └─938 /usr/sbin/mysqld
</code></pre>
<p>By default, MySQL server is not hardened. You can secure MySQL using the <code class=" prettyprinted"><span class="pln">mysql_secure_installation</span></code> script.</p>
<pre><code># mysql_secure_installation</code></pre>
<p>Configure it like this:</p>
<pre><code>- Set root password? [Y/n] <strong>Y</strong>
- Remove anonymous users? [Y/n] <strong>Y</strong>
- Disallow root login remotely? [Y/n] <strong>Y</strong>
- Remove test database and access to it? [Y/n] <strong>Y</strong>
- Reload privilege tables now? [Y/n] <strong>Y</strong></code></pre>
<p>Now, log into the MySQL prompt:</p>
<pre><code>#  mysql -u root -p</code></pre>
<p>To create a database, database user, and grant all privileges to the database user run the following commands:</p>
<pre><code>mysql&gt; CREATE DATABASE cakephp_db;
mysql&gt; CREATE USER 'cakephp_user'@'localhost' IDENTIFIED BY 'Str0Pa$$word';
mysql&gt; GRANT ALL ON cakephp_db.* TO 'cakephp_user'@'localhost';
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; EXIT</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 5: Install Composer</span></h2>
<p>CakePHP’s official installation method is through <a href="https://getcomposer.org/" target="_blank" rel="noopener noreferrer">Composer</a>.</p>
<p>Run the following command to download the Composer installer using <code class=" prettyprinted"><span class="pln">curl</span></code> command:</p>
<pre><code># curl -sS https://getcomposer.org/installer | php</code></pre>
<p>Next, move the composer file to the<code> /usr/local/bin</code> path.</p>
<pre><code># mv composer.phar  /usr/local/bin/composer</code></pre>
<p>Assign execute permission:</p>
<pre><code># chmod +x   /usr/local/bin/composer</code></pre>
<p>Verify the Composer version installed:</p>
<pre><code># composer --version</code></pre>
<pre><code>Output:
Composer version 2.5.7 2023-05-24 15:00:39</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 6: Create CakePHP Project</span></h2>
<p>Now, using Composer it is quite simple to create CakePHP project. To do so, just run the following command:</p>
<pre><code># cd /var/www
# composer create-project --prefer-dist cakephp/app MyProject</code></pre>
<p>In the final part of the installation, you will be asked to change the permissions of the folders.</p>
<pre><code>Set Folder Permissions ? (Default to Y) [Y,n]? <span style="color: #ff0000;"><strong>Y</strong></span>
Permissions set on /var/www/MyProject/tmp/cache
Permissions set on /var/www/MyProject/tmp/cache/models
Permissions set on /var/www/MyProject/tmp/cache/persistent
Permissions set on /var/www/MyProject/tmp/cache/views
Permissions set on /var/www/MyProject/tmp/sessions
Permissions set on /var/www/MyProject/tmp/tests
Permissions set on /var/www/MyProject/tmp
Permissions set on /var/www/MyProject/logs
Updated Security.salt value in config/app_local.php</code></pre>
<p>Also, change the ownership of the <strong>MyProject</strong> directory with the following command:</p>
<pre><code># chown -R www-data:www-data /var/www/MyProject/</code></pre>
<p>Then edit <strong>MyProject/config/app_local.php</strong> configuration file and search for your database setting.</p>
<pre><code># nano /var/www/MyProject/config/app_local.php</code></pre>
<p>Make necessary changes as per below details:</p>
<pre><code>    'Datasources' =&gt; [
        'default' =&gt; [
            'host' =&gt; 'localhost',
            //'port' =&gt; 'non_standard_port_number',

            'username' =&gt; 'cakephp_user',
            'password' =&gt; 'Str0Pa$$word',

            'database' =&gt; 'cakephp_db',
</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 7: Deploy CakePHP (Development)</span></h2>
<p>To check that CakePHP is properly installed, simply run PHP’s built-in webserver to serve your project.</p>
<pre><code># bin/cake server</code></pre>
<p>By default, without any arguments provided, this will serve your application at <strong>http://localhost:8765/</strong>.</p>
<p>You can also specify your own host and port:</p>
<pre><code># bin/cake server -H 192.168.10.10 -p 4321</code></pre>
<p>This will serve your application at <strong>http://192.168.10.10:4321/</strong></p>
<p><span style="color: #ff0000;"><strong>Note:</strong></span> That this is done for development purposes and never for production.</p>
<h2><span class="has-inline-color has-vivid-purple-color">Step 8: Configure Apache for CakePHP (Production)</span></h2>
<p>To create a new VirtualHost file run the following commands:</p>
<pre><code># nano /etc/apache2/sites-available/cakephp.conf</code></pre>
<p>Paste the content as shown below:</p>
<pre><code> &lt;VirtualHost *:80&gt;
    ServerAdmin admin@your-domain.com
    DocumentRoot /var/www/MyProject/
    
    ServerName your-domain.com
    ServerAlias www.your-domain.com

    &lt;Directory /var/www/MyProject/&gt; 
        AllowOverride All
        Require all granted
    &lt;/Directory&gt; 

    ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
    CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

 &lt;/VirtualHost&gt;</code></pre>
<p>Remember to replace <strong><code>your-domain.com</code></strong> with the domain name of your server.</p>
<p>Save and exit the configuration file.</p>
<p>Then enable the <code>"rewrite"</code> module in Apache:</p>
<pre><code># a2enmod rewrite</code></pre>
<p>To enable this site run the command:</p>
<pre><code># a2ensite cakephp.conf</code></pre>
<p>To implement the changes, restart Apache webserver:</p>
<pre><code># systemctl restart apache2</code></pre>
<h2><span class="has-inline-color has-vivid-purple-color">Step 9: Access CakePHP</span></h2>
<p>To access your CakePHP project, go to your browser and visit <code>http://your-domain.com</code>.</p>
<div class="google-auto-placed ap_container"><img fetchpriority="high" decoding="async" class="aligncenter size-large wp-image-1372" src="https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-900x512.jpg" alt="CakePHP 4" width="900" height="512" srcset="https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-900x512.jpg 900w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-300x171.jpg 300w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-768x437.jpg 768w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-1536x875.jpg 1536w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-1222x696.jpg 1222w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-897x511.jpg 897w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4-684x389.jpg 684w, https://www.linuxtuto.com/wp-content/uploads/2023/05/CakePHP_4.jpg 1895w" sizes="(max-width: 900px) 100vw, 900px" /></div>
<div>You will see the database is connected properly.</div>
<h2><span class="has-inline-color has-vivid-purple-color">Comments and Conclusion</span></h2>
<p class="LC20lb MBeuO DKV0Md">That&#8217;s it. You can now create controllers, models and views to develop your project according to your requirements.</p>
<p>For additional help or useful information, we recommend you to check <a href="https://book.cakephp.org/4/en/contributing/documentation.html">the official CakePHP documentation</a>.</p>
<p>The post <a href="https://www.linuxtuto.com/how-to-install-cakephp-on-ubuntu-22-04/">How to Install CakePHP on Ubuntu 22.04</a> appeared first on <a href="https://www.linuxtuto.com">LinuxTuto</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.linuxtuto.com/how-to-install-cakephp-on-ubuntu-22-04/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1368</post-id>	</item>
	</channel>
</rss>
