MySQL shutdown unexpectedly on XAMPP – Server socket created on IP: ‘::’

  1. Take backup all files+folder from folder mysql/data to mysql/data_old_backup
  2. Sometime XAMPP MySQL service stopped working, in my case reason in XAMPP control panel: “Error: MySQL shutdown unexpectedly” with the same error log

Solution:

  1. I have fixed the same issue, copy (+overwrite) all files+folder from xampp/mysql/backup/ into xampp/mysql/data/
  2. You may lost your Mysql root password after step-1, your mysql password is null now.
  3. Now, Copy (+overwrite) file ibdata1 from backup folder from “mysql/data_old_backup/ibdata1” to xampp/mysql/data/
    (because you want to restore all your data)
  4. Start MySQL from XAMPP control panel.

Couldn’t load private key format too new

This issue happens when you use PuTTYgen to generate or convert to a ppk key.

When you use PuTTYgen to generate or convert to a ppk key and leave PuTTYgen settings as default, you might experience this issue.

From PuTTY version 0.75, the program uses a new format to generate the SSH private key; it uses ppk version 3. However, PuTTY 0.74 or earlier versions can’t read this format, and this can be a problem for programs that use PuTTY internally, like Solar PuTTY or MobaXtermn. If the internal PuTTY version is not compatible with PPK version 3, the program can’t use keys created with a default setting of PuTTY 0.75.

Solution

You can generate a new SSH key pair or change the private key format of an existing private key using PuTTYgen .

Step 1: Change the PuTTYgen PPK File Version to version 2.

Run the PuTTYgen program. Go to Key > Parameters for saving key files…

Changing the Version of the SSH Private Key

Change the PuTTygen PPK File Version to version 2.

Changing the Version of the SSH Private Key

Step 2: Generate a new SSH key pair or change the format of an existing one.

After following step one, you can now generate a key using the ppk version 2. You will be able to SSH to the cloud instance. This option is better if you are just creating the cloud instance. 

Step 3: Click on Load and search for your ppk key (version 3). Click Save private key, to convert the key to the old ppk format.

Changing the Version of the SSH Private Key

Set Up Docker Python

Requirements:
Install Python and Docker

Create folder on computer named docker-python and follow steps below:

cd /path/to/python-docker 
pip3 install Flask 
pip3 freeze | grep Flask >> requirements.txt 

Create app.py file and add this code

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, Docker!'

Create a Dockerfile for Python

# syntax=docker/dockerfile:1

FROM python:3.8-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . .

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

Directory structure is now:

python-docker
|____ app.py
|____ requirements.txt
|____ Dockerfile

Build an image:

docker build --tag docker-python .

Run your image as a container with ability to open in browser

docker run --publish 5000:5000 docker-python

Test in terminal to see if works

curl localhost:5000
Hello, Docker!

Check Docker Desktop and you should see it listed as a running container with ability to open in browser!

WAMP Virtual Hosts

Setting Up Overall Structure

Keep localhost homepage in default location on C drive. Set up all websites to be virtual hosts that you configure from the localhost homepage which will be the name of website ending in .local.

Update httpd-vhosts.conf to make files.local URL point to the D drive. This will make WordPress sites work when the database is not updated with new domain. Add this code to the file:

<VirtualHost *:80>
   DocumentRoot "d:/sites"
   ServerName files.local
   <Directory "/">
      AllowOverride All
      Require local
      Allow from All
      Require local
   </Directory>
</VirtualHost>

Add an htaccess to C:\wamp64\www so that all localhost links except the homepage rewrite to files.local which points to D drive

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://files.local/$1 [L]

Setting Up HTTPS

  1. Download and Install OpenSSL
    OpenSSL is available in both 32 and 64 bit. Make sure you select the correct installer for your version of Windows. You can find the latest version of OpenSSL here https://slproweb.com/products/Win32OpenSSL.html. Navigate to your downloads folder and double click the installer. When Installing OpenSSL leave all settings default.
  2. Create Your Key and Certificate
    Open your start menu and Load Command Prompt as an Administrator and run the following commands.

    First, we will need to change our directory to where we installed OpenSSL.
    cd D:\Program Files\OpenSSL-Win64\bin

    Next, we will create our private key. You will be asked for a passphrase. Make it anything you want just make sure you remember it for the next step.
    openssl genrsa -aes256 -out private.key 2048
    openssl rsa -in private.key -out private.key

    Next, we will create our certificate. You will be asked several questions on this step. You can put whatever you like or just hit enter to leave it at default. The only one that really matters is Common Name (e.g. server FQDN) you will need to type “localhost” for this.
    openssl req -new -x509 -nodes -sha1 -key private.key -out certificate.crt -days 36500
  3. Move your Key and Certificate
    Create a folder named “key” in the C:\wamp64\bin\apache\apache2.4.23\conf directory.

    Navigate to c:/program files/openssl-win64/bin/ to find the certificate.crt and private.key that you just created. Both of these need to be moved to the new folder c:/wamp64/bin/apache/apache2.4.41/conf/key/.
  4. Edit Your httpd.conf File
    Open c:/wamp64/bin/apache/apache2.4.23/conf/httpd.conf and un-comment (remove the #) the following 3 lines:
    LoadModule ssl_module modules/mod_ssl.so
    Include conf/extra/httpd-ssl.conf
    LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
  5. Edit Your httpd-ssl.conf File
    Open up C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-ssl.conf and replace content with:
Listen 443

DocumentRoot "c:/wamp64/www"
ServerName localhost:443
ServerAdmin info@christinewilson.ca
SSLSessionCache "shmcb:${SRVROOT}/logs/ssl_scache(512000)"
ErrorLog "${SRVROOT}/logs/error.log"
TransferLog "${SRVROOT}/logs/access.log"
SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

<VirtualHost localhost:443>

	DocumentRoot "c:/wamp64/www"
	ServerName localhost:443
	ServerAlias localhost
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "d:/sites">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

<VirtualHost files.local:443>
 
	DocumentRoot "d:/sites"
	ServerName files.local:443
	ServerAlias files.local
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "d:/sites">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

Adding New Websites

Open hosts file in C:\Windows\System32\drivers\etc\hosts to point new domain name to localhost:

127.0.0.1	mongooseandmink.local

Add Virtual Host on localhost homepage for http.

Add Virtual Host on https by opening up C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-ssl.conf and add:

<VirtualHost mongooseandmink.local:443>
 
	DocumentRoot "D:/sites/ouioui"
	ServerName mongooseandmink.local:443
	ServerAlias mongooseandmink.local
	ServerAdmin info@christinewilson.ca
	ErrorLog "${SRVROOT}/logs/error.log"
	TransferLog "${SRVROOT}/logs/access.log"

	SSLEngine on
	SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
	SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"

	<FilesMatch "\.(cgi|shtml|phtml|php)$">
		SSLOptions +StdEnvVars
	</FilesMatch>

	<Directory "D:/sites/ouioui">
		SSLOptions +StdEnvVars
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		Require all granted
		AllowOverride All
	</Directory>

	BrowserMatch "MSIE [2-5]" \
			 nokeepalive ssl-unclean-shutdown \
			 downgrade-1.0 force-response-1.0

	CustomLog "${SRVROOT}/logs/ssl_request.log" \
			  "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

Websites with Old WordPress Database

For WordPress websites with old database (URL is localhost still), Update the htaccess to remove the folder

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /ouioui/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ouioui/index.php [L]
</IfModule>

Update wp-config file to use new domain name:

define( 'WP_HOME', 'http://mongooseandmink.local/' );
define( 'WP_SITEURL', 'http://mongooseandmink.local/' );

Set Up an SSH Key for SourceTree (Windows)

Purpose

When you set up SSH, you create a key pair that contains a private key (saved to your local computer) and a public key (uploaded to Bitbucket). Bitbucket uses the key pair to authenticate anything the associated account can access. This two-way mechanism prevents man-in-the-middle attacks.

This first key pair is your default SSH identity. If you need more than a default identity, you can set up additional keys.

For security reasons, we recommend that you generate a new SSH key and replace the existing key on your account at least once a year.

You can’t use the same key between accounts. You must create new keys for each individual Bitbucket account.

Set up SSH for Git on Windows

Use this section to create a default identity and SSH key when you’re using Git on Windows. By default, the system adds keys for all identities to the /Users/<username>/.ssh directory.Collapse

Step 1. Set up your default identity

  1. From the command line, enter ssh-keygen.For Windows 7 or earlierYou can only enter ssh-keygen into the Git Bash window. It won’t work in the Command prompt.The command prompts you for a file to save the key in:$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa):
  2. Press enter to accept the default key and path, /c/Users/<username>/.ssh/id_rsa.We recommend you keep the default key name unless you have a reason to change it.To create a key with a name or path other than the default, specify the full path to the key. For example, to create a key called my-new-ssh-key, you would enter the Windows path, shown here:$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa): c:\Users\emmap1\.ssh\my-new-ssh-key
  3. Enter and re-enter a passphrase when prompted.The command creates your default identity with its public and private keys. The whole interaction looks similar to this:$ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa):
    Created directory '/c/Users/emmap1/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/emmap1/.ssh/id_rsa.
    Your public key has been saved in /c/Users/emmap1/.ssh/id_rsa.pub.
    The key fingerprint is: e7:94:d1:a3:02:ee:38:6e:a4:5e:26:a3:a9:f4:95:d4 emmap1@EMMA-PC
  4. List the contents of .ssh to view the key files.You should see something like the following:$ dir .ssh
    id_rsa id_rsa.pub
    The command displays two files, one for the public key (for example id_rsa.pub) and one for the private key (for example, id_rsa).

Step 2. Add the key to the ssh-agent

If you don’t want to type your password each time you use the key, you’ll need to add it to the ssh-agent.

  1. To start the agent, run the following:$ eval $(ssh-agent)
    Agent pid 9700
  2. Enter ssh-add followed by the path to the private key file:$ ssh-add ~/.ssh/<private_key_file>

Step 3. Add the public key to your Bitbucket settings

  1. From Bitbucket, choose Bitbucket settings from your avatar in the lower left.
    The Account settings page opens.
  2. Click SSH keys.
    If you’ve already added keys, you’ll see them on this page.
  3. Open your .ssh/id_rsa.pub file (or whatever you named the public key file) and copy its contents.
    You may see an email address on the last line. It doesn’t matter whether or not you include the email address.
  4. From Bitbucket, click Add key.
  5. Enter a Label for your new key, for example, Default public key.
  6. Paste the copied public key into the SSH Key field.
  7. Click Save.
    Bitbucket sends you an email to confirm the addition of the key.Edit an SSH keyAfter you add a key, you can edit the key’s Label but not the key itself. To change the key’s contents, you need to delete and re-add the key.
  8. Return to the command line and verify your configuration and username by entering the following command:$ ssh -T git@bitbucket.orgThe command message tells you which of your Bitbucket accounts can log in with that key.conq: logged in as emmap1. You can use git or hg to connect to Bitbucket. Shell access is disabled.If you get an error message with Permission denied (publickey), check the Troubleshoot SSH issues page for help.
  9. Open SourceTree and go to Tools > Options. In General tab find “SSH Client Configuration”. Find the path to your private SSH key. For SSH Client choose “OpenSSH”

Now that you’ve got an SSH key set up, use the SSH URL the next time you clone a repository. If you already have a repository that you cloned over HTTPS, change the remote URL for your repository to its SSH URL.

Installing Gulp

Every new website uses gulp. Below is the code to start using it on a new project.

Install the npm init package:

npm init

Complete the npm init process populating all fields.

After, install gulp:

npm install gulp@3.9.0

And gulp dependencies:

npm install gulp-sass --save-dev; npm install gulp-concat --save-dev; npm install gulp-uglify --save-dev; npm install browser-sync --save-dev; npm install gulp-rename --save-dev;

If this is your first time using gulp in a new machine, we need to install the gulp-cli:

 npm install --g gulp-cli 

For more references, check the official documentation:

https://gulpjs.com/docs/en/getting-started/quick-start