These local web development servers are fast and free to set up.  I always set them up on another computer so they’re available on  my local home network without slowing my own computer down.  Be careful setting this up on the same computer you want to use to write code, unless you have a blazing fast computer.  Even if you have an 8 core loaded with RAM, I still wouldn’t install dev sites on the machine I also use to write code, edit video and produce 3D animations it just slows you down, and besides, if you can afford a nice machine, use your old computer as a dev or buy a $500 box to avoid clogging your desktop and slowing your computer down to the point it’d be almost as slow as developing websites on your remote host — the world’s worst, most inefficient and unsafe way to develop websites.

Here’s a quick run through of my latest checklist instructions and resources to install a new local dev server (web development server) to run WordPress, Symfony, and OpenERP.  This also includes installing Webmin.  Once you find a reliable dev server that you set up, keep everything updated and you should be great to clone a server to create fresh new dev servers for multiple projects fast and easily.

It’s always a good idea to go through the steps and set up a new Virtual Machine in “Virtual Box” just in case you have to install a new flavor of Linux.  As you can see, CentOS and Ubuntu are my favorites, but you should always try and set up a Linux OS closest to the version you are running on your live host and there always seems to be a new technical challenge, especially if your company uses advanced firewalls.

Installing Ubuntu

Good overview to install Ubuntu on VirtualBox:  https://www.youtube.com/watch?v=1Nov2yDIk-4

Settings > Network:  Bridge Adapter
Run, choose file — ubuntu-14… -server-i386

System for 64 bit go to Acceleration

Setting up static:  https://www.youtube.com/watch?v=GaM9nLvyYDA

Login
sudo nano /etc/network/interface

Change in this file:  inet dhcp to “inet static”

address 192.168.0.13  <- your desired internal dev IP  ->

(Note the pattern with the masks where zeroes are below)
netmask: 255.255.255.0
network:  192.168.0.0
broadcast 192.168.0.255
gateway  192.168.0.1  <- router ->

dns-nameservers  192.168.0.1
sudo reboot

log back in

ifconfig
ping www.google.com

Install webmin on your virtual machine:

sudo nano /etc/apt/sources.list

at top of file:

#webmin
deb http://download.webmin.com/download/repository  sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Ctrl-X

wget http://www.webmin.com/jcameron-key.asc
sudo apt-key a add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin

then go to your internal dev IP you set above:  192.168.0.13:10000

=========

Installing Virtualmin

On FRESH INSTALL CentOS:  https://www.youtube.com/watch?v=ERM-Ty0jjjQ

Log in:
sudo yum -y update
sudo yum -y install perl
sudo yum install wget

wget http://softwaer.virtualmin.com/gpl/scripts/install.sh

sudo sh install.sh

http://IP_Address:10000

Setting up multiple IP for VMs:

Network Adapter Settings — can have 4 adapters

Set 1 to
NAT – VirtualBox runs own DHCP
Port Forwarding is available, but leave

Set 2 to
Bridged

Promiscuous Mode – will decode packets not meant for machine — select “Allow All”
Leave MAC address set.

Notes:

Internal Network — available to other VMs inside
Host only:   127.0.0.1
Generic Driver:  Any OS can recognize


By bootstrapping a Symfony project I am referring to creating a ready-to-go basic software package from which to build any projects from.  This also does include Twitter’s awesome Bootstrap libraries as well.

New project requires a well-designed database first

The first thing I usually do with a new Symfony project is design the database.  I use Oracle’s free tool called MySQL Workbench.  Here is a screenshot of a basic database design.  Once I go through the database and document how it will work, I then migrate the table model to the database where it creates the actual tables.

While it may take days to design the database first, this is by far the most critical step because your Symfony project, like most websites, depends on the database to perform properly.

Copying an existing Symfony project or phase of project or start from scratch?

So while this is going on I then would set up a new instance of Symfony on the website.  For first-timers, you need to do it a few times and get used to being able to have the framework’s tools write a bunch of code already for you!  Simply follow the instructions in the Cookbook on Sensio Lab’s Symfony website — a newest feature now is the Symfony installer which you will now need to install first before executing the few other command line prompts.

It’s fast and easy and all the Symfony files will be loaded on your website in the standard folder structure ready to go.  You can move folders around later and if you already did this on a local dev, you can just copy the entire folder to another site.  As an alternative, before you dev’d that project, you could use the .git repository and use the first commit as your bootstrap as well and simply check out those files from the repository.

There are many ways to deploy Symfony and since Symfony’s meant to be modular, Sensio claims it’s flexible and easy to deploy and I find it is most the time.

Essentially any already deployed Symfony project can serve as your next bootstrapped project.  Just don’t copy over anything dealing with “cache” folders or “cache” in the file names.

During initial Symfony set ups, depending on your host and server machine on occasion I would run into some file permission issues or directives in the php.ini or .htaccess files that are prohibited with certain hosts, but this is the exception and not the rule.

Composer – get to know your new friend

You’re not going to get very far if you don’t learn Composer.  It’s pretty easy how it works but it helps you keep all your software dependencies in line so things don’t break later.  Composer is your friend so take 10 minutes and learn up on what it is and does!

In case you were wondering, you can install it on your server through the command line, it’s usually better if you are logged in as the root user:

$ curl -sS https://getcomposer.org/installer | php

Bootstrapping your Bootstrap Symfony Project

Besides the FOSUserBundle, which now looks like it comes with the newest Symfony package, I usually install Braincrafted’s Bootstrap Bundle automatically since I use it for so many projects.  You can always not use a bundle from a vendor, but it’s usually a foregone conclusion I will be needing it.  So follow the instructions how to install the Bootstrap Bundle or simply go to your Symfony folder and add these three requirements to your composer.json file:

"require": { ...
  "braincrafted/bootstrap-bundle": "dev-master",
  "twbs/bootstrap" : "dev-master"
  "jquery/jquery":  "1.11.*"
}

By the way, jQuery’s pretty common and works well with Bootstrap themes, so you need to throw this into the composer.json file after your “requires” list:

 "repositories": [
        {
            "type": "package",
            "package": {
                "name": "jquery/jquery",
                "version": "1.11.1",
                "dist": {
                    "url": "http://code.jquery.com/jquery-1.11.1.js",
                    "type": "file"
                }
            }
        }
    ],

Then on the command line update all your Composer dependencies by typing in:

php composer.phar update

It also just updated my Symfony from 2.6.3 to 2.6.9, so I’m curious if I’ll run into any issues.  You’ll know if you do usually right away you will see 500 errors blowing up or blank pages (yikes) and what you need to do is Google frantically or roll back version in your composer.json file until the errors go away.  Lesson here?

Never ever ever run Composer updates on a live site, always do it on a staging server and test it, then test it again, then ask end users to test your staging again before going live!

Everytime you update your Composer dependencies, you must CLEAR YOUR SYMFONY CACHE!

Do save yourself the frustration and navigate to your Symfony install on your site, usually inside “public_html” and automatically type in  “app/console  ca:cl”  then “app/console ca:cl –env” in that order on your server.  This will clear the cache, sometimes it doesn’t make sense, but do it.  This is just the abbreviated commands for “cache:clear”.

Commit your Barebones Symfony so you have a snapshot

Now, since you’re using a local computer as a dev server and hopefully not the one you’re coding on because running VM on the same machine is asking for performance frustration later — you can just grab the entire site, pull it down, it’ll take 3 minutes.  I use PHP Storm for my IDE and already have it connected to my BitBucket account so after grabbing it all, I commit it and push the code to BitBucket and mark it with “INITIAL COMMIT” and I usually leave a note like “Bootstrap template” so I know it’s a quick way I can have Symfony-ready site to dev later.

Need help?  Feel free to contact me!

 

– Aaron Belchamber

www.AaronBelchamber.com