Skip to content

Instantly share code, notes, and snippets.

@nguyenanhtu
Created December 1, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nguyenanhtu/26f841e12e8c99b6505020f90a831d7f to your computer and use it in GitHub Desktop.
Save nguyenanhtu/26f841e12e8c99b6505020f90a831d7f to your computer and use it in GitHub Desktop.

In this document, I will guide you how to implement SSL with Nginx in Ubuntu.

Menu

  • Config requirements system
    • Install Nginx + MySQL + PHP-FPM
    • Some potentials bugs while installation
  • Enable https in Nginx

Step 1 : Config requirements system

Firstly, we must setup all software that we need. If in Windows, we have XAMPP bundle (it contains Apache, PHP and MySQL), then in Linux, we will use Nginx instead of Apache, PHP-FPM replaces PHP and MySQL doesn't change. One notice is I will use Ubuntu 14.04 to setup all.

Step 1.1 : Install Nginx + MySQL + PHP-FPM

  • To install Nginx in Ubuntu, open terminal and paste these commands :
sudo apt-get update
sudo apt-get install nginx
  • To install MySQl :
sudo apt-get install mysql-server

We need to tell MySQL to generate the directory structure it needs to store its databases and information. We can do this by typing :

sudo mysql_install_db

Next, you'll want to run a simple security script that will prompt you to modify some insecure defaults. Begin the script by typing:

sudo mysql_secure_installation

It is location that you setup password for root account in MySQL.

  • Lastly, it is time for PHP-FPM :
sudo apt-get install php5-fpm php5-mysql

Default, Ubuntu will setup PHP 5.5.9, if you want to use PHP 5.6 or PHP 7, change above command like that :

sudo apt-get install php5.6-fpm php5.6-mysql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment