Installing Apigility on Debian 7.5

Apigility is an API Builder designed to easily create and maintain useful, easy to consume and well structured APIs in PHP. To run Apigility, we need PHP 5.3.23+, with the recommendation being PHP 5.4.8+ to enable the serving of the admin user interface.

Downloading Apigility

To download the latest release of the Framework, we access it at https://www.apigility.org/download.

Installing Apigility

Once downloaded, we can extract the archive and setup the virtual host to publish the public folder.

Advertisements

Installing Zend Framework on Debian 7.5

Zend Framework 2 is an open source framework for developing web applications and services using PHP 5.3+ using 100% object-oriented code and utilises most of the new features of PHP 5.3, namely namespaces, late static binding, lambda functions and closures. The components form a powerful and extensible web application framework and also offers a robust, high performance MVC implementation, a database abstraction that is easy to use, a forms component that implements HTML5 form rendering, validation and filtering as well as other components that provides authentication and authorization against common credential stores.

Downloading Zend Framework

To download the latest release of the Framework, we access it at http://framework.zend.com/downloads/.

Installing Zend Framework

Once downloaded, we can extract the archive to /usr/share/zend and re-use it in multiple applications.

Setting up Zend Framework

To use the shared Zend Framework library in our application, we set an environment variable in our virtual server to point to the installation directory of our library.

    SetEnv ZF2_PATH /usr/share/zend/ZendFramework-2.3.1/library

An alternative is to have the library on a per-application basis as per the skeleton application.

Installing Tomcat and Java Development Tools on Debian 7.5

Apache Tomcat is an application server that serves Java applications to its users and implements the specifications of Java Servlet and Java Server Pages developed by Sun Microsystems.

Installing Apache Tomcat

To install the basic application, we execute the following command in a “root” shell.

apt-get install tomcat7

To access the default page, we can access it at http://localhost:8080/.

To take advantage of additional functionality, we can install some packages that would allow us to control the application server from a web interface as well as have example applications and the documentation to Tomcat available. To install the additional packages, we execute the following command in a “root” shell.

apt-get install tomcat7-admin tomcat7-examples tomcat7-docs

Configuring Tomcat Web Interface

To enable access to some of the features, we need to set a username and password for Tomcat in the /etc/tomcat7/tomcat-users.xml file. To define a user “admin” with password “password”, we edit the file to contain the following.

<tomcat-users>
    <user username="admin" password="password" roles="manager-gui,admin-gui"/>
</tomcat-users>

Once we’ve defined the user, we will be able to access the management sections of Tomcat. For these changes to take effect, we need to restart the service by executing the following command in a “root” shell.

service tomcat7 restart

Testing Tomcat Web Interface

To view the Tomcat documentation, we can access it at http://localhost:8080/docs. This will provide us with extensive information on how to perform something with Tomcat.

To view the Tomcat example applications, we can access it at http://localhost:8080/examples. The examples implement a few different technologies that we can use for reference since the source code is included as well.

To view the Tomcat manager web application, we can access it at http://localhost:8080/manager/html, which will allow us to manage the Java applications (start, stop, deploy and reload applications) as well as enable us to find memory leaks in our running applications.

To view the Tomcat host-manager web application, we can access it at http://localhost:8080/host-manager/html, which will allow us to test, adjust and add virtual hosts in order to serve our applications.

Installing the Java Development Tools

To enable us to develop Java applications for Tomcat, we first need to install a compatible Java Development Kit by executing the following command in a “root” shell.

apt-get install default-jdk

This will install the openjdk-6-jdk package on our server. The documentation also suggests that we install Apache Ant, a build tool for Java applications, by executing the following command in a “root” shell.

apt-get install ant

Installing Apache with PHP5 and SSL support on Debian 7.5

The web server component of our development server has multiple purposes in our environment and is used for

  • the development of client solutions;
  • the development of software products;
  • the hosting of version control software, namely Subversion and Mercurial; and
  • the hosting of project management software, including time and issue tracking, namely Redmine.

Installing Apache

We install the required packages by executing the following command in a “root” shell.

apt-get install apache2 apache2-doc

Installing PHP

To enable the processing of PHP scripts, we install PHP and the PHP Apache Module by executing the following command in a “root” shell.

apt-get install php5 libapache2-mod-php5 php-doc

Installing PHP Modules

To enable the use of some additional functionality in PHP, we install the PHP modules by executing the following command in a “root” shell.

Retrieving files

To enable the retrieval of files, we install the php5-curl package by executing the following command in a “root” shell.

apt-get install php5-curl

Handling graphics

To enable the handling of graphics, we install the php5-gd package by executing the following command in a “root” shell.

apt-get install php5-gd

The module supports the PNG, JPEG, XPM formats as well as Freetype/Truetype fonts.

Finding a Location

To enable the determination of the geographical location of an IP address, we install the php5-geoip package by executing the following command in a “root” shell.

apt-get install php5-geoip

Internationalisation

To enable internationalisation in PHP scripts, we install the php5-intl package by executing the following command in a “root” shell.

apt-get install php5-intl

Encryption

To enable encryption in PHP scripts, we install the php5-mcrypt package by executing the following command in a “root” shell.

apt-get install php5-mcrypt

Memcached

To enable memcached functionality in PHP scripts, we install the php5-memcache package by executing the following command in a “root” shell.

apt-get install php5-memcache

MySQL

To enable MySQL functionality in PHP scripts, we install the php5-mysql package by executing the following command in a “root” shell.

apt-get install php5-mysql

PostScript

To enable PostScript functionality in PHP scripts, we install the php5-ps package by executing the following command in a “root” shell.

apt-get install php5-ps

XML-RPC

To enable XML-RPC functionality in PHP scripts, we install the php5-xmlrpc package by executing the following command in a “root” shell.

apt-get install php5-xmlrpc

XSL parser

To enable the XSL parser functionality in PHP scripts, we install the php5-xsl package by executing the following command in a “root” shell.

apt-get install php5-xsl

PHP Extension and Application Repository

To enable the PHP Extension and Application Repository (PEAR), we install the php-pear package by executing the following command in a “root” shell.

apt-get install php-pear php5-dev
MongoDB

To add the MongoDB extension to the repository, we install the mongo extension by executing the following command in a “root” shell.

pecl install mongo

Once the extension has been compiled and installed, we need to register the extension by executing the following command in a “root” shell.

echo 'extension=mongo.so' > /etc/php5/conf.d/mongo.ini

Enabling SSL support

To enable SSL support for our web server, we execute the following command in a “root” shell.

a2enmod ssl

Once all configuration has been done, we need to restart the web server by executing the following command in a “root” shell.

service apache2 restart

Installing MongoDB on Debian 7.5

The development server caters for the hosting of schema-free document-oriented databases during the development of web-based applications.

Installing MongoDB

The official packages are generally more up to date than the packages distributed with Debian. To enable the installation of the official packages, we need to import the public GPG key of the MongoDB package store. To import the public GPG key to the system key ring, we execute the following command in a “root” shell.

apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

Once the key is imported, we need to create an APT source list file for MongoDB. To create the file, we execute the following command in a “root” shell.

echo 'deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' > /etc/apt/sources.list.d/mongodb.list

Once the source list file is created, we need to reload the local package database. To reload the local package database, we execute the following command in a “root” shell.

apt-get update

Once the package database is updated, we can install the latest stable version of MongoDB. To install the MongoDB package, we execute the following command in a “root” shell.

apt-get install mongodb-org

Configuring MongoDB

The configuration of MongoDB is defined in the /etc/mongod.conf file. It is recommended to stop the daemon before making any configuration changes.

To stop the daemon, we stop the mongod service by executing the following command in a “root” shell.

service mongod stop

dbpath

dbpath = /var/lib/mongodb

By default, MongoDB stores its databases under /var/lib/mongodb. To store the databases under /home/mongodb, we would move the current databases by executing the following command in a “root” shell.

mv /var/lib/mongodb /home

To update the location, we set the value of dbpath to /home/mongodb in the /etc/mongodb.conf file.

dbpath = /home/mongodb

port

port = 27017

By default, MongoDB listens on port 27017 for connections. By setting the value of port, MongoDB can listen on a different port for connections. The default ports used by MongoDB, is listed in the reference documentation.

bind_ip

bind_ip = 127.0.0.1

By default, MongoDB binds to the localhost IP address. By specifying an IP address for bind_ip, MongoDB will bind to that specific address.

bind_ip = 192.168.100.14

From the example above, MongoDB will only bind to the IP address specified, namely 192.168.100.14.

To start the daemon, we start the mongod service by executing the following command in a “root” shell.

service mongod start

Installing Memcached on Debian 7.5

The development server caters for the hosting of in-memory object-caching during the development of web-based applications intended to speed up dynamic web applications by alleviating database load.

Installing Memcached

We install the required packages by executing the following command in a “root” shell.

apt-get install memcached

Configuring Memcached

The configuration of Memcached is defined in the /etc/memcached.conf file. It is recommended to stop the daemon before making any configuration changes.

To stop the daemon, we stop the memcached service by executing the following command in a “root” shell.

service memcached stop

memory size

-m 64

By default, Memcached will use up to a maximum size of 64 MB of memory. By setting the value of -m, Memcached can use a different amount of maximum memory.

port

-p 11211

By default, Memcached listens on port 11211 for connections. By setting the value of -p, Memcached can listen on a different port for connections.

address

-l 127.0.0.1

By default, Memcached binds to the localhost IP address. By specifying an IP address for -l, Memcached will bind to that specific address.

To start the daemon, we start the memcached service by executing the following command in a “root” shell.

service memcached start

Installing MySQL Server on Debian 7.5

The development server caters for the hosting of relational databases during the development of web-based applications.

Installing MySQL Server

We install the required packages by executing the following command in a “root” shell.

apt-get install mysql-server mysql-client

During installation, we will be prompted for a password for the MySQL “root” user – this password is valid for the user root@localhost and root@hostname.

Configuring MySQL Server

The configuration of MySQL Server is defined in the /etc/mysql/my.cnf file under the section [mysqld]. It is recommended to stop the daemon before making any configuration changes.

To stop the daemon, we stop the mysql service by executing the following command in a “root” shell.

service mysql stop

datadir

datadir         = /var/lib/mysql

By default, MySQL Server stores its databases under /var/lib/mysql. To store the databases under /home/mysql, we would move the current databases by executing the following command in a “root” shell.

mv /var/lib/mysql /home

To update the location, we set the value of datadir to /home/mysql in the /etc/mysql/my.cnf file.

datadir         = /home/mysql

port

port            = 3306

By default, MySQL Server listens on port 3306 for connections. By setting the value of port, MySQL Server can listen on a different port for connections.

bind-address

bind-address            = 127.0.0.1

By default, MySQL Server binds to the localhost IP address. By specifying an IP address for bind-address, MySQL Server will bind to that specific address.

bind-address            = 192.168.100.14

From the example above, MySQL Server will only bind to the IP address specified, namely 192.168.100.14.

To start the daemon, we start the mysql service by executing the following command in a “root” shell.

service mysql start