To start with, I work predominantly on backend web development at the moment - I touch various database technologies and as such I usually have to change my database engine and configurations on a job-by-job basis. I swap jobs multiple times in a work period and pickup new ones qute frequently, this started to present a problem when it came to managing the seperate development environments. Below is a series of configuration changes I made to my machine to allow what I think is a more efficient workflow for backend development sans databsase engine.

Dividing your projects by directory

Apache supports virtual hosts which effectively create seperate apache 'instances' - with configuration directives you can enact these instances on each working directory inside a parent folder

sudo vim /etc/apache2/sites-available/dev.conf

*Note: Modified to allow overrides by way of .htaccess files (can't believe I forgot) adding

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "/home/{user}/www"
  ErrorLog /home/{user}/www/apache.error.log
  CustomLog /home/{user}/www/apache.access.log common
  php_flag log_errors on
  php_flag display_errors on
  php_value error_reporting 30719
#<RequireAll>
# Require all granted
#</RequireAll>
</VirtualHost>

<VirtualHost *:80>
  ServerAlias *.dev
  VirtualDocumentRoot "/home/{user}/www/%1"
  ErrorLog /home/{user}/www/apache.error.log
  CustomLog /home/{user}/www/apache.access.log common
  php_flag log_errors on
  php_flag display_errors on
  php_value error_reporting 30719

#<RequireAll>
#  Require all granted
#</RequireAll>
</VirtualHost>

<Directory "/home/{user}/www/*/">
  Options +Indexes
  IndexOptions +FancyIndexing +HTMLTable +IconsAreLinks +FoldersFirst +IconWidth=16 +IconHeight=16 +NameWidth=*
  AllowOverride All
  <RequireAll>
     Require all granted
  </RequireAll>
</Directory>
Now permission the directory & modify your hosts, finally enabling the modules & config::

chmod 755 -R on working directory a2enmod rewrite autoindex vhost_alias a2ensite dev.conf

sudo vim /etc/hosts name.dev 127.0.0.1 #maps to ~/www/name project.dev 170.0.0.1 #maps to ~/www/project

Setting up your PHP

cURL is a must

sudo apt-get install curl

Installing Composer

sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

*Assuming you have GCC installed Install Twig, a templating engine

git clone https://github.com/fabpot/Twig.git
cd Twig/ext/twig/
sudo phpize
sudo ./configure
sudo make
sudo make install

Add the following to your php.ini

extension=twig.so

Comments

comments powered by Disqus