Install CakePHP 3 On Ubuntu 16.04 Rumi, September 30, 2018September 30, 2018 This guide assumes you’ve set up a Ubuntu 14.04 server and have MYSQL up and running. This guide uses the “PHPMyAdmin” from the “One Click Apps” available on Digital Ocean running on a vps running Ubuntu 16.04. The smallest memory (512mb) should be enough to get you up and running. If you don’t have a Digital Ocean account (you should, they’re a great service) get one here. Step 1: Update Package Manager ssh root@YOUR-IP Note: If this is the first time you’ve logged into your vps, you will be asked to change the password from the one emailed to you when you created your vps. This is fairly self explanatory, simply follow the prompts. Update your package manager: sudo apt-get update Step 2: Install Some PHP Modules We need to install a few PHP modules that CakePHP uses. Namely the curl, zip, intl and sqlite modules. Run these commands in succession. You may be asked if you want to take up the extra space, reply ‘Y’ for yes: sudo apt-get install curl php7.0-cli git sudo apt-get install php7.0-zip sudo apt-get install php7.0-sqlite sudo apt-get install php7.0-intl Step 3: Install Composer Composer is a dependancy manager for PHP, this is ultimately what we’ll use to install CakePHP to our server: apt install composer Step 4: Enable Rewrite Module Make sure the recite module is enabled: sudo a2enmod rewrite Step 5: Restart Apache For all the changes we’ve made to actually take affect, we need to restart our server: service apache2 restart Step 6: Enable AllowOverride Navigate to the ‘/etc/apache2’ directory, download and open the ‘apache2.conf’ file. Around line 166 within the ‘<Directory /var/www/>’ tags, change the that says ‘AllowOverride None’ to: AllowOverride All This allows .htaccess files to override of the Apache config on a per directory basis, which is what CakePHP needs. You’ll also need to restart apache again for this change to take affect: service apache2 restart Step 7: Install CakePHP cd /var/www/html Note: Change YOUR_APP_NAME to something applicable (no spaces): composer create-project --prefer-dist cakephp/app YOUR_APP_NAME Step 8: Update The Web Root For Your vps At the moment when we visit our vps via a browser, we are taken to the ‘html’ folder (currently displays the default apache page). If you look in the folder you created in the previous step, there is a ‘webroot’ folder. This is actually the folder we need to point our vps to. We can do this in one of the apache config files. Navigate to the ‘/etc/apache2/sites-enabled’ directory and download and open the ‘000-default.conf’ file. You need to just change one line (around line 12): DocumentRoot /var/www/html/YOUR_APP_NAME/webroot Note: Again, change YOUR_APP_NAME to whatever you used in the previous step. Re-upload this from whence it came overwriting the old file. Finally give apache one last restart for that to take affect: service apache2 restart Done! If you visit your vps IP in a browser, all being well, you should now see the default CakePHP. You should see an abundance of green under ‘Environment’, ‘Filesystem’ and ‘DebugKit’. The ‘Database’ will show an error as we haven’t set one up yet and edited the CakePHP config file to tell it where to look for our database. You’ll need to setup a database and then edit your config.php file details can be found on how to do that in the CakePHP documentation here. Note As we’re running our cake setup and developing on a server as opposed to a local environment, we’ve uploaded the cake shell script used to generate the scaffolding code for our database. This lives in the ‘bin’ directory. You’ll need to give this file write and execute permissions: cd /var/www/html/YOUR_APP_NAME/bin sudo chmod 777 cake Administrations Configurations (Linux) CakephpUbuntuUbuntu 16.04