This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
proxy_http_version 1.1; | |
proxy_set_header Connection ""; | |
root /PROJECT_PATH/public; | |
index index.html index.htm index.php index.nginx-debian.html; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Command Document | |
First thing first fresh server add new user | |
# adduser administrator | |
# usermod -aG sudo administrator | |
Install NGINX | |
# sudo apt install nginx | |
# sudo ufw allow 'Nginx HTTP' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
composer install | |
# Change folder directory permission | |
sudo find project_folder -type f -exec chmod 664 {} \; | |
sudo find project_folder -type d -exec chmod 775 {} \; | |
# Change laravel directory permission | |
sudo chgrp -R www-data storage bootstrap/cache | |
sudo chmod -R ug+rwx storage bootstrap/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if ! type "jq" > /dev/null; then | |
echo "Please install jq command to commit. run command 'brew install jq'" | |
exit 1 | |
fi | |
currentVersion=$(jq .version .version.json | bc -l) | |
currentBuildNumber=$(jq .build_number .version.json | bc -l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#count total request | |
awk -F[:\ ] '{count[$5]++}; $12 == 200 { hour[$5]++} END { for (i in hour) print i, count[i] }' /var/log/nginx/access.log | sort | |
#count Ip address | |
cat /var/log/nginx/access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -20 | |
zcat /var/log/nginx/access.log.2.gz | awk '{print $1}' | sort -n | uniq -c | sort -nr | head -50 | |
# Deny IP | |
ufw insert 1 deny from 14.192.209.123 to any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){ | |
$redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
header("Location: $redirect"); | |
} | |
class Host { | |
private $ip; | |
private $hosts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_page 500 /500.html; | |
location /500.html{ | |
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}'; | |
} | |
error_page 502 /502.html; | |
location /502.html{ | |
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM webdevops/php-nginx:7.2 | |
ARG WHAT_ENVIRONMENT=local | |
ARG PROJECT_FOLDER_NAME=laravel_app | |
LABEL maintainer=hafiq | |
LABEL email=hafiq@terato.com | |
##################################### | |
# Software Installation # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: hafiq | |
* Date: 03/11/2019 | |
* Time: 11:36 PM | |
*/ | |
use Illuminate\Support\Facades\Schema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\PushNotification; | |
class Apns | |
{ | |
static function sendPush($deviceToken, $message, $type = '', $contentId = -1) { | |
// check if is not empty string | |
if (!isset($deviceToken) || strlen($deviceToken) == 0) { |