Installing Laravel 5.2 & PHP 7 on Ubuntu 16.04 for Apache 2.4.10

Laravel 5.2  is a very popular open source PHP framework aimed at easy development of applications. If you are looking for a new PHP framework to try, you should give Laravel a try. The following guide will allow you to run Laravel on a Ubuntu 15.10 based Apache server.

Pre-Requisities:

Before proceeding with the installation, its always a good idea to make sure your sources and existing softwares are all updated.

sudo apt-get update
sudo apt-get upgrade

Installing PHP7:

We can install PHP 7 and the Apache PHP module as follows:

sudo apt install php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-mbstring

Then restart Apache:

systemctl restart apache2

Installing Composer:

Composer, the now de facto dependency manager, is a must-use in the PHP ecosystem. It will manage the dependencies – pull in required libraries, dependencies and manage them all for you. Composer also has a main repository: Packagist. Combined, Composer and Packagist make the experience similar to npm or Ruby’s Bundler.

In order to use Composer, install zip/unzip:
sudo apt install zip 

Also, we will need Git installed on our system:

apt install git

Okay, now – let’s go ahead and actually install Composer:
cd ~
curl -sS https://getcomposer.org/installer | php

This will create a file called composer.phar in your home directory. This is a PHP archive, and it can be run from the command line.

We want to install it in a globally accessible location though. Also, we want to change the name to composer (without the file extension). We can do this in a couple steps.

Let’s make it an executable that we can run as composer:

sudo mv composer.phar /usr/local/bin/composer

Alright, alright, alright! We should be able to see a list of Composer commands:

composer

Saw the list? Great. Let’s move on to Laravel.

 

Install Laravel & Quickstart Tutorial:

To install Laravel, we need to install Composer first. It is a tool for dependency management in PHP that allows you to package all the required libraries associated with a package as one. To install Laravel and all its dependencies, Composer is required. It will download and install everything that is required to run Laravel framework. To install Composer, issue the following commands.

MySQL

First, let’s set up our database. It will only take a second. We’re going to use MySQL – remember that password you saw after you logged in?

Login to MySQL on the command line – using your saved password:
mysql -uroot -p

You will be prompted for your password. Once in – enter in the following commands:

Once logged in to MySQL – enter in the following commands:
mysql> CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'laravel';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'laravel'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE DATABASE laravel;
Query OK, 1 row affected (0.00 sec)

You can name your user, password, and database anything you want – we are using laravel for the sake of being easy.

Laravel & Stream Example Project

To make it as easy as possible to get started, let’s just clone the completed Stream-Laravel example app.

Please note that you do not need to copy and paste any code, or create any files. Rather, this is intended to help you learn while you follow along with the process.

Follow the steps below to add Laravel, along with the Stream-Laravel example application:

First, move to /var/www/:


cd /var/www/

You may want to use sudo with the following commands to avoid any permissions errors. Check out this DigitalOcean how-to and search for “permissions”.

Next, clone the Stream-Laravel-Example project as “quickstart”:


git clone https://github.com/GetStream/Stream-Laravel-Example quickstart
cd quickstart
composer install

Okay, cool. If all went well – you just installed a bunch of dependencies inside of vendor.

Note: The Stream-Laravel example application is based off of the Laravel quickstart-intermediate project. Please take a look at the additional references below for more information.

Additional References:
GitHub Repository
Laravel Quickstart Documentation

Set Database Credentials

One thing we need to do is set our new application’s database credentials – which happens in a .env file.

Copy .env.example, which is located in the root directory, to .env:


cp .env.example .env

Next, let’s add our database credentials. For the sake of an easy example we use “laravel”:


DB_HOST=127.0.0.1
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

Now let’s run php artisan migrate.

If all goes well, you should see something like:


Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrated: 2016_02_04_041533_create_tasks_table
Migrated: 2016_07_12_182728_create_follows_table

Let’s also generate and set an encryption key:

php artisan key:generate

Create an Apache Virtual Host for your project.

cd /etc/apache2/sites-available
sudo nano myapp.conf

Have the contents of the file match what’s below.

<VirtualHost *:80>
  ServerName myapp.localhost.com
  DocumentRoot "/home/vagrant/projects/myapp/public"
  <Directory "/home/vagrant/projects/myapp/public">
    AllowOverride all
  </Directory>
</VirtualHost>

Save the file, then continue below.

cd ../sites-enabled
sudo a2ensite myapp.conf
sudo service apache2 reload

Fixing Permissions

If you’re running a virtual machine under Vagrant, you may want to change the user and group to avoid permission issues.

To do this:

cd /etc/apache2
sudo nano envvars

Change the lines below to contain the desired user and group

export APACHE_RUN_USER=vagrant
export APACHE_RUN_GROUP=vagrant

Save the file and restart apache.

sudo service apache2 restart

MySQL ERROR 1819 (HY000): Your password does not satisfy the current policy requirements !!

First you login with mysql -u root -p and check the current policy rules by:

# SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password_dictionary_file    |        |
| validate_password_length             | 5      |
| validate_password_mixed_case_count   | 1      |
| validate_password_number_count       | 1      |
| validate_password_policy             | MEDIUM |
| validate_password_special_char_count | 1      |
+--------------------------------------+--------+

Then you can change any of the above variables at your will:

# SET GLOBAL validate_password_length = 5;
# SET GLOBAL validate_password_number_count = 0;
# SET GLOBAL validate_password_mixed_case_count = 0;
# SET GLOBAL validate_password_special_char_count = 0;

Finally you can create a database and a user accessing it with a simpler password:

# CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'laravel';
# GRANT ALL PRIVILEGES ON *.* TO 'laravel'@'localhost' WITH GRANT OPTION;
# CREATE DATABASE laravel;
# FLUSH PRIVILEGES;

After that you can login with mysql -u user1 -p laravel using password laravel

How to Protect Linux Against the Shellshock Bash Vulnerability

The Shellshock vulnerability can be exploited on systems that are running Services or applications that allow unauthorized remote users to assign Bash environment variables.

Examples of exploitable systems include the following:

Apache HTTP Servers that use CGI scripts (via mod_cgi and mod_cgid) that are written in Bash or launch to Bash subshells
Certain DHCP clients
OpenSSH servers that use the ForceCommand capability
Various network-exposed services that use Bash

On each of your systems that run Bash, you may check for Shellshock vulnerability by running the following command at the bash prompt:

env VAR='() { :;}; echo Bash Linux has Bugs ' bash -c "echo Bash Linux is save"

The highlighted echo Bash is vulnerable! portion of the command represents where a remote attacker could inject malicious code; arbitrary code following a function definition within an environment variable assignment. Therefore, if you see the following output, your version of Bash is vulnerable and should be updated:

Bash Linux has Bugs
Bash Linux is save

Otherwise, if your output does not include the simulated attacker’s payload, i.e. “Bash Linux has Bugs ” is not printed as output, your version of bash is not vulnerable. It may look something like this:

bash: warning: VAR: ignoring function definition attempt
bash: error importing function definition for `VAR’
Bash Linux is save

If your version of Bash is vulnerable, read on to learn how to update Bash and fix the vulnerability.
Test Remote Sites

Debian / Ubuntu – Open a terminal and type in:

sudo apt-get update && sudo apt-get install --only-upgrade bash

CentOS / Red Hat / Fedora – Open a terminal and type in:

su
yum update bash

Now check your system vulnerability again by running this command :

env VAR='() { :;}; echo Bash Linux has Bugs ' bash -c "echo Bash Linux is save"

Be sure to update all of your affected servers to the latest version of Bash!

How to combine Sencha Touch and PhoneGap to create a native app for android

Prerequisites:

  • Phonegap (Version 2.9 or later)
  • Sencha Command Line Tool (Version 5.0.0 or later)

Firstly I’ve downloaded the Phonegap package (from the phonegap archive) and extracted it to my folder /opt/phonegap-2.9

Afterwards I’ve downloaded the Sencha Touch Framework from Sencha and placed it on my Linux Ubuntu 14.04 into the folder /opt/senchatouch2

Combination of Sencha Touch and Phonegap

Create a Sencha Touch application

To make use of this combination, we need to create a touch application.

Open a terminal and type in:

cd /opt/senchatouch2/
sencha generate app AppName /var/www/AppName
cd /var/www/AppName
sencha app build package

Now if you open your favorite web browser (webkit-browser work best for sencha touch), you should be able to see your created application:

http://localhost/AppName

If this works and you can see your application, you can try to have a look for the package build we’ve just done in addition:

http://localhost/AppName/build/package/AppName.

This version is a minified version of all the individual sencha touch files, merged into one single file.

If you are able to open the build package in your web browser, we are ready now to take one further step and go on with the Phonegap project creation.

Create the Phonegap project

cd /opt/phonegap-2.9/lib/android/bin/
./create /var/www/AppName/build/package/AppName/android com.yourdomainnamespace.AppName AppName
cd /var/www/AppName/build/package/AppName/android/
ant debug && adb install -r ./bin/AppName-debug.apk

The first line changes from the current directory to the phonegap folder. There we use the create script to create a phonegap project for us. Afterwards we change to the build directory and create a apk file which will be installed directly in your running android emulator. If you don’t want to test it in an emulator, just copy the apk file onto your android device.

Warning: Test the apk on your device on your own risk! This may be harmful for your device and therefore testing on an emulator is recommended!

At this moment, what you will see, will just be like the Apache Cordova splash screen which shows the device is ready animation. If this is also works on your side, you’ve done a good job so far.

Open now the file /var/www/AppName/app.json and add the lines marked in bold to the js section of this file:

"js": [
     {
         "path": "cordova.js"
      },
      {
         "path": "touch/sencha-touch.js",
         "x-bootstrap": true
      },
      {
         "path": "bootstrap.js",
         "x-bootstrap": true
      },
      {
         "path": "app.js",
         "bundle": true,
         "update": "delta"
      }
   ]

And kick off a build:

cd /var/www/AppName/
sencha app build package

When you refresh now your application in the browser and open the developer tools (most probably F12) you should see that the app loads the cordova.js file properly.

Well, at this point, we need to change a few code lines in the build.xml file. We need to copy our desired application files into the cordova web root which is located in /android/assets/www/.

Copy following code lines below the section:

<import file="${basedir}/.sencha/app/build-impl.xml"/>
<target name="-after-build">

		<delete dir="${build.dir}/android/assets/www" />

		<copy todir="${build.dir}/android/assets/www">
		    <fileset dir="${build.dir}" />
		</copy>

		<delete dir="${build.dir}/android/assets/www/android" />
    	</target>

Afterwards kick off a build again:

cd /var/www/AppName
sencha app build package
cd /var/www/AppName/build/package/AppName/android/
ant debug && adb install -r ./bin/AppName-debug.apk

In your android emulator now should your Sencha Touch application as a native app combined with phonegap features.

To make use of them either visit phonegap.com and have a look to the api, or just give it a try with following commands which you add to /var/www/AppName/app/view/Main.js to the items section:

items: [
            {
                title: 'Welcome',
                iconCls: 'home',

                styleHtmlContent: true,
                scrollable: true,

                tpl: [
                    'device name: {name}<br />',
                    'phonegap version: {cordova}'
                ].join(''),
                listeners: {
                    initialize: function() {
                        this.setData(device);
                        navigator.notification.vibrate(250);
                        navigator.notification.alert('Testing the Notification feature of cordova (Phonegap)');
                        
                    }
                }
            }
        ]

Let’s kick off our last build for this how to:

cd /var/www/AppName
sencha app build package
cd /var/www/AppName/build/package/AppName/android/
ant debug && adb install -r ./bin/AppName-debug.apk

And now switch to your emulator and see the final result.

How to online Booking or Shopping safely

Online Shopping or Booking isn’t just as safe as handing over your credit card in a Department Store , Restaurant.

However, if you take care of few things it can be a safe deal.

Following are the things you should take care of:

  • Never respond to an email request for credit card details. All reputable companies will conduct transactions with you over a secure website connection.
  • Remember to never respond to any email advertisement, and only visit sites you know or have book marked, and verify the address before browsing further.
  • Only buy from trusted brands and websites.
  • To ensure that you only do business with legitimate companies check to see if they have a contact number, an actual retail store and a printed catalogue to browse.
  • Check a website’s returns and privacy policy before going ahead with a purchase.
  • Check that you are entering your details through a secure payment connection. You should notice when you click through to the transaction page of a company’s website that the URL in the address bar begins https:// (instead of the normal http://). This is the standard encrypted communication mechanism on the internet and means that your credit card details are being sent securely.
  • Beware of deals that seem too good to be true.
  • Beware of the limitations of the internet. The internet may not the best place to buy clothes or other products you need to see, touch or try on.
  • All reputable websites use secure payment systems. These are either a company’s own system or a 3rd party system such as Worldpay or Paypal.
  • When conducting a transaction over the internet, look for the yellow padlock in the grey status bar at the bottom of your browser page. This is an indication that the transaction is being conducted over a secure connection.
  • As an extra precaution check to see if there’s a gold lock at the bottom of the right hand corner of the browser. If they don’t include any of these reliable indicators, you might want to think twice before handing over your credit card number.
  • To be on the safe side, and avoid Internet fraudsters, it’s also a good idea to install and use security software such as Kaspersky Internet Security. It can provide you with industry-leading security services that will provide you more protection against the latest threats.

 

How to fix unstable wifi connection after 14.04 upgrade

After upgrade the computer from 13.10 to Ubuntu 14.04, the connection has been really unstable. The connection frequently drops, fails to connect, or is very slow.

You should deactivate the N-mode of the driver.

Open a Terminal “CTRL+ALT+T” and type this command line:

# sudo apt-update 
# echo "options iwlwifi 11n_disable=1" | sudo tee /etc/modprobe.d/iwlwifi.conf 
# sudo modprobe -rfv iwlwifi
# sudo modprobe -v iwlwifi

 

Note:

Additionally you can deactivate the power management of the card:

 # sudo iwconfig wlan0 power off

How to create OOP Smartphone or Tablet with Sencha Touch Framework

 

sencha-large

Sencha Touch is an OOP JavaScript framework that makes it easy to build mobile web applications that look and feel native on iPhone, Android, and BlackBerry touch devices. To find more you can take a look at Sencha Touch website.

 

Required Software

  1. Download and unzip Sencha Touch. You can unzip the software to any directory.
  2. Sencha Touch requires Chrome or Safari. On a mobile device, you can use Chrome, Safari, or Internet Explorer 10 or 11.
  3. Download and install Sencha Cmd. Sencha Touch 2.3.1 and later requires Sencha Cmd 4.0.1, 4.0.2, and later. To check that you have correctly installed Sencha Cmd, type the sencha command, for example:
    # sencha
    Sencha Cmd vn.n.n
    ...
    
  4. Java Runtime Environment version 1.7. Sencha Cmd is written in Java and needs the JRE to run. Note: If you are building an Android app using Windows, you must install the Java SDK. You can build an iOS app under Windows with the JRE, but not an Android app.
  5. Ruby to create the compiled CSS used by Touch.
    • Windows: Download Ruby from rubyinstaller.org. Download the RubyInstaller .exe file and run it.
    • Mac: Ruby is pre-installed. You can verify its presence with the ruby -v command.
    • Ubuntu: Use sudo apt-get install ruby2.0.0 to download and install Ruby.

Create a Starting Environment

Choose or create a directory where your application will reside, change to that directory, and issue the following command:

$ sencha -sdk /path/to/touch generate app MyApp . 

Where:

  1. /path/to/touch is the directory where you unzipped the Touch software.
  2. MyApp is the name you give your application.

This generates a starting Sencha Touch application namespaced to the MyApp variable and located in the current directory.

The starting app contains all the files you need to create a Sencha Touch application, including the default index.html file, a copy of the Touch SDK, the CSS file, and images and configuration files for creating native packages for your app.

You can verify if your application has generated successfully by opening it in a web browser. If you extracted the SDK to your webroot folder, navigate to http://localhost/MyApp. If you are using the Sencha Cmd web server, you can access served applications with the http://localhost:1841/ URL.

What We Are Creating

We are creating a simple mobile web app to use for a company’s mobile site. The app includes a home page, a contact form, and a simple list that fetches Sencha’s recent blog posts and allows visitors to read them on a mobile device.

senchatouch2

 

 

How to Securing your Linux Server

Securing your environment starts during the ordering process when you are deploying server resources. If you want to deploy a quick server without putting it behind an extra hardware firewall layer or deploying it with an APF (Advanced Policy Firewall).

There are a couple of security hardening tips. I  set my servers to have a solid base level of security when I deploy a Linux system.

 

Limit physical access and booting capabilities

  • Enable BIOS password
  • Disable floppy and usb booting
  • Set a LILO or GRUB password (/etc/lilo.conf or /boot/grub/menu.lst, respectively)
  • check that the LILO or GRUB configuration file is read-protected.

 

Disable Root Login

When you need super-user permissions, use sudo instead of su. Sudo is more secure than using su: When a user uses sudo to execute root-level commands, all commands are tracked by default in /var/log/secure. Furthermore, users will have to authenticate themselves to run sudo commands for a short period of time.

Note:
You should Stop Using Root!

 

Partitioning

  • Separate user-writable data, non-system data, and rapidly changing run-time data to their own partitions
  • Set nosuid,noexec,nodev mount options in /etc/fstab on ext2 partitions such as /tmp

 

Limiting the network access

  • Install and configure ssh (suggest PermitRootLogin No in /etc/ssh, PermitEmptyPasswords No; note other suggestions in text also)
  • Consider disabling or removing in.telnetd
  • Generally, disable gratuitous services in /etc/inetd.conf using update-inetd –disable (or disable inetd altogether, or use a replacement such as xinetd or rlinetd)
  • Disable other gratuitous network services; mail, ftp, DNS, www etc should not be running
  • if you do not need them and monitor them regularly.
  • For those services which you do need, do not just use the most common programs, look for more secure versions shipped with Debian (or from other sources). Whatever you end up running,make sure you understand the risks.
  • Set up chroot jails for outside users and daemons.
  • Configure firewall and tcpwrappers (i.e. hosts_access); note trick for /etc/hosts.deny in text
  • If you run ftp, set up your ftpd server to always run chrooted to the user’s home director
  • If you run X, disable xhost authentication and go with ssh instead; better yet, disable remote X if you can (add -nolisten tcp to the X command line and turn off XDMCP in /etc/X11/xdm/xdm-config by setting the requestPort to 0)
  • Disable outside access to printers
  • Tunnel any IMAP or POP sessions through SSL or ssh; install stunnel if you want to provide this service to remote mail users Set up a loghost and configure other machines to send logs to this host (/etc/syslog.conf)
  • Secure BIND, Sendmail, and other complex daemons (run in a chroot jail; run as non-root pseudo-user)
  • Install snort or a similar logging tool.
  • Do without NIS and RPC if you can (disable portmap).

 

Password hygiene and login security

  • Do not choose passwords less than 8 characters “Create complexity with upper and lower-case of letters ,Special character and numbers e.g Qu4DL1nux*I0″
  • Enable password shadowing and MD5
  • Install and use PAM – Add MD5 support to PAM and make sure that (generally speaking) entries in /etc/pam.d/ files which grant access to the machine have the second field in the pam.d file set to “requisite” or “required”.
  • Tweak /etc/pam.d/login so as to only permit local root logins.
  • Also mark authorized tty:s in /etc/security/access.conf and generally set up this file to limit root logins as much as possible.
  • Add pam_limits.so if you want to set per-user limits
  • Tweak /etc/pam.d/passwd: set minimum length of passwords higher (6 characters maybe) and enable md5
  • Add group wheel to /etc/group if desired; add pam_wheel.so group=wheel entry to /etc/pam.d/su
    For custom per-user controls, use pam_listfile.so entries where appropriate
  • Have an /etc/pam.d/other file and set it up with tight security
  • Set up limits in /etc/security/limits.conf (note that /etc/limits is not used if you are using PAM)
  • Tighten up /etc/login.defs; also, if you enabled MD5 and/or PAM, make sure you make the corresponding

Note:
Disable root ftp access in /etc/ftpusers
Disable network root login; use su or sudo.

Policy issues

  • Educate users about the whys and hows of your policies. When you have prohibited something which is regularly available on other systems, provide documentation which explains how to accomplish similar results using other, more secure means.
  • Prohibit use of protocols which use cleartext passwords (telnet, rsh and friends; ftp, imap, http)
  • Prohibit programs which use SVGAlib.
  • Use disk quotas.

Update Kernel and Software

Ensure your kernel and software patches are up to date. I like to make sure my Linux kernel and software are always up to date because patches are constantly being released with corrected security flaws and exploits. Remember you have access to SoftLayer’s private network for updates and patches, so you don’t have to expose your server to the public network to get updates. Run this with sudo to get updates in RedHat or CentOS: yum update.

How to Install MySQL on Linux

MySQL is a relational database management system (RDBMS), and ships with no GUI tools to administer MySQL databases or manage data contained within the databases.

Users may use the included command line tools  or use MySQL “front-ends”, desktop software and web applications that create and manage MySQL databases, build database structures, back up data, inspect status, and work with data records.

The official set of MySQL front-end tools, MySQL Workbench is actively developed by Oracle, and is freely available for use.

Installation

Open a Terminal “CTRL+ALT+T” and type this command line:

on Debian / Ubuntu

# sudo -i 
# apt-get update
# apt-get install mysql-client-5.1 mysql-server-5.1

Note:
The apt-get command will install a number of packages, including the MySQL server, in order to provide the typical tools and application environment. This can mean that you install a large number of packages in addition to the main MySQL package.

During installation, the initial database will be created, and you will be prompted for the MySQL root password (and confirmation). A configuration file will have been created in /etc/mysql/my.cnf. An init script will have been created in /etc/init.d/mysql.

The server will already be started. You can now start  the MySQL server using this command line:

# service mysql [start|stop]

on Red Hat Linux, Fedora, CentOS

# su
# yum install mysql mysql-server mysql-libs mysql-server

Note:
MySQL and the MySQL server should now be installed. A sample configuration file is installed into /etc/my.cnf . An init script, to start and stop the server, will have been installed into /etc/init.d/mysqld.
To start the MySQL server use service:

# service mysqld start

To enable the server to be started and stopped automatically during boot, use chkconfig:

# chkconfig --levels 235 mysqld on 

Which enables the MySQL server to be started (and stopped) automatically at the specified the run levels.

 

How to install Zend Framework 2 (ZF2) & ZFTool (Command Line Tool) in Linux Ubuntu 14.04

Introduction:

The Zend Framework 2 is a MVC Framework developped by the PHP developpers called Zend.

I am using an Ubuntu 14.04 Desktop with an installed Apache2 web server, php5 (5.3+ required for ZF2).


Installation Process:

Download Zend Framework 2

First you will have to download the Zend Framework you desire to install (version >= 2.0.0 for this tutorial)

Visit Zend Archive and download your Zend package. 
Extract it to /usr/share/php/ZendFramework2

Download ZFTool

Afterwards you will need to install ZFTool. It is a command line tool which gives you the ability to create projects, models, viewtemplates and so on.

Download ZFTool from GitHub.
Extract it now to /usr/share/php/ZFTool

Now you need to grab a file called zftool.phar.

Download it directly from Zend packages.
And then extract it to the previously created folder
/usr/share/php/ZFTool/bin/.

For the extraction process you are free to choose between handling it over the terminal or the graphical way.

Notice: You will need permission rights to add content to the /usr/share/php/ folder!

You can use sftp://root@localhost to get access to this folder with root permissions, but use this way carefully!

Now you have installed the ZFTool but it is a pity to write the whole path to the executable file to use this tool.
However, as linux gives us the possibility, we can make use of aliases (for the standard user).

Create Alias

cd /etc/php5/conf.d/
sudo touch zend-framework2.ini
sudo gedit zend-framework2.ini

Now you should be able to edit this recently created file. Add the following content to it:

[Zend]
php.include_path = "/usr/share/php/ZendFramework2/library"

Save and close the file afterwards.

Let’s define the alias now:

sudo gedit ~/.bashrc

Add the following lines to your bashrc if they aren’t already defined or uncomment them
(keep in mind to edit from you standard user!):

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
   . ~/.bash_aliases
fi

Save and close again.
Now we have to create the file we are looking for in the previous bashrc:

sudo touch ~/.bash_aliases
sudo gedit ~/.bash_aliases

We add the following line(s) to the file:

alias zf2='export ZF_CONFIG_FILE=/etc/php5/conf.d/zend-framework2.ini; sudo /usr/share/php/ZFTool/bin/zftool.phar'

Finally save and close it.
Now use following command to reload your bashrc file to make the changes taking effect:

. ~/.bashrc

Now you can try to use ZFtool:

zf2 --version

You should get something like this:

ZFTool - Zend Framework 2 command line Tool
The ZFTool is using Zend Framework 2.2.4

Basic usage

For the basic commands of this tool please check the manual / help.

zf2 --help

Debugging

If you get an error, for instance, you wouldn’t have the required permissions,
you could try to give your user the permissions to access the zend directory.

sudo -i
cd /usr/share/php/
chown -R yourUser:yourUser ZFTool/
chmod a+x ZFTool/*
exit

Afterwards try again zf2 --version while logged into the command line with yourUser.