Skip to content

Instantly share code, notes, and snippets.

View dharma017's full-sized avatar

Dharma R. Thapa dharma017

  • Melbourne, Australia
View GitHub Profile
@dharma017
dharma017 / install-comodo-ssl.md
Last active August 20, 2024 08:53
Install Comodo SSL

Generate private key and csr file

openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

server.key: it is the private key used on the TLS protocol.
server.csr: it is the required certificate signing request.

If all three certificates are listed separately, use the command:

@dharma017
dharma017 / allowed-memory-size-exhausted.md
Created August 20, 2024 08:44
Fixing PHP Fatal Error: Allowed Memory Size Exhausted

Navigate to your php.ini file and edit it

sudo vim /etc/php/7.4/fpm/php.ini

Update parameters as following

upload_max_filesize = 256M
post_max_size = 256M
memory_limit = 512M
max_execution_time = 180
@dharma017
dharma017 / delete-mysql-log-file
Created August 20, 2024 08:41
Delete MySql Log File
Erase all binary logs before midnight 3 days ago.
PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0 SECOND;
If you want to have binlog rotated away automatically and keep 3 days worth, simply set this:
mysql> SET GLOBAL expire_logs_days = 3;
then add this to /etc/my.cnf
# List all running application
pm2 list
# Save application to be opened at reboot (only if you are adding new projects or path modified)
pm2 save
# Restart all saved application automatically
(When server restarted and no Node running process or when server down)
pm2 resurrect
@dharma017
dharma017 / create_mysql_user_grant_permission
Created August 20, 2024 08:24
Connecting a Database to a Docker Container Running a Laravel Project
# Create mysql user and grant permission
CREATE USER 'laraveluser'@'%' IDENTIFIED BY 'passwordhere';
GRANT ALL PRIVILEGES ON dbname.* TO 'laraveluser'@'%';
FLUSH PRIVILEGES;
@dharma017
dharma017 / ebs-deploy
Created August 20, 2024 08:17
AWS: Deploy Laravel application to Elasticbeanstalk
pip install awsebcli --upgrade --user
cd project
eb init
zip -r dir.zip . -x ".DS_Store" -x "__MACOSX"
eb deploy
@dharma017
dharma017 / update-craft-cms-user-password
Last active August 20, 2024 08:40
Update User Password Hash for Craft CMS
<?php
echo password_hash('passwordhere', PASSWORD_DEFAULT, ['cost'=> 13]);
@dharma017
dharma017 / nginx_with_ssl_conf.conf
Last active August 21, 2024 23:49
Wordpress Setup
server {
root /var/www/foobar.com/public_html;
index index.php;
server_name foobar.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/etc/nginx/ssl/{{host}}.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/{{host}}.key;
ssl_ciphers HIGH:!aNULL:!MD5;
# listen 80;
server_name {{host}};
@dharma017
dharma017 / ovveride-path-of-php-with-mamp-path.md
Created June 16, 2017 08:50
Use MAMP php instead of native MAC php

Bash Shell

Use MAMP version of PHP

PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1 export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

Fish Shell

set PHP_VERSION (ls /Applications/MAMP/bin/php/ | sort -n | tail -1) set -x PATH /Applications/MAMP/bin/php/$PHP_VERSION/bin $PATH set -x PATH /Applications/MAMP/Library/bin/ $PATH