Skip to content

Instantly share code, notes, and snippets.

@nncl
Last active August 14, 2017 22:04
Show Gist options
  • Save nncl/f85a6f877961562ff29e to your computer and use it in GitHub Desktop.
Save nncl/f85a6f877961562ff29e to your computer and use it in GitHub Desktop.
How to create virtual machines, import/export databases, make a deploy on server and much more.

Din Stuff

This file is based on doubts that I had/have when I got in at Din Digital and when I forget some stuff.

Note: some paths depend of your own enviroment.

What you'll find here

This:

  1. Creating a new project
  2. Importing Data Base
  3. Exporting
  4. Uploading the Virtual Box
  5. Deploy on server
  6. Bower Stuff
  7. Generating assets
  8. How GULP and GRUNT works
  9. Bonus

Creating a new project

  1. Create/clone a directory project on your directory enviroment
  2. Duplicate the config file
  3. Change the hosts (sudo vi /etc/hosts) - add ip address + address > and then run :wq to quit
  4. vagrant reload to reload virtual box at /mvs/dev/, for example

Importing Data Base

  1. Create a new schema on mysql workbench
  2. Go to inside of your virtual box. Ex: cd > cd mvs/dev > vagrant ssh
  3. Then go to your directory project. Ex: cd /var/www/direcotry-name // inside of the virtual box
  4. Importing: mysql -u root -pmysql schema-name < file-name.sql

Note: Connect on virtual box, and not just get in the directory. To connect: cd > cd mvs/dev/ and run vagrant ssh.

Then you'll can see what is inside of it. Ex: inside of the dev directory (/var/www).

.MWB File

With this type of file, just give double click on it, wait the MySQL open and press:

  1. On a Mac: command + ctrl + Y
  2. On a Windows: ctrl + windows + Y

Exporting

To export (generate DUMP): mysqldump -u username -p[password] db_name > file.sql.

If you get errors, try run:

  1. Log out from VM
  2. Log in as super user: su
  3. Type and enter vagrant
  4. Done

Exporting in the real world

Get in into vagrant ssh > su

mysqldump -u username -p -h {{IP.ADDRESS}} database > database_file.sql

Here the password will be asked later.

  1. Or just run again

Uploading the Virtual Box

  1. Go to your directory. Ex: cd > cd mvs/dev/
  2. Run sudo vagrant up

Deploy on server

  1. Get in the server. Just run ssh root@ip. Example: ssh dev@dev.dindigital.com
  2. Get in the directory: cd /var/www/directory-name/
  3. Clone/update repo: git pull origin branch-name

Bower stuff

How to insert on bower file a project that does not contains itself as bower from git?

  1. Go to the directory where bower is installed
  2. Put the oficial name from git
  3. Version - ambiente de dev: "latest" - Example: https://github.com/stevenwanderski/bxslider-4/blob/master/bower.json
  4. Run bower install

Generating assets

Go to the root of your project and run php compressor.php.

How GULP and GRUNT works

Let's call GULP and GRUNT if GG. The GG are automation tasks, where they helps the programmer on simple tasks that get some time from programmer to being complete.

Who is better? And why?

Bonus

To find your ssh key, just run vi ~/.ssh/id_rsa.pub or cat ~/.ssh/id_rsa.pub.

To connect din's development server go to Google Drive, download both id_rsa files, give permissions and run:

ssh dev@162.243.52.61 -i /Users/dindigital02/Downloads/key@dindigital.com/id_rsa

More information here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment