Getting Started with CakePHP 3.5 and Accelerated Mobile Pages (AMP)

Next: Connecting to the PostgreSQL database 10.1 from CakePHP 3.5 UP: TOC

In this chapter we will setup nginx in order to connect with CakePHP. Furthermore we will setup https with dehydrated.

cd /...../nginx/vhosts/

vi translate.conf

This is the content of the translate.conf file:

server { listen 443 ; server_name tl.logikfabrik.com; client_max_body_size 10M; # max size for uploading image files client_body_buffer_size 10M; access_log /.../nginx-access-translate.log; error_log /..../nginx-error-translate.log; root /usr/.../cakephp3/webroot/; # point to cakephp webroot,refer chapter setup CakePHP index index.php; server_tokens off; # these ssl line are commented out until certificated is available # ssl on; # ssl_certificate /usr/..../certs/tl.logikfabrik.com/fullchain.pem; # ssl_certificate_key /usr/..../certs/tl.logikfabrik.com/privkey.pem; # ssl_trusted_certificate /usr/..../certs/tl.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; } # this section is aimed for creating and renewal of certifcates. location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; #alias /usr/...../bin/.acme-challenges/; alias /usr/...../dehydrated/; } location ~ \.php$ { try_files $uri =404; include /usr/..../nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }

Now your can restart nginx.

service nginx restart

First we will setup the certificates in order to encrypt the http traffic.

This command shows the environment for dehydrated:

/usr/local/bin/dehydrated --env
# dehydrated configuration # INFO: Using main config file /usr/..../dehydrated/config declare -- CA="https://acme-v01.api.letsencrypt.org/directory" declare -- LICENSE="" declare -- CERTDIR="/usr/.../certs" declare -- CHALLENGETYPE="http-01" declare -- DOMAINS_D="" declare -- DOMAINS_TXT="/usr/..../dehydrated/domains.txt" declare -- HOOK="" declare -- HOOK_CHAIN="no" declare -- RENEW_DAYS="30" declare -- ACCOUNT_KEY="/usr/.../dehydrated/accounts/abcd..../account_key.pem" declare -- ACCOUNT_KEY_JSON="/usr/...../dehydrated/accounts/abcd../registration_info.json" declare -- KEYSIZE="4096" declare -- WELLKNOWN="/usr/.../dehydrated" declare -- PRIVATE_KEY_RENEW="yes" declare -- OPENSSL_CNF="/etc/ssl/openssl.cnf" declare -- CONTACT_EMAIL="" declare -- LOCKFILE="/usr/..../dehydrated/lock"
/usr/local/bin/dehydrated --cron --domain tl.logikfabrik.com --challenge http-01

This command requests a certificated for https://tl.logikfabrik.com

# INFO: Using main config file /usr/.../dehydrated/config Processing tl.logikfabrik.com + Signing domains... + Creating new directory /usr/.../certs/tl.logikfabrik.com ... + Generating private key... + Generating signing request... + Requesting challenge for tl.logikfabrik.com... + Responding to challenge for tl.logikfabrik.com... + Challenge is valid! + Requesting certificate... + Checking certificate... + Done! + Creating fullchain.pem... + Done! Next: Connecting to the PostgreSQL database 10.1 from CakePHP 3.5 UP: TOC