Skip to content

Instantly share code, notes, and snippets.

View efarem's full-sized avatar

EFAREM efarem

  • London, UK
View GitHub Profile
@efarem
efarem / convert-apache-php-fpm
Created May 24, 2016 15:09
Convert Apache to PHP-FPM
#!/bin/bash
# Install dependencies
sudo apt-get install -y apache2-mpm-worker
sudo apt-get install -y libapache2-mod-fastcgi php5-fpm
# Disable prefork & Enable fcgi
sudo a2dismod php5 mpm_prefork
sudo a2enmod actions fastcgi alias mpm_worker
@efarem
efarem / gitautodeploy.sh
Created July 24, 2015 13:50
Git Auto Deploy init script for CentOS 6
#!/bin/bash
#
# /etc/init.d/gitautodeploy
#
# Service manager for GitAutoDeploy
#
# chkconfig: 345 70 30
# description: Git Auto Deploy is a simple HTTP server for accepting push notifications from GitLab
# processname: gitautodeploy
@efarem
efarem / new-sftp-user
Created March 5, 2015 17:21
New SFTP User
useradd [username]
passwd [username]
usermod -g www-data -G [username] -d [home-directory] -s /usr/sbin/nologin [username]
Add this to bottom of /etc/ssh/sshd_config
Match User [username]
ChrootDirectory [home-directory]
PasswordAuthentication yes
X11Forwarding no
@efarem
efarem / ssl-generate-csr
Created September 9, 2014 09:21
SSL Generate CSR
sudo openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr
@efarem
efarem / mysql-random-number
Created July 17, 2014 08:15
MySQL Random Number
(FLOOR( 100 + RAND( ) * 1000 ))
@efarem
efarem / plesk-reload-domain
Last active August 29, 2015 14:00
Plesk - Reload domain/vhost config
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain example-domain.com
@efarem
efarem / php-configure
Last active December 31, 2015 15:29
PHP - Config pre build command
./configure --prefix=/usr/local/src/php-5.4.23 --with-config-file-path=/usr/local/src/php-5.4.23/lib/php.ini --enable-cgi --enable-soap --with-pdo-mysql --with-curl --with-mysql --with-openssl --enable-force-cgi-redirect
@efarem
efarem / plesk-add-php
Last active December 31, 2015 15:29
Plesk - Add a new PHP version
/usr/local/psa/bin/php_handler --add -id "5.4.23" -displayname "5.4.23" -path /usr/local/src/php-5.4.23/bin/php -phpini /usr/local/src/php-5.4.23/lib/php.ini -type "fastcgi"
@efarem
efarem / WooCommerce Payment Gateway
Created October 21, 2013 14:27
Basic template for WooCommerce Payment Gateway Class
<?php
class WC_Gateway_EFAREM extends WC_Payment_Gateway
{
public function __construct()
{
$this->id = 'efarem';
$this->icon = plugin_dir_url(__FILE__) . '/assets/images/efarem.png';
$this->has_fields = true;
$this->method_title = '{Title of Gateway}';
@efarem
efarem / is_blog
Created October 1, 2013 15:45
WordPress function to tell if you're on a blog page, current page is a blog page
<?php
/**
* Are we on a blog page?
*
* @return bool
**/
function is_blog()
{
return (is_post_type_archive('post') || is_author() || is_category() || is_home() || is_singular('post') || is_tag()) ? true : false ;