Installing RockMongo on Debian 7.5

To be able to administer a MongoDB Server, a connection needs to be established to it. Several options are available, with the most frequently used being the command-line utilities in a shell. We can also make use of RockMongo, allowing us access to the database server through a web interface.

Downloading RockMongo

To download the latest release of RockMongo, we access it at http://rockmongo.com/downloads.

Installing RockMongo

Once downloaded, we can extract the archive and setup the virtual host to publish the extracted directory.

Configuring RockMongo

To configure RockMongo, we will host it on a secure virtual host on Apache.

Virtual Host settings

The virtual host will use the IP address 192.168.100.14, using the certificate in /etc/ssl/CA/certs/sitename.cert and the private key in /etc/ssl/CA/private/sitename.key.nopass. Authentication will also be required using a htpasswd file in /etc/apache2/security/htpasswd.sitename.

To create this htpasswd file, we execute the following command in a “root” shell.

htpasswd -c /etc/apache2/security/htpasswd.sitename admin

We will then be prompted to enter a password for the user admin, and using these credentials we will be able to access the RockMongo web interface.

Virtual Host Configuration

<VirtualHost 192.168.100.14:80>
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost 192.168.100.14:443>
    ServerName sitename
    ServerAdmin webmaster@domain

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    DocumentRoot /var/www/rockmongo
    <Directory /var/www/rockmongo>
        Options FollowSymLinks
        DirectoryIndex index.php
        <IfModule mod_php5.c>
            AddType application/x-httpd-php .php
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_admin_flag allow_url_fopen Off
            php_value include_path .
        </IfModule>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "MongoDB Administration"
            AuthUserFile /etc/apache2/security/htpasswd.sitename
        </IfModule>
        Require valid-user
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>

Enabling the Virtual Host

To enable the virtual host, we execute the following command in a “root” shell.

a2ensite sitename

To reload the configuration, we execute the following command in a “root” shell.

service apache2 reload
Advertisements

Installing phpMemcachedAdmin on Debian 7.5

To be able to monitor and manage a Memcached server, a connection needs to be established to it. Several options are available, with the most basic being making use of telnet. We can also make use of phpMemcachedAdmin, allowing us to monitor and manage our Memcached server through a web interface.

It provides us with real-time stats for get, set, delete, increment, decrement, evictions, reclaimed and cas commands, as well as server stats (network, items, server version) with googlecharts and server internal configuration.

Downloading phpMemcachedAdmin

To download the latest release of phpMemcachedAdmin, we access it at http://blog.elijaa.org/index.php?pages/phpMemcachedAdmin-Download.

Installing phpMemcachedAdmin

Once downloaded, we can extract the archive and setup the virtual host to publish the extracted directory.

Configuring phpMemcachedAdmin

To configure phpMemcachedAdmin, we will host it on a secure virtual host on Apache.

Virtual Host settings

The virtual host will use the IP address 192.168.100.14, using the certificate in /etc/ssl/CA/certs/sitename.cert and the private key in /etc/ssl/CA/private/sitename.key.nopass. Authentication will also be required using a htpasswd file in /etc/apache2/security/htpasswd.sitename.

To create this htpasswd file, we execute the following command in a “root” shell.

htpasswd -c /etc/apache2/security/htpasswd.sitename admin

We will then be prompted to enter a password for the user admin, and using these credentials we will be able to access the phpMemcachedAdmin web interface.

Virtual Host Configuration

<VirtualHost 192.168.100.14:80>
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost 192.168.100.14:443>
    ServerName sitename
    ServerAdmin webmaster@domain

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    DocumentRoot /var/www/phpmemcachedadmin
    <Directory /var/www/phpmemcachedadmin>
        Options FollowSymLinks
        DirectoryIndex index.php
        <IfModule mod_php5.c>
            AddType application/x-httpd-php .php
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_admin_flag allow_url_fopen Off
            php_value include_path .
        </IfModule>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "Memcached Administration"
            AuthUserFile /etc/apache2/security/htpasswd.sitename
        </IfModule>
        Require valid-user
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>

Enabling the Virtual Host

To enable the virtual host, we execute the following command in a “root” shell.

a2ensite sitename

To reload the configuration, we execute the following command in a “root” shell.

service apache2 reload

Installing phpMyAdmin on Debian 7.5

To be able to administer a MySQL Server, a connection needs to be established to it. Several options are available, with the most frequently used being the command-line utilities in a shell. Another option is to make use of MySQL Workbench. However, this isn’t the preferred solution, since this would require firewall rules to be defined to allow only certain remote connections to our database server. We can also make use of phpMyAdmin, allowing us access to the database server through a web interface.

Installing phpMyAdmin

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

apt-get install phpmyadmin

During the installation, we are prompted whether a web server should be configured and if the database should be configured making use of dbconfig-common.

If we selected to configure apache2, a virtual path /phpmyadmin will be added to the primary web site.

Configuring phpMyAdmin

To configure phpMyAdmin, we will host it on a secure virtual host on Apache.

Virtual Host settings

The virtual host will use the IP address 192.168.100.14, using the certificate in /etc/ssl/CA/certs/sitename.cert and the private key in /etc/ssl/CA/private/sitename.key.nopass. Authentication will also be required using a htpasswd file in /etc/apache2/security/htpasswd.sitename.

To create this htpasswd file, we execute the following command in a “root” shell.

htpasswd -c /etc/apache2/security/htpasswd.sitename admin

We will then be prompted to enter a password for the user admin, and using these credentials we will be able to access the phpMyAdmin web interface.

Virtual Host Configuration

<VirtualHost 192.168.100.14:80>
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost 192.168.100.14:443>
    ServerName sitename
    ServerAdmin webmaster@domain

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    DocumentRoot /usr/share/phpmyadmin
    <Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php
        <IfModule mod_php5.c>
            AddType application/x-httpd-php .php
            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_admin_flag allow_url_fopen Off
            php_value include_path .
            php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
            php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
        </IfModule>
        <IfModule mod_authn_file.c>
            AuthType Basic
            AuthName "MySQL Administration"
            AuthUserFile /etc/apache2/security/htpasswd.sitename
        </IfModule>
        Require valid-user
    </Directory>
    <Directory /usr/share/phpmyadmin/setup>
        Order Deny,Allow
        Deny from All
    </Directory>
    <Directory /usr/share/phpmyadmin/libraries>
        Order Deny,Allow
        Deny from All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>

Enabling the Virtual Host

To enable the virtual host, we execute the following command in a “root” shell.

a2ensite sitename

To reload the configuration, we execute the following command in a “root” shell.

service apache2 reload

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.

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 a Certificate on a Virtual Host

To enable the use of multiple secure virtual hosts, we use name-based as well as ip-based virtual hosts. To setup the secure virtual host, we use the following template.

NameVirtualHost 192.168.100.xxx
<VirtualHost 192.168.100.xxx:443>
    ServerName sitename
    ServerAdmin webmaster@sitename

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    BrowserMatch "MSIE [2-6]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    DocumentRoot /home/www-data/sitename
    <Directory /home/www-data/sitename>
        Options SymLinksIfOwnerMatch
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>

    DirectoryIndex index.html
    ErrorDocument 404 /404.html

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>

From the above, it is clear that we can setup a secure as well as a non-secure virtual host, whereby the non-secure virtual host would host general information and the secure virtual host the information exchange that requires encryption, e.g. the non-secure hosting a product catalogue and the secure hosting the payment component.

To ensure that the user always access the secure virtual host, we use the following template.

NameVirtualHost 192.168.100.xxx
<VirtualHost 192.168.100.xxx:80>
    RewriteEngine on
    ReWriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
</VirtualHost>

<VirtualHost 192.168.100.xxx:443>
    ServerName sitename
    ServerAdmin webmaster@sitename

    SSLEngine On
    SSLCertificateFile /etc/ssl/CA/certs/sitename.cert
    SSLCertificateKeyFile /etc/ssl/CA/private/sitename.key.nopass

    BrowserMatch "MSIE [2-6]" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    DocumentRoot /home/www-data/sitename
    <Directory /home/www-data/sitename>
        Options SymLinksIfOwnerMatch
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
    </Directory>

    DirectoryIndex index.html
    ErrorDocument 404 /404.html

    ErrorLog ${APACHE_LOG_DIR}/sitename/error.log
    CustomLog ${APACHE_LOG_DIR}/sitename/access.log combined
</VirtualHost>