App Development with CakePHP 3.4 and Bootstrap 4.0

Next: Setup database connection for CakePHP 3.4 UP: TOC

First we need an ssl certificate in order to use a ssl host

/usr/local/bin/dehydrated --env
# dehydrated configuration # # !! WARNING !! No main config file found, using default config! # declare -- CA="https://acme-v01.api.letsencrypt.org/directory" declare -- LICENSE="https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf" declare -- CERTDIR="...." declare -- CHALLENGETYPE="http-01" declare -- DOMAINS_D="" declare -- DOMAINS_TXT="..." declare -- HOOK="" declare -- HOOK_CHAIN="no" declare -- RENEW_DAYS="30" declare -- ACCOUNT_KEY="..." declare -- ACCOUNT_KEY_JSON="....." declare -- KEYSIZE="4096" declare -- WELLKNOWN="/usr/local/www/dehydrated" declare -- PRIVATE_KEY_RENEW="yes" declare -- OPENSSL_CNF="....." declare -- CONTACT_EMAIL="" declare -- LOCKFILE="/usr/local/bin/lock"
/usr/local/bin/dehydrated --cron --domain c34.logikfabrik.com --challenge http-01
# !! WARNING !! No main config file found, using default config! # Processing c34.logikfabrik.com + Signing domains... + Creating new directory /usr/local/bin/certs/c34.logikfabrik.com ... + Generating private key... + Generating signing request... + Requesting challenge for c34.logikfabrik.com... + Responding to challenge for c34.logikfabrik.com... + Challenge is valid! + Requesting certificate... + Checking certificate... + Done! + Creating fullchain.pem... + Done!

Let’s create a virtual host for nginx in the command line. Open Terminal and run the following command:

su -

cd /usr/local/etc/nginx/vhosts.d

vi cakephp34.conf



The file contains these configurations parameters.

server { listen 443 ; server_name c34.logikfabrik.com; client_max_body_size 10M; # max size for uploading image files client_body_buffer_size 10M; # ava 20160501 access_log /var/log/nginx-access-logikfabrik-c34.log; error_log /var/log/nginx-error-logikfabrik-c34.log; root /usr/local/www/logikfabrik.com/cakephp34/webroot/; # point to cakephp webroot,refer chapter setup CakePHP index index.php; server_tokens off; ssl on; ssl_certificate /usr/local/bin/certs/c34.logikfabrik.com/fullchain.pem; ssl_certificate_key /usr/local/bin/certs/c34.logikfabrik.com/privkey.pem; ssl_trusted_certificate /usr/local/bin/certs/c34.logikfabrik.com/fullchain.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; # serve static files location / { try_files $uri $uri/ /index.php?$uri&$args; } location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; #alias /usr/local/bin/.acme-challenges/; alias /usr/local/www/dehydrated/; }

We need to restart nginx in order to make it work:

/usr/local/etc/rc.d/nginx restart

To prove that the setup was successful we call the url get will get this content:

Successful installation of CakePHP 3.4Next: Setup database connection for CakePHP 3.4 UP: TOC