Skip to content

Instantly share code, notes, and snippets.

up vote
26
down vote
accepted
First, to create 4,000 MB of swap space:
$ sudo dd if=/dev/zero of=/swapspace bs=1M count=4000
4000+0 records in
4000+0 records out
4194304000 bytes (4.2 GB) copied, 5.92647 s, 708 MB/s
@Sunnyztj
Sunnyztj / gist:6e712dfd0c7273864ed9f4678940f1f6
Last active January 26, 2017 23:18
ubuntu server fail2ban setup

https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-ubuntu-14-04 Introduction

While connecting to your server through SSH can be very secure, the SSH daemon itself is a service that must be exposed to the internet to function properly. This comes with some inherent risk and creates a vector of attack for would-be assailants.

Any service that is exposed to the network is a potential target in this way. If you pay attention to application logs for these services, you will often see repeated, systematic login attempts that represent brute force attacks by users and bots alike.

A service called fail2ban can mitigate this problem by creating rules that can automatically alter your iptables firewall configuration based on a predefined number of unsuccessful login attempts. This will allow your server to respond to illegitimate access attempts without intervention from you.

In this guide, we'll cover how to install and use fail2ban on an Ubuntu 14.04 server.

======= Prolbem =================================================================================================================
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute:
rake db:create , command I get:
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'.......
bin/rake:16:in `load'

Create user deploy

  1. sudo adduser deploy
  2. sudo adduser deploy sudo
  3. visudo
deploy  ALL=(ALL) ALL
deploy ALL=(ALL) NOPASSWD: ALL (* ubuntu 18.04 *)
$ sudo su
$ su postgres
$ psql
$ create database [database_name] with owner = deploy;
$ \q
$ exit
$ exit
$ psql --user deploy --password [database_name]
$ \q
Previously I’d only ever posted this in my ebook, WordPress Multisite 110.
What people mean by this is the site they originally set to be seen at domain.com is no longer the one they want to use, but the one at (say) domain.com/temp or temp.domain.com. If this is what you’re wanting to due, it’s not impossible, but it is annoying and a little tricky. If you’re using the trick to give WP it’s own directory, these are not the directions you’re looking for. I haven’t written those out yet.
First you have to go to Network Dashboard > Sites and edit the site you want to be the main site.
Example.com using two
This you want to to look like this:
@Sunnyztj
Sunnyztj / gist:c97eab89c8c73b6c10d9
Last active April 1, 2016 22:32
fix 建立数据库连接时出错
sudo service mysql start
if start: Job failed to start :
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
@Sunnyztj
Sunnyztj / gist:da0e40858fc635237c71
Created December 14, 2015 03:09
.htaccess file setup
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
@Sunnyztj
Sunnyztj / gist:159ba92737814a9d6858
Last active February 20, 2020 00:07
wordpress setup
sudo adduser deploy
sudo adduser deploy sudo
su deploy
sudo apt-get update
sudo apt-get install lamp-server^ php5-gd libssh2-php
sudo mysql -u root -p
http://fortawesome.github.io/Font-Awesome/cheatsheet/