Skip to content

Instantly share code, notes, and snippets.

View monbang's full-sized avatar
🌴
On vacation

monbang

🌴
On vacation
View GitHub Profile
@monbang
monbang / 000-default.conf
Last active May 1, 2020 05:55
Apache localhost
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
@monbang
monbang / Nginx caching pitfalls
Created May 1, 2020 03:39
Nginx caching pitfalls
Pitfalls when using caching in nginx
The web server and reverse-proxy nginx have very powerful features for caching HTTP responses. However, in some cases, documentation and examples are not enough, as a result, not everything turns out as easy and simple as we would like. For example, my nginx configs are written in blood in some places. With this article I will try to improve the situation a little.
In this article: a) pitfalls with full-page caching; b) caching with rotation; c) creating a dynamic “window” in a cached page.
I will assume that you are using the nginx + fastcgi_php bundle. If you are using nginx + apache + mod_php, just replace the directive names with fastcgi_cache * with proxy_cache *
If I choose whether to cache the page on the PHP side or on the nginx side, I select nginx. Firstly, it allows you to send 5-10 thousand requests per second without any difficulties and without smart talk about the "high load". Secondly, nginx independently monitors the size of the cache and cleans it both
@monbang
monbang / Configuring Nginx + LAMP server
Created May 1, 2020 03:38
Configuring Nginx + LAMP server
Configuring Nginx + LAMP server at home. Part 1: Setting up the frontend - backend
Hello. I recently asked a question about creating a series of articles. Here is the first article.
In this series of articles, you will learn how to correctly configure the LAMP server, but "hosting is only more powerful."
We will use the following stack: nginx - apache-mpm-itk - mod_php - mysql - linux / debian.
I will cover the following topics:
Frontend setup - backend
Calculation of server capabilities, setting up mysql and backend
@monbang
monbang / links
Created April 30, 2020 13:21
links
@monbang
monbang / MYSQL strict mode
Created April 30, 2020 10:17
MYSQL strict mode
Step 1: Check if strict mode is enabled
We first need to establish if strict mode is enabled on the MySQL
server. To check this, type the command below on a terminal server:
$ sudo mysql -u root -p
Enter your MySQL database root password and press Enter.
Then, you will need to run the query below on the MySQl command prompt:
$ SHOW VARIABLES LIKE 'sql_mode';
@monbang
monbang / SSH config
Created April 30, 2020 10:15
SSH config
SSH
Generate ssh keys
Ed25519 is an EdDSA scheme with very small (fixed size) keys,
introduced in OpenSSH 6.5, to check sshd version use sshd -V
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_personal_$(date +%Y-%m-%d)
-C "Let's Play" -a 100 ,
for old severs ssh-keygen -t rsa -b 4096 -o -a 100
@monbang
monbang / bash aliases
Created April 30, 2020 10:11
bash aliases
# delete all but .ext "rm -- !(*.ext)"
# file and folder permissions
# find . -type f -exec chmod 644 {} \; file permissions
# find . -type d -exec chmod 755 {} \; folder permissions
# dos to unix
# find . -type f -name '*.php' -exec dos2unix '{}' +
# photo on trm "display photo.ext"
@monbang
monbang / deploy with git
Created April 30, 2020 07:34
deploy with git
#Automated Deployment of PHP Applications using git
Heroku is a sweet hosting platform which offers a pure git deployment workflow. I love using it to deploy my Rails projects. I miss using it when I deploy a PHP application.
Lets fix that…. Here is a quick heroku-ish git deployment workflow for your PHP applications. We will be using Wordpress for this example. The same steps can be adapted for Drupal or any other PHP application.
Our goal is to development and test new features, themes, and plugins for Wordpress locally on our development machine. When changes are working properly, we want to deploy them to our live site with one command:
git push origin master
#1: Set up password-less login to your webserver with SSH keys
@monbang
monbang / config
Created April 25, 2020 17:07
i3bar
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
@monbang
monbang / config
Created April 25, 2020 17:06
i3wm
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!