Author: Ricardo Correia

  • Creating a web and WordPress development environment

    Installing Ubuntu Server Virtual Machine, using VMware (Part 2)

    After installing Ubuntu Server, using VMWare as explained in my previous post, You’ll have a local development environment for your projects that’s fully functional, but only with  the basic features.

    You’ll want to use a series of tools in your development stack, that aren’t available from start in the installation and also, have the means to easily edit the files inside your server, preferably without the need to use FTP or other tools, after all, this is your local stack.

    In this post I’ll explain how I’ve configured the server to improve the development environment and run the following tools correctly,

    • Samba ( File sharing between the virtual machine and our local system)
    • Git
    • Ruby and Gem
    • SASS
    • Bourbon
    • node.js
    • Grunt
    • Wordmove

    1. Install and configure Samba on Ubuntu VM

    First step, the obvious, install Samba using root access

    sudo apt-get install samba

    Next you’ll need to open your Samba configuration file ( /etc/samba/smb.conf ) and add a few lines in order to configure a shared folder, start by opening your configuration file with your favorite editor and then you’ll need to add the following lines to your file:

    # The following property ensures that existing files do not have their permissions
    # reset to the "create mask" (defined below) if they are changed
     map archive = no
    
    # Notify upon file changes so that Windows can detect such changes
     change notify = yes
    
    [htdocs]
     comment = Htdocs Files
     path = /opt/lampp/htdocs/
     guest ok = no
     browseable = yes
     writable = yes
     create mask = 0664
     directory mask = 0775
    

    In the above, I’m assuming you want to share the htdocs folder from your lampp install.

    Next, you need to add a Samba user, with the same name and password as your Ubuntu user account

    
    sudo smbpasswd *username*
    
    

    To finish this step you need to restart the samba service,

    
    sudo service smbd restart
    
    

    2. Setting permissions on htdocs folder

    In order to be able to edit, add and delete files from the htdocs folder you’ll need to set all the permissions correctly on that folder, to do this you’ll need to change the folder permissions, doing the following:

    First you need to create a new group “www” which will have the permissions for this folder,

    sudo groupadd www
    

    Next, you’ll change the group on the directory,

    sudo chgrp -R www /opt/lampp/htdocs
    

    and then you need to set the correct permissions on that directory:

    sudo chmod 2775 /opt/lampp/htdocs
    

    To finalize, add your user to this group, running the following command:

    sudo usermod -aG www *username*
    

    Now you’ll need to logout or restart your server, in order to these changes take effect, as these rules are read at login time.

    3. Configure static IP in your VM and change your windows “hosts” file

    For me this is one of the most important steps on this configuration, I love being able to type something like local.dev in my browser, putty or ftp and be able to access my VM without any hassle.

    To do this you need to change two files in your VM.

    First, open the “interfaces” file ( etc/network/interfaces ) in your favorite editor, and change the following lines:

    auto eth0
    iface eth0 inet static
    address 192.168.0.100
    netmask 255.255.255.0
    network 192.168.0.0
    gateway 192.168.0.2
    broadcast 192.168.0.255
    

    You’ll need to get the correct values for each from your own network configuration, just have in mind that the ip address need to be unique and in the same network as your local machine.

    Next, open the “resolve” configuration file ( etc/resolv.conf ) and change the nameserver to match your gateway ip address.

    Then just restart the network, by running the following command:

    sudo etc/init.d/networking restart
    

    Back in windows you need to add a new entry to your host file, for that you need to open notepad or your favorite text editor, as administrator, then navigate to the host file, usually in: C:\Windows\System32\drivers\etc and add the following line to your file:

    192.168.1.100 local.dev
    

    The first part is your virtual machine ip address, the second your desired alias for it.

    4. Install all the packages you want

    Now it’s time to install all the packages you want in your VM, before selecting them and start installing, just run an update to make sure you’re getting the latest stable versions.

    sudo apt-get update
    

    Now it’s time for installing the packages, usually I install the following:

    • Git
    • Ruby
    • Gem
    • Sass
    • Bourbon
    • Wordmove
    • lftp
    • mysqldump
    • grunt
    • Node.js

    Please have in mind that these are the steps I use to create a local VM for development, these configurations shouldn’t be used on a VPS or a production environment.

    There are other alternative configurations for a local environment including the famous VVV, https://github.com/Varying-Vagrant-Vagrants/VVV . The last time I tried to install this on my windows laptop I couldn’t get it to work correctly due to some windows permissions, I’ll give it another try some time soon, but for now I’m sticking with my own VM.

  • Matosinhos WordPress Meetup

    3 reasons for using WooCommerce

    On Thursday, last week, I’ve attended the first of a monthly series of WordPress meetups in Porto, organized by the “Comunidade Portuguesa de WordPress” this series intends to bring more people to the community as it’s location will change inside the Porto district.

    It couldn’t have started in a better way, Pedro Fonseca, Matosinhos resident and this session organizer, brought to us his presentation about e-commerce, in a consulting oriented presentation, Pedro shown us a variety of plugins available for this purpose and some of their key features.

    Presentation available here (Portuguese Only)

    This day had also the presence of an accountant and a lawyer to clarify any question about legal and tax issues which propelled us into a clarifying and very interesting discussion about these topics in internet business today.

     

    From the plugins shown my favorite and go-to plugin for e-commerce is WooCommerce from WooThemes.

     

    There are many reasons to my choice, and having worked and built websites in each one of them I can say that at least for me WooCommerce is by far the best one, why?

    My 3 major reasons are:

    • Biggest community and free support,
    • Built using the same structure that WordPress itself uses (functions, naming, template system, etc.),
    • Available documentation and Github code repository.
  • Installing Ubuntu Server Virtual Machine, using VMware

    Basic setup for web development

    Following up my previous post, A Modern Web Development Workflow in Windows, I’ve created this small step-by-step configuration guide for a VM with ubuntu server using VM Ware.

    This is mostly for myself, as future reference, but you can also use this 10 steps to install and configure your own local environment.

    1. Download the latest Ubuntu server distribution compatible with your machine

    You can find here, all the latest releases : http://www.ubuntu.com/download/server

    2. Download the latest VMware Player

    VMware player is a FREE tool for personal use, and you can download it from:

    https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0

    3. Create a new Virtual Machine in VMware

    I used the following specs for my setup:

    • 2 Gb RAM
    • 2 Core processor
    • 5 Gb Disk Space

    4. Install Ubuntu Server

    As easy as clicking next in every screen

    5. Start your new Virtual Machine

    Selecting the correspondent item in the menu, and click “Play Virtual Machine”

    6. Change Keyboard layout

    After installing and as a Portuguese, I need to change my keyboard layout.
    (Skip this step if you don’t need a special keyboard layout).
    You can achieve it running the following command, and then selecting the desired keyboard layout

    sudo dpkg-reconfigure keyboard-configuration

    7. Next, we’ll install Open-SSH

    As simple as running the command:

    sudo apt-get install openssh-server

    8.Install PuTTY

    As I hate to lose mouse focus when I need to access my virtual machine, the next step is installing PuTTY on my PC.
    You can download it from here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

    9. Login via Putty

    In order to login using PuTTY on your virtual machine you need to know your IP address, this is a very simple command and very similar to the one we use in windows

    ifconfig

    10. Installing LAMP

    The final step of the initial configuration is installing LAMP, on your Ubuntu Server.
    You can download and follow the installation instructions from:
    http://www.apachefriends.org/en/xampp-linux.html#374

    These are the basic configuration steps for installing LAMP on a virtual machine, in order to use it efficiently in web and WordPress development I’ve found a couple of other tweaks that makes it faster, easier and even more awesome. I’ll share those in a next post.

  • A Modern Web Development Workflow in Windows

    I’ve been on a mission in the last weeks, modernizing my workflow in WordPress development in order to automate as many tasks as possible and start using SASS, Grunt, Git and Capristano.

     

    First, you need to know that I’m a windows user, I like everything about Linux philosophy, but I really hate Photoshop running on Wine and I love playing some games whenever I’ve the time for it. 

     

    I’ve started installing git on windows (Awesome),

    continued to install Ruby and SASS, one more Console…

    Testing wordmove (https://github.com/welaika/wordmove), more modules to install, one more console Cygwin…

     

    Come on! If I continue this way I’ll work with 3 different consoles and multiple configurations and installs of each module I needed for each new “hot” thing available.

     

    So I needed to find a way of reduce this huge setup and mess.

    I’ve poked around a little and decided to install a Virtual Machine running Ubuntu server, with everthing I needed.

    – Git
    – Ruby
    – Sass
    – Node.js
    – Grunt
    – Lampp

    This way I would be able to install everything I needed today and have an expansible environment capable of fulfilling my future needs.

    What do you think of my choice?

    Do you have any alternative suggestions or use a similar setup?