Book Image

Learning Phalcon PHP

By : Calin Rada, Ioan C Rada
Book Image

Learning Phalcon PHP

By: Calin Rada, Ioan C Rada

Overview of this book

Table of Contents (17 chapters)
Learning Phalcon PHP
About the Author
About the Reviewers

Enabling SSL on our local machine

We will take into account one of the API rules: always use a secure connection. Assuming that you are using Nginx, this can be done in four easy steps:

  1. Create a directory, /etc/nginx/ssl:

    $ sudo mkdir /etc/nginx/ssl
  2. Generate a new certificate using the following command:

    $ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt

    At this point you will be asked to provide some information about the new certificate, as shown in the following diagram:

  3. Open the learning-phalcon.localhost configuration file (/etc/nginx/sites-available/learning-phalcon.localhost) and enable SSL:

    server {
      listen 80;
      listen 443 ssl;
      ssl_certificate /etc/nginx/ssl/nginx.crt;
      ssl_certificate_key /etc/nginx/ssl/nginx.key;
  of the code
  4. Then reload the Nginx configuration:

    $ sudo service nginx reload

Now you can try to access https://learning-phalcon.localhost/. In any browser that you are using, you will...