I bought a cheapest desktop computer from the Media Markt, because my old DELL Inspiron 8600 laptop with live web server on, feels it’s going to break any time.
Maybe it is just the stupid ZyXEL router or my ISP fault here, since I never had this problem before with the old router.
Some years has passed and it's 2015 and I can't turn back because I don't feel like to going to waste any more time.

Specs

Medion Intel Celeron J1900 Processor
2.0 Ghz, 2 MB Intel Smart Cache

  • 4 GB DDR3-SDRAM memory
  • 2000 GB hard disk
  • Intel HD graphics
  • Multiformat DVD/CD Burner
  • 4-in-1 multi-card reader
    for MS, SD, MMC and xD memory cards
  • Network controller
  • 6 channel audio
  • USB keyboard and optical USB mouse
  • Front connections: 2x USB 2.0, 1 x mirophone, 1 x headphone
  • HDMI out

This comes with 2014 Bios and Windows 8 preinstalled.

Partition the system

So what's the best Partition tool in 2015. I went to this site: Windows best partition manager
and downloaded MiniTool Partition Manager.
Because windows partition too basic and I need better userfriendly stuff.

My goal was 100 GB Windows and rest (around 1800 GB) for Ubuntu.
Shrinking the partition, then moving Windows Recovery partition with it.
So it would like
[Windows 8][Recovery][Free space]

Get the Elementary OS .iso

Magnet: Freya 32-bit
Magnet: Freya 64-bit

Save IMAGE to USB with UNetbootin

Installing Elementary OS from 2 GB USB stick

Pressing F2 or F8 after the chime.. I mean beep.. I mean when capslock turns on after reboot. Choosing Ubuntu

Hopefully I get the correct Grub menu and I go ahead and install directly.

Install SSH server

Elementary looks neat and well. Found out it's Ubuntu 14.04. Let's do terminal stuff.

Just installed new OS, let's update.

sudo apt-get update

And let's install SSH Server

sudo apt-get install openssh-server

Backing up the SSH config before messing up.

cd /etc/ssh; sudo cp sshd_config sshd_config.factory-defaults; sudo chmod a-w sshd_config.factory-defaults

Rest of the Guide

Install LAMP stack

sudo apt-get install apache2 mariadb-server php5-mysql php5 libapache2-mod-php5 php5-mcrypt php5-gd

Install MariaDB instead of MySQL

Fixing PHP MCrypt

sudo php5enmod mcrypt
sudo service apache2 restart 

Check your IP

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Stuff with apache

sudo service apache2 {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean}

Add user into a www-data group

Create user: mizu

sudo adduser mizu

Add user mizu in the www-data group

sudo gpasswd -a mizu www-data

Correct previously created files (assuming mizu to be the only user of /var/www)

sudo chown -R mizu:www-data /var/www
find /var/www -type f -exec chmod 0660 {} \;
sudo find /var/www -type d -exec chmod 2770 {} \;

More info Add User,
Security vhosts, Arrow Keys Not working in Terminal

Install other softwares

  • Git
  • NodeJS

NodeJS

sudo apt-get install npm

This will even download and install other dependencies

How to install NodeJS

Check NodeJS version

node -v

node -v might not work, try this:

nodejs -v

What you're using could be low version, so to update it

sudo npm cache clean -f; sudo npm install -g n; sudo n stable

This command really messed up my system

Source Upgrade NodeJS

When you do this on production instance, it can mess your global npm packages and ability to install new ones

This upgrade make node -v work again

Node Dependencies

  • forever
  • gulp
  • grunt-cli
  • bower
sudo npm install -g forever gulp grunt-cli bower

Migrating data

Files and folders

Knowingly Apache 2 creates /var/www directory, I can clone recursive directories from remote server

cd /var/www

Now you're as mizu:www-data

sudo -u mizu -g www-data ssh username@remote-server "cd /var/www; sudo -S tar --exclude='log' --exclude='vhosts/mysecretstash' -vczpf - ." | tar -vxzpf - -C /var/www  
  • -vczpf Verbose, Create, Gzip, Perserve Permissions, Archive File
  • -vxzpf Verbose, Extract, un-Gzip, Same Permissions, Force local

MySQL to MariaDB

From the old server you want to make backup of MySQL.

Export to file

sudo -s mysqldump -u root -pPassword --all-databases --skip-lock-tables > mycomputername_20150620.sql

To the server you want restore/import the backup to MariaDB.

Import from file

sudo -s mysql -u root -pPassword < mycomputername_20150620.sql

Another neat way to transport MySQL data directly.
Log in from to target server where you want to import data.

Log in root with: sudo -s

ssh username@remote-server "sudo -sS mysqldump -u root -pPassword --all-databases --skip-lock-tables" | mysql -u root -pPassword 

Check tables in your database in your MySQL CLI:

show databases

Fix Crontab

To make Crontab more awesome you need to set PATH to make magic happen.

sudo -s
crontab -e
# Set PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# On Reboot
@reboot /var/www/cron/forever_blog_mdstn_com.sh

# Send Email Uptime Report when website is offline every 20 minutes
*/20 * * * * /var/www/.bin/bash/sendMailUptimeReport.sh