Setting up Git with 1&1

Next in my quest to move my website design to a more professional workflow is using version control more thoroughly.

For me this means getting to grips with a little app that I’ve been avoiding for a few years – GIT!

So what’s my goal….
Basically I want a local development server that links to a remote ‘live’ server – giving me the ability to test content and develop apps, whilst being able to go back a few steps and branch my development.

This post will track my first attempt – so I’ll probably tidy up things in a guide later…

As a first attempt I’m going to follow this guy:-

http://blog.woodylabs.com/2012/01/1and1-web-hosting-git-installing-it-for-singular-dev/

…and as this is a little bit of an experiment I’ll be attempting it first on the dev.galiquis.com section.

  • Open SSH session
  • cd to dev.galiquis.com root folder
  • create two new directories:-
    • …/dev/live (live site)
    • …/dev/repo (git repository to store all the changes)
  • Next create the local folder to develop in (part of the WAMP Server folder structure)
  • right click in folder > select ‘git bash here’ > type ‘git init’
  • Back to SSH
  • Change directory to the repo directory > ‘cd ./dev/repo’
  • type ‘git init –bare’ > message “Initialized empty Git repository…”

The next step is slightly different from the guide I’m following….

  • ‘vim ./hooks/post-receive’ (opens vim with a blank new document ‘post-recieve’
  • ‘i’ to insert text into the new file, typing:-
    • #!/bin/sh
    • GIT_WORK_TREE=”../live” git checkout -f
  • ‘esc’ to exit insert mode > ‘:’ > wq (save and quit)

Next we need to make it executable…and back to the guide…

  • chmod +x ./hooks/post-receive

### so far so good – but the next stage (establishing a SSH link) is causing problems ###

The solution to my SSH headache was turning to GUI tool – SourceTree

It was a simple install and when pointed at the local dev folder it piked everything up.

But the SSH issue…

  • Tools > Options > General
  • I took the opportunity to ad in my name and email in the global settings…
  • set SSH Client to Putty/Pink – leaving the tick in Auto start SSH agent > ok
  • Tools > Create or Import SSH Keys
  • I decided to create a new key…
    • Click ‘Generate’, then move your mouse randomly while it generates a key for you
  • Once created I saved private and public versions in my user folder
  • Tools > Options > General
  • SSH Client Configuration > SSH Key > navigate to, and select the new private key > ok

Thats the key configured, now the connection

  • Still in SourveTree > ‘Settings’ > ‘Add’
  • ‘Remote name:’ > enter an identifier name
  • ‘URL / Path’ > ‘ssh://[username] @ [host] / [remote repo folder]
  • ‘Host Type’ > Unkown > ok > ok

Finally test the connection using ‘push’…password entered and it all works 🙂

 

Peace

G

 

WordPress migration to a new host – Part 2

Preparing the new platform

  1. Create a new directory
  2. Create a new SFTP account
  3. Create a new mySQL DB and user
  4. Update wp-config.php
  5. Update DNS to point to the new folder

Create a new directory

Just one minor rant before I get started – 1&1 your cPanel replacement is rubbish!!!

Anyway job number 1 is creating a folder on the server for everything to be dumped into.

  • Log into 1&1 admin page > left-hand menu ‘Web Hosting Overview’ > WebspaceExplorer

This brings up a new page with an embedded folder view.

  • ‘New folder’ icon or select ‘file’ > ‘New folder’
  • type the folder name > ok

Create a new SFTP account

  • Left-hand panel ‘Secure FTP account’
  • Select ‘New user’ button
  • Complete desired:-
    • User name – or more precisiely the second half of the desired username as it uses the main account name as the first half.
    • Password, also with a ‘Repeat password’
    • Description – one habbit I’ve made myself get into is always writing meaningful descriptions to my future self
    • Directory – point this at the newly created directory above
  • click the ‘save’ button

Rather than creating a global account and using this for all sites I’m compartmentalising everything – to keep it all segregated and in order.

Create a new mySQL DB and user

  • Left-hand panel ‘MySQL Database’
  • Select ‘New database’ button
  • Complete the desired info:-
    • Description of the new database
    • Version of the new database : MySQL 5.5
    • Password & Repeat password
  • Click ‘set up’
  • Note down the details of the database
  • Click ‘Go To Overview’

Update wp-config.php

Next the new database settings need to be added tot he wp-config file.

  • In the root directory of the downloaded site open wp-config.php with a text editor – Notepad++ for me.
  • Change the following, to the values from above:-
    • define(‘DB_NAME’, 1&1databasename’);
    • define(‘DB_USER’, 1&1username’);
    • define(‘DB_PASSWORD’, 1&1password);
    • define(‘DB_HOST’, 1&1hostname’);
  • Save this

Update DNS to point to the new folder

  • Left-hand panel > Domains
  • Click ‘Transfer domain from another provider’
  • ‘Domain check’ > type in the domain > select the right top level endind > click ‘check’
  • select/check ‘Point DNS to 1&1 name servers and keep your current registrar.’ > ‘next’
  • select ‘Use the 1&1 mail servers.’ > next
  • Note down the details > click ‘order’

Next the new domian needs to be pointed at the right folder

  • Left-hand panel > Domains > ‘Manage domains’
  • Select the relevant domain > ‘Edit Destination’
  • In the Webspace section select the desired folder > ‘save’

 

WordPress migration to a new host – Part 1

I intend to do the move in three stages:-

  1. Export and download the current site – files and DB
  2. Prepare the new platform
  3. Upload and Import the content and DB
  4. Alter domain details to point to the correct nameservers

Simple…I hope

First up Satiricalblog.com – which on first look at the admin section reminds me how infrequently I use this blog, kill the spam from the comments section (243 waiting approval) or update things (20 updates pending).

So pre-step 1  is getting it all updated so everything it going across clean.

Export and download the current site

  1. Grab a WordPress export of the site
  2. Export the MySQL Database
  3. Download all WordPress files via SFTP

Grab a WordPress export of the site

Time to grab an export of the site which will contain the posts, pages, comments, custom fields, categories, and tags

  • Log into the admin section -> Tools -> Export
  • Select ‘All content’
  • Click ‘Download Export File

Doing this just highlights my frustration with my current hosting package as several times I ran into ‘502 bad gateway’ error messages. However I still ended up with a fairly hefty xml file.

The above phase isn’t 100% necessary as I’m going to take an extract of the database but I like the ‘belt and braces’ approach.

Export the MySQL Database

So onto the database extract and for this I need to log into cPanel.

  • From the home screen > Database section > phpMyAdmin

This step again highlighted an important lesson I need to bear in mind on the new platform – keeping database naming conventions in mind and relevant to the site/project. Fortunately I had named this sites DB something relevant – more by luck than judgement.

  • In phpMyAdmin select the database from the left-hand panel
  • Then in the right-hand panel click ‘export’
  • Select the option ‘Quick – display only the minimal options’
  • Select the ‘SQL format’
  • Click ‘OK’

This downloads an sql file with all the DB content.

Download all WordPress files via SFTP

Now it’s time to grab the files from my current host via good old ftp.

For this I chose to use WinSCP, having not used ftp clients in many years it seemed to have the best reviews and least malware.

One thing to note here, I grabbed everything rather than getting picky over which files I might need.

So while that transfers I’m going to get some sleep.

Peace

G