Skip to content

Instantly share code, notes, and snippets.

View anhtuank7c's full-sized avatar
🎯
Focusing

Tuan Nguyen anhtuank7c

🎯
Focusing
View GitHub Profile
@anhtuank7c
anhtuank7c / nginx
Last active February 26, 2016 09:34
server {
listen 80;
server_name cakephp.org www.cakephp.org;
# root directive should be global
root /var/www/cakephp.org/webroot/;
index index.php;
access_log /var/www/cakephp.org/logs/nginx_access.log;
error_log /var/www/cakephp.org/logs/nginx_error.log;
@anhtuank7c
anhtuank7c / subdomain.your_domain.conf
Last active March 24, 2016 07:22
Demo config apache virtual host
<VirtualHost *:80>
ServerAdmin support@your_domain.com
ServerName subdomain.your_domain.com
ServerAlias www.subdomain.your_domain.com
DocumentRoot /var/www/subdomain.your_domain.com
# your folder /var/www/subdomain.your_domain.com
<Directory /var/www/subdomain.your_domain.com>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php index.html
AllowOverride All
@anhtuank7c
anhtuank7c / .htaccess
Last active April 6, 2016 15:42
CakePHP: Redirect old domain to new domain using .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old_domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old_domain.com [NC]
RewriteRule ^(.*)$ http://new_domain.net/$1 [L,R=301,NC]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
@anhtuank7c
anhtuank7c / .htaccess
Created April 6, 2016 15:56
.htaccess gzip compress
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
@anhtuank7c
anhtuank7c / Let's Encrypt
Last active August 11, 2016 07:44
Install Let's Encrypt, create cert, automatic renew cert for Apache Ubuntu
(setup ssl self-cert first https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04)
1) Install the Server Dependencies:
apt-get update
apt-get install git
2) Download the Let’s Encrypt Client:
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
3) Set Up the SSL Certificate:
@anhtuank7c
anhtuank7c / LdapAuthenticate.php
Created April 9, 2016 17:31
LDAP authentication
<?php
namespace App\Auth;
use Cake\Auth\BaseAuthenticate;
use Cake\Network\Request;
use Cake\Network\Response;
class LdapAuthenticate extends BaseAuthenticate
{
@anhtuank7c
anhtuank7c / Install mysql server 5.7
Last active June 7, 2016 02:11
Install mysql server 5.7 on ubuntu 16
Go to http://dev.mysql.com/downloads/repo/apt/ then download the .deb file to your server
Install downloaded package: sudo dpkg -i package_name
Update Apt: sudo apt-get update
Install mysql: sudo apt-get install mysql-server
After install, going to secure it:
sudo mysql_secure_installation
@anhtuank7c
anhtuank7c / Install php 5.6 ubuntu 16
Created June 7, 2016 02:21
Install php 5.6 ubuntu 16
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
you can install more php5.6 module
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-intl php5.6-intl php5.6-mbstring php-apcu php-uuid php5.6-cgi php5.6-cli php5.6-gd php5.6-ldap php5.6-sqlite3 php-uploadprogress
@anhtuank7c
anhtuank7c / install_nginx.sh
Last active August 12, 2016 06:47
Install nginx with ngx_pagespeed on ubuntu 14.04 (blank new server), config nginx to support vhost, create demo vhost, deploy demo cakephp project. (aws ec2)
#!/bin/bash
## Author: Anh Tuan Nguyen (anhtuank7c@hotmail.com)
## Created: 08/08/2016
# update, upgrade to latest source
sudo apt-get update -y
sudo apt-get upgrade -y
# GOOGLE PAGE SPEED
sudo apt-get install -y build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
@anhtuank7c
anhtuank7c / install_nginx_php7.sh
Last active March 8, 2017 09:45
Install nginx, openssl, google pagespeed, php7.0, mysql 5.7, phpmyadmin, cakephp 3.x on ubuntu 14.04 with default account "ubuntu". If your server don't have ubuntu account, please replace ubuntu by your account. Download this script to your server then "chmod +x install_nginx_php7.sh". Execute script by "./install_nginx_php7.sh"
#!/bin/bash
## Author: Anh Tuan Nguyen (anhtuank7c@hotmail.com)
## Created: 08/08/2016
## Install nginx, openssl, php7.0, mysql 5.7, phpmyadmin, cakephp 3.x
# update, upgrade to latest source
sudo apt-get update -y
sudo apt-get upgrade -y
# GOOGLE PAGE SPEED