Skip to content

Instantly share code, notes, and snippets.

@kolunar
kolunar / gist:ee6fddf83e563e0619586540f0fc0247
Created April 24, 2017 22:52
Changing password for MySQL's account
A root account password can be set several ways. The following discussion demonstrates three methods:
Use the SET PASSWORD statement
Use the UPDATE statement
Use the mysqladmin command-line client program
To assign passwords using SET PASSWORD, connect to the server as root and issue a SET PASSWORD statement for each root account listed in the mysql.user table.
@kolunar
kolunar / gist:53983ee3facb1ab1068171e87d9d8edb
Created April 24, 2017 22:52
MySQL dump/create database and grant all privileges to specific user
mysqldump -uroot databasename > database.sql
mysql create database databasename DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Option1
=======
$ mysqldump yourFirstDatabase -u user -ppassword > yourDatabase.sql
$ mysql yourSecondDatabase -u user -ppassword < yourDatabase.sql
Option2
@kolunar
kolunar / gist:bdef45f9e7c23b197ea6aeac50ce7c5b
Created April 24, 2017 22:53
installing php5-fpm on Ubuntu Server 14.04 TLS LAMP stack
Assuming that you're starting with a basic LAMP stack, first you need to install the needed packages:
sudo apt-get install libapache2-mod-fastcgi php5-fpm
Then create the file "/etc/apache2/conf-available/php5-fpm.conf" with the contents:
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Check if query caching is available:
mysql> show variables like 'have_query_cache';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+
Check if query caching is enabled:
mysql> show variables like 'query%';
@kolunar
kolunar / gist:a81403e372e039e393a0caa71034b43d
Created April 24, 2017 22:53
php5-imagick for Digital Packages Image upload
Digital Packages Image upload utilizes blueimp image upload bundle and requires php-gd to be installed, you can check gd using phpinfo().
You can also use blueimp with other two image libraries, imagick and imagemagick, please see UploadHandler.php in the blueimp bundle for changing the options.
apt-get install php5-imagick
php5enmod imagick
apt-get install imagemagick php5-imagick
service apache2 reload
@kolunar
kolunar / gist:3141b569938c20c3501565396fb6d8a2
Created April 24, 2017 22:54
SSH search keywords, files & folders basic commands
grep -r -H "search string" *
ref: https://www.siteground.com/tutorials/ssh/ssh_searching.htm
find /path/to/fies -type f -name "*.js" -exec grep -il 'string' {}\; > output.txt
count number of files within a dir recursively or specifically:
==============================================================
$ find /var/www/html/cache/ -type f -print | wc -l
$ ls | wc -l
zip all files in a dir
======================
zip -r filename.zip foldername/
zip all files in current dir
=============================
zip -r filename.zip *
unzip
=====
@kolunar
kolunar / gist:3586a459e371d328f4d766d34c82782a
Created April 24, 2017 22:55
How To Set Up mod_rewrite for Apache on Ubuntu 14.04
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite
sudo a2enmod rewrite
sudo service apache2 restart
sudo nano /etc/apache2/sites-enabled/000-default.conf
Follow the instructions from the link given above
@kolunar
kolunar / gist:265620ed21fcca6eeb920b95bb5c2040
Created April 24, 2017 22:55
Creating and Enabling ftp user and access
1. mkdir /var/www/mydomain.com
2. mkdir /var/www/mydomain.com/html
3. useradd <-username>
4. passwd <-username>
5. chown –R <-username> /var/www/mydomain.com
5. groupadd <-groupname>
6. gpasswd -a <-username> <-groupname>
7. chgrp -R <-groupname> /var/www/mydomain.com
8. chmod -R g+rw /var/www/mydomain.com
@kolunar
kolunar / gist:aa9d645717afe74add0b6d408cb3bde3
Created April 24, 2017 22:55
Changing open file limit for all users on Ubuntu
First, check "$ ulimit -a".
Go to /etc/security/limits.conf and add the two lines described below:
* soft nofile 10240
* soft nproc 10240
Reboot system or add following line to the end of /etc/pam.d/common-session:
session required pam_limits.so