Skip to content

Instantly share code, notes, and snippets.

@Skylarity
Last active December 7, 2016 17:18
Show Gist options
  • Save Skylarity/e46c0e50cd498c626e8eb7754c8988cc to your computer and use it in GitHub Desktop.
Save Skylarity/e46c0e50cd498c626e8eb7754c8988cc to your computer and use it in GitHub Desktop.
Setting Up Encrypted Config Files

FIRST TIME SETUP:

On the server:

Create directory

$ cd /etc/apache2
$ mkdir encrypted-config

Set permissions

$ chmod 700 encrypted-config
$ chown www-data:www-data encrypted-config
$ cd encrypted-config

Locally:

Upload files

$ scp aes256.php skyler@skylerrexroad.com:/tmp
$ scp encrypted-config.php skyler@skylerrexroad.com:/tmp

On the server:

Move files to proper directory

$ mv /tmp/aes256.php /etc/apache2/encrypted-config/
$ mv /tmp/encrypted-config.php /etc/apache2/encrypted-config/

Set permissions

$ chmod 600 aes256.php
$ chmod 600 encrypted-config.php
$ chown www-data:www-data aes256.php
$ chown www-data:www-data encrypted-config.php

NEW PROJECTS:

On the server:

Create new directory to house .ini file (Or store them anywhere you like, as long as it's NOT IN THE PROJECT DIRECTORY)

$ mkdir /etc/apache2/encrypted-config/project-name

Locally:

Upload template to use

$ scp encrypted-config-template.php skyler@skylerrexroad.com:/tmp

On the server:

Move template to proper directory, and rename to be project-specific

$ mv /tmp/encrypted-config-template.php /etc/apache2/encrypted-config/project-name/project-name.php

Edit this file to reflect proper project credentials

Then, create the .ini file

$ sudo touch /etc/apache2/encrypted-config/project-name/project-name.ini
$ sudo php project-name.php

DELETE UNENCRYPTED TEMPLATE FILE

$ rm /etc/apache2/encrypted-config/project-name/project-name.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment