Category Archives: Development

Maestro for OpenERP

Development of Maestro as a stand-alone application has been temporarily halted while I port the Maestro test and demo data to OpenERP, and then evaluate OpenERP as a platform to implement Maestro. The decision was based on the work still needed to achieve a minimum viable feature set developing from scratch, and on the opportunities made possible by building on OpenERP. I want to sincerely thank Maestro contributors Serge and Mark for their excellent work, and for helping me better understand the challenges of developing Maestro from scratch.

When I come up for air, I’ll post more on my experiences sp far with OpenERP, but I’ll tell you now I’m excited!

Installing OpenERP 7.0 using BitNami OpenERP 7.0 Stack

Fred Blauer recommended I take a look at OpenERP based on my described use case of PLM, Manufacturing, and Inventory Management.

I have been casually following OpenERP since v4.x (it was called TinyERP then), but had never configured a server – primarily because OpenERP used separate server and client, and I wanted a pure server system. However, I was pleasantly surprised when I took a look at the current OpenERP 7.0. OpenERP is now a pure web application, and BitNami has a free OpenERP Stack, including an Ubuntu-based virtual machine (in VMware format but also supported by VirtualBox). I’ll get the vm running first on my Win7 laptop with VirtualBox, and describe my experiences using OpenERP in a future post.

Create server

  • Download BitNami OpenERP Stack virtual machine (vm) to a Windows machine on my local network.
  • Using VirtualBox, create a new vm (Linux/Ubuntu 64b OS with 512MB RAM), but do not configure a boot drive.
  • Extract the files from the downloaded vm zip file into the directory VirtualBox created for the new vm.
  • Configure the new vm using VirtualBox Manager.
    • Network: Bridged (to have access from other machines in my network).
    • Storage: bitnami-openerp-7.0-3-ubuntu-12.04.vmdk (included in the BitNami vm download and copied to the vm directory).
  • Boot the new vm.

After booting, the console will display the server IP address and other helpful information (the IP address shown will likely differ in your environment):

*** Welcome to the BitNami OpenERP Stack ***
*** Built using Ubuntu 12.04 - Kernel 3.2.0-31-virtual (tty1). ***
*** You can access the application at 192.168.10.124 ***
*** The default username and password is 'user' and 'bitnami'. ***
*** Please refer to http://wiki.bitnami.com/Virtual_Machines for details. ***

******************************************************************************
*  To access the console, please use user 'bitnami' and password 'bitnami'.  *
*                                                                            *
*                                 WARNING                                    *
*  For security reasons, upon your first login, you will be prompted to      *
*  change the default password.                                              *
******************************************************************************

linux login:

If you copied the system drive for the vm from one host computer to another, the vm may report “The machine could not configure the network interface” after booting. This will occur if VIrtualBox provides a different Ethernet MAC ID on the second computer than on the first, and Ubunto creates a new Ethernet interface for a new interface MAC ID but is still configured for the interface on the first computer. Got it? “ifconfig -a” shows the Ethernet devices identified during boot, and “dmesg | grep eth” will show the network interface renaming. In this case, edit /etc/network/interfaces to specify the appropriate network interface (e.g. eth1 instead of eth0). See: http://www.howtogeek.com/168143/fixing-failed-to-bring-up-eth0-in-ubuntu-virtual-machine/ and http://gist.github.com/percursoaleatorio/6881040.

Login to the VirtualBox terminal using the provided username/password (bitnami/bitnami), and set a new password when prompted e.g. appleton (i.e. bitnami/appleton).

Enable ssh login

  • Configure sshd for remote login and scp file transfer.
$ sudo cp /etc/init/ssh.conf.back /etc/init/ssh.conf
$ sudo start ssh

PostgreSQL

My initial goal was to use pgadmin3 for viewing and managing PostgreSQL databases on the vm from my laptop.

  • Edit postgresql.conf so PostgreSQL will listen on all IP addresses.
$ sudo vi /opt/bitnami/postgresql/data/postgresql.conf
...
listen_addresses = '*'                  # what IP address(es) to listen on;
...
  • Restart PostgreSQL. I tried using pg_ctl but it wouldn’t initially run because of missing libraries. I solved this by adding the BitNami common libraries and the PostgreSQL libraries to LD_LIBRARY_PATH in ~/.bashrc (and logged out and back in again).
$ vi ~/.bashrc
...
# for BitNami Stack PostgreSQL
LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib:/opt/bitnami/common/lib
export LD_LIBRARY_PATH
...

However, this just led to other problems – the user to run pg_ctl as, whether the unset environment variable PGDATA is an issue, etc. I’m sure this isn’t how BitNami intends this to work (fwiw, /opt/bitnami/ctlscript.sh seems to be the intended control point for everything), but

Finally I just rebooted the vm, but pgadmin3 still wouldn’t connect. Perhaps it’s a firewall problem…

However, the PostgreSQL psql cli utility can be used (the password for the bitnami_openerp database is ‘bitnami’):

bitnami@linux:~$ psql bitnami_openerp
Password:
psql.bin (9.2.4)
Type "help" for help.

bitnami_openerp=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
bitnami_openerp=#

For more information on psql, see the PostgreSQL psql documentation.

Configure OpenERP

The BitNami OpenERP stack vm includes a database called bitnami_openerp (Administrator username/password: user/bitnami). I’m going to create a new database from scratch and install the basic modules needed to support Maestro workflows.

Access the vm from a workstation browser. The IP address for the vm is shown in the vm terminal window after booting (or after logging out).

  • Create a new database (company). The PostgreSQL master (super-administrator) password is “bitnami”, and I’ll use “appleton” for the new database password. OpenERP will create a new database with an administrative user (username/password: admin/appleton) and a demo user (username/password: demo/demo), and will login to the database as the administrator.

You will likely see a “timezone mismatch” warning in the top bar of the window. This is because the timezone set in your user preferences (which was configured by BitNami when they created the OpenERP stack) is different from the timezone your browser believes you are in (which comes from your workstation). You can access your user preferences by clicking the drop-down menu beside your username in the top bar of the window.

Install the following OpenERP applications using the Modules > Apps menu:

        • MRP (Manufacturing Orders, Bill of Materials, Routing)
        • Project Management (Projects, Tasks)
        • Issue Tracker (Support, Bug Tracker, Helpdesk)
        • Warehouse Management (Inventory, Logistic, Storage)

You will be prompted for your OpenERP user id and password (free to register) to start, and for any required configurations as each application is installed. Applications often have dependency applications, which will be automatically installed.

If you want to experiment with pre-defined demo data, select Manage Databases in the login screen and create a new database selecting “Install Demo Data”. The new database will be configured with a basic set of applications and demo data.

Still to do

Now that I’ve got OpenERP installed, the top items on my To Do list are:

  • Learn how OpenERP works! Create a couple users, import Maestro bills of materials, manufacture some serialized items using un-controlled, batch controlled and serialized raw material, etc.
  • Learn more about host OpenERP and Python web applications in general using WSGI by examining the BitNami OpenERP Stack (/opt/bitnami/apache2/conf/httpd.conf includes a WSGI reference).
  • Install OpenERP on FreeBSD. As of 2014-03-20, there is a binary package available for OpenERP 7.0, but it will still take time to understand how to make it usable.

Related information

For more information on OpenERP, a great reference is the OpenERP Book.

 

Updated since first posting 2013-07-22.

Northwind on MySQL

The Northwind sample database provided with Microsoft Access is an excellent tutorial schema for managing small business customers, orders, inventory, purchasing, suppliers, shipping, and employees. My problem was that I wanted to experiment with it using MySQL and the Yii Framework.

I found a number of MySQL ports of Northwind on the internet, but none with all 20 tables in the current version, or that included foreign key constraints. The only solution was to make my own.

I’ve put the results on GitHub should anyone else be in similar need: http://github.com/dalers/northwind

 

New Year’s Day 2014 Bicycle Ride

I’ve gone for a bike ride on New Year’s Day for about 5 years now, and this year was no different – except this time I’ve got video to show, my first YouTube video!

Video in 720p format was captured by a Contour Roam2, a really nice HD-quality video Action Camera. Editing and rendering was done using Microsoft’s free Movie Maker 2012, a very satisfactory experience. The transitions and most of the titles were added automatically using a Smart Theme, and the Add music button conveniently linked to free content (legally free!). The edited project was rendered and uploaded to YouTube using the Movie Maker YouTube plugin. After uploading, YouTube suggested video stabilization – which I agreed to.

FWIW, Contour has an interesting back story. They unfortunately closed doors August 2013, and remind me a lot of IVL Technologies, a similar sized tech company I had the pleasure of working  for 1993 to 1997. BloombergBusinessWeek had an interesting post mortem article on Contour , with a few tips for all tech entrepreneurs.

Column Types in Yii Migrations

I can never remember the abstract column types Yii supports, and never seem to get the right search string for google, but I’ll remember my own blog post.

Yii Database Abstract Column Types

Physical types are given in brackets using MySQL syntax.

  • pk: auto-incremental primary key type (“int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY”).
  • string: string type (“varchar(255)”).
  • text: a long string type (“text”).
  • integer: integer type (“int(11)”).
  • boolean: boolean type (“tinyint(1)”).
  • float: float number type (“float”).
  • decimal: decimal number type (“decimal”).
  • datetime: datetime type (“datetime”).
  • timestamp: timestamp type (“timestamp”).
  • time: time type (“time”).
  • date: date type (“date”).
  • binary: binary data type (“blob”).

If the abstract type contains two or more parts separated by spaces (e.g. “string NOT NULL”), then only the first part will be converted, and the rest of the parts will be appended to the conversion result. For example, ‘string NOT NULL’ is converted to ‘varchar(255) NOT NULL’.

I have shamelessly plagiarized this list from the Yii manual. Also see the Yii manual’s excellent article on migrations, and queirozf.com has a nice list of tips.

 

Calgary Tech Groups

I wrote up a list of tech groups I’m following for a colleague and thought it might be worth sharing.

The local ‘nix groups are CUUG (Calgary Unix Users Group, www.cuug.ab.ca) and Calgary LUG (Linux Users Group, http://clug.ca/). CUUG tends to focus more on server-side topics such as networking and security, whereas CLUG (at least from meeting topics and mailing list conversation) tends to focus more on distros, desktop apps and device interconnectivity.

CAMUG (Calgary Agile Method’s Users Group, www.calgaryagile.com). They cover a broad spectrum of software topics in their meetings and workshops, with a small-a-agile hook (e.g. developing software in an agile way using Git and GitHub, developing software in an agile way using Ruby…). CAMUG can draw 50-100 people for a popular topic, and their session last night on Appsec with Jim Bird was great!

The ASQ (American Society of Quality). The Calgary chapter (http://www.asqcalgary.org/ee/) seems mostly interested in manufacturing quality systems (i.e. enterprise stuff) and meets at night monthly in the NE. The topics have been hit and miss for my interests, but they’ve had excellent topics/speakers when I’ve attended.

The SQDG (Software Quality Discussion Group, http://www.sqdg.ca/) meets monthly downtown during lunch, and focuses on software testing practices. They’ve had some good topics, but I haven’t been to a session in over a year now. Again, the topics are hit and miss for my interests but the ones I’ve attended have been excellent with good networking opportunities.

Calgary Protospace (http://protospace.ca/) seem most interested in low-level hardware and firmware hacking, but the system drive failed in a NAS array a few years ago and all the family photos were temporarily unavailable (my wife said I lost them). A unix networking specialist I met through protospace helped me reconstruct the array and save my marriage.

Mobile Mondays (https://twitter.com/momoyyc) host a mobile-related hackathon the first Monday night of every month.

Startup Calgary (http://startupcalgary.ca/) is a government/industry coalition I like to follow not only for their own events, but also because they aggregate what everyone else is doing into a nice regular email they send me.

Calgary democamp (http://democampcalgary.com/) organize DemoCamps periodically for tech entrepreneurs to demo shiny new apps that will change the world <wink>. I’ve only been to one, but it was a packed house and very interesting set of presentations.

There are also a number of Calgary-area tech MeetUp groups, such as the Calgary WordPress MeetUp Group, the Calgary PHP AND NOT PHP Meetup Group, Pixels and Pints, PyYYC (Python) and more. Do some poking around for your interests, and contribute to the success of a community.

Maestro project now on GitHub

Maestro is now on GitHub. See the README.md for an overview of the project (and Getting Started instructions), and the wiki for project documentation. Unfortunately, there’s not much else yet other than the migration file for the schema, which should be stable (at least for a while).

In order, the immediate goals are to:

  • Complete the demo data set and load scripts
  • Auto-generate CRUD MVC code
  • Host a demo system on dalescott.net
  • Complete a basic read-only Part module

After a number of abortive attempts trying to adapt existing projects, this time it feels right – not too hot and not too cold. If you need to know what’s going on in, ask the Maestro!

Installing FreeDOS 1.1 on a T-23 Thinkpad

I recently had need to install DataScope on my T-23 Thinkpad (1.1GHz Pentium Mobile with 1G RAM and a 40G hard drive). DataScope is a serial data protocol analyzer that runs on DOS (and really does need DOS because it’s interacting directly with the PC’s serial ports). I had heard about FreeDOS, but never had a need to check it out before and this seemed a good opportunity (instead of finding my equally old set of MS-DOS 6.22 disks, or even worse, a Win98SE CD).

Although installation went smoothly, I simply could not get the T-23 to boot FreeDOS. I scoured the wiki and web for information, repeated the install over and over looking for a step I’d missed, went through the BIOS setup screen by screen, and googled for why the bootloader might fail.

Almost ready to give up, I recalled having to fully wipe a drive a few years back to remove both primary and backup boot records before FreeBSD would boot from the drive.

I booted the T-23 with LinuxMint 13 XFCE (more recent releases had display issues with the old Savage graphics chipset), and wrote 0′s to the entire drive:

> sudo dd if=/dev/zero of=/dev/sda bs=1M

To see the progress, I peridically sent a kill notice to dd from a second terminal session:

> ps -aux
> sudo kill -USR1 dd-pid

Twenty minutes later, the drive was clean. One more FreeDOS install and success. It’s alive! (or at least boots).

The next step is enabling USB support so I can install DataScope from a USB stick (the floppy drive for the T-23 is long gone, and so are any disks I once had).

Dale

P.S. Bill, why, oh why, did you decide MS-DOS file paths should have backslashes? Was it really better for it?

Removing ports no longer needed using portmaster

I replaced Postfix with ssmtp recently, and wanted to check my FreeBSD server for any installed ports that are no longer needed. Thanks to Chris on the FreeBSD mail list, I have added some new portmaster flags to my tookit.

First, you may want verify your ports index by rebuilding it:

# cd /usr/ports
# make index

Next, list the ports installed, grouped by:

  • Root ports (No dependencies, not depended on)
  • Trunk ports (No dependencies, are depended on)
  • Branch ports (Have dependencies, are depended on)
  • Leaf ports (Have dependencies, not depended on)
# portmaster -l

Finally, delete the leaf ports that you know you don’t need on their own:

# portmaster -e portname

Thanks, Chris.

 

Installing mdbtools, MariaDB, Nginx, and PHP on FreeBSD 9.1

This was originally a 2-part series, but has since been edited to a single post as part 2 was never fully completed.

Sometimes building a new server is easier than upgrading an old one, with the added bonus of staying up to date with current install procedures. Here’s the procedure I followed to build a new FreeBSD 9.1 server recently. I’ll be installing everything on the bare server (no jails).

FWIW, this server configuration is now being called a “LEMP” server, for Linux, Nginx (spelled “EngineX” for the “E”), MySQL (or MariaDB), and PHP (or as in my case, either PHP or Python).

The major applications being installed and their versions are:

  • FreeBSD 9.1-RELEASE
  • mdbtools v0.7 (project head from GitHub)
  • MariaDB 5.5.31
  • Nginx 1.4.2
  • PHP 5.5.1
  • phpMyAdmin 4.0.5

Create a virtual machine

You can build a bare-metal server, but a Virtual Machine (vm) can be more convenient to work with, and a dump from the vm can be easily restored on a bare-metal server if needed. The virtualizing environment I use is VirtualBox. Start by create a basic virtual machine for BSD (FreeBSD), with 256 MB memory, a 20G IDE primary master drive, and a CD/DVD drive IDE secondary master.

You may also need to configure the network interface for your situation. Consider how the vm will connect to the internet, and how you will connect to it. My default configuration is to bridge my laptop and the vm network interfaces. This gives me access to the vm from the host and from any other devices on my LAN, but requires a DHCP server on your LAN, and port 22 routed (not blocked).

If you don’t have internet access (e.g. if you are in someone else’s conference room), or if you do but port 22 is blocked (e.g. you’re in a certain popular fast-food restaurant with free WiFi), you will need to use a NAT or Host Only network connection in VirtualBox. If you don’t, the IP address Windows choses for itself will typically not be in the same subnet as the IP address VirtualBox choses for the client, and the two will not be able to communicate.

If you use the NAT connection, you will need to forward the following ports in order to communicate with the vm from the host:

ssh               host port 2222        client port 22
HTTP              host port 8880        client port 80
MySQL TCP         host port 3336        client port 3306
MySQL UDP         host port 3336        client port 3306
ftp               host port 2221        client port 21

Install FreeBSD OS

Install FreeBSD base system. Perform a standard install using FreeBSD-9.1-RELEASE-i386-dvd1.iso (or -bootonly.iso), with the following configuration:

hostname: firefly.scc.local
root password: secret
daemons to start at boot: sshd
user: dale (group wheel)

After installing the base system and rebooting, login as root and update the FreeBSD OS:

# freebsd-update fetch
# freebsd-update install

If freebsd-update reports that /usr/src/crypto/ssl/s3_cbc.c is missing, create the directory path (e.g. “# mkidir -p /usr/src/crypto/ssl/”) and fetch/extract again.

Update the ports tree:

# portsnap fetch
# portsnap extract

Edit /etc/hosts to specify a FQDN (fully qualified domain name) for the server:

::1                     localhost firefly.scc.local
127.0.0.1               localhost firefly.scc.local
#10.0.2.15               firefly.scc.local # default VBOX NAT IP address

Install portmaster:

# cd /usr/ports/ports-mgmt/portmaster/
# make install clean

If desired, install and run portaudit to monitor port security notices (you may want to omit this if you won’t be updating the system):

# cd /usr/ports/ports-mgmt/portaudit/
# make install clean
# portaudit -Fda

Edit /etc/ssh/sshd_config to allow remote ssh login by root and user dale, and restart sshd. The base system versions of OpenSSL and OpenSSH will be used (I trust the FreeBSD security committee, and not replace them with updated versions from the ports tree just to be up to date).

root is being allowed remote ssh access for managing databases remotely using MySQL Workbench. If this isn’t needed, don’t give root remote ssh access to avoid a potential security risk should the vm be deployed to the public one day.

# vi /etc/ssh/sshd_config
# add following
AllowUsers root dale
PermitRootLogin yes
#
# /etc/rc.d/sshd restart

Copy your ssh public key to ~/.ssh/authorized_keys (e.g. using WinSCP).

If desired (e.g. if this server will be in continuous use), you may want to define a mail alias for the root user, so that local system mail gets forwarded to a real system administrator.

# vi /etc/mail/aliases
add following alias:
root: realuser@realdomain.com

Install utility applications

Install some basic utility apps that usually come in handy eventually:

# cd /usr/ports/archivers/p7zip/
# make install clean
#
# cd /usr/ports/ftp/curl/
# make install clean
#
# cd /usr/ports/textproc/flip
# make install clean
#
# cd /usr/usr/ports/devel/git
# make install clean
#
# cd /usr/ports/www/lynx
# make install clean
#
# cd /usr/ports/ftp/wget
# make install clean
#
# cd /usr/ports/archivers/unzip   # might already be installed
# make install clean

Install mdbtools

mdbtools is a suite of utilities for working with data from an MS Jet database on a Unix system. First, install the GNU build toolchain needed to compile mdbtools.

# cd /usr/ports/devel/libtool   # may already be installed
# make install clean

# cd /usr/ports/devel/automake
# make install clean

# cd /usr/ports/devel/autoconf    # may already be installed
# make install clean

# cd /usr/ports/textproc/flex/
# make install clean

# cd /usr/ports/devel/bison/    # may already be installed
# make install clean

# cd /usr/ports/textproc/txt2man/
# make install clean

# cd /usr/ports/devel/glib20  # undocumented dependency
# make install clean

# rehash

Next, clone the mdbtools Github repo locally:

> mkdir ~/src/
> cd ~/src/
> git clone https://github.com/brianb/mdbtools.git

And finally, build and install mdbtools:

> cd ~/src/mdbtools/
> autoreconf -i -f
> ./configure
> gmake
> su - 
# gmake install

Add the installed mdbtools man pages to manpath (the install uses the Linux-typical /usr/local/share/man/man1/) by creating /usr/local/etc/man.d/mdbtools.conf and rebuilding the whatis database:

# vi /usr/local/etc/man.d/mdbtools.conf
# add MANPATH
MANPATH /usr/local/share/man
#
# /etc/periodic/weekly/320.whatis
# exit
> apropos mdb

Install Web App Stack

My goal is a simple common stack using MariaDB and Nginx for hosting PHP and Python-based web applications with MySQL back-ends.

Using MariaDB will mitigate risk of MySQL falling out of favor as Oracle continues to orient MySQL to its own needs, with minimal to no impact on applications and use. However, I expect to be using PostgreSQL more in the future, in particular as OpenERP uses PostgreSQL, but also because I seem to see more projects using it every day.

Nginx will provide improved performance on older and less capable hardware, and is becomming (has become?) the new standard for web servers, with its asynchronous event-driven approach to requst handling (instead of using more threads), and a reportedly simpler configuration (we’ll see about that…).

Install MariaDB Database Server

Install MariaDB:

# cd /usr/ports/databases/mariadb55-server/   # includes client
# make config ; make install clean
# rehash

Edit rc.conf to start MariaDB at boot:

# vi /etc/rc.conf
...
# add mysql_enable
mysql_enable="YES"

Manually start MariaDB:

# service mysql-server start

Setup grant tables:

# cd /usr/local/   # mysql_install_db assumes its running from here
# mysql_install_db --user=mysql

Configure root password:

> mysqladmin -u root password 'appleton'
> mysqladmin -u root -p -h firefly.scc.local password 'appleton'

Grant root permission to connect remotely:

> mysql -u root -p
mysql> grant all privileges on *.* to 'root'@'%' identified by 'appleton' with grant option;
mysql> exit;
>

Use the provided my-medium.cnf config file and edit for using InnoDB tables:

The output from “my_print_defaults –help” implies my-medium.cnf should copied to /etc/my.cnf, but I’ll use the MySQL convention I’ve learned until I know different.

# cp /usr/local/share/mysql/my-medium.cnf /var/db/mysql/my.cnf
# vi /var/db/mysql/my.cnf
...
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /var/db/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/db/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

Restart MariaDB:

# service mysql-server restart

and finally do a basic test to confirm things are basically working:

> mysql -u root -p
...
MariaDB [(none)]> show databases;
...
MariaDB [(none)]> use test;
...
MariaDB [(test)]> exit;
Bye
>

Install Nginx web server

Nginx will interoperate with PHP via FastCGI and PHP-FPM (FastCGI Process Manager), and with Python via FastCGI and via the flup library (py27-flup).

Install Nginx with appropriate options (note I’m not enabling SSL, which I don’t need at the moment, but I may wish later I had included it also):

# cd /usr/ports/www/nginx/
# make config
Use the default configuration options:
IPV6 IPv6 protocol support
HTTP Enable HTTP module 
HTTP_CACHE Enable http_cache module 
HTTP_REWRITE Enable http_rewrite module 
HTTP_STATUS Enable http_stub_status module
WWW Enable html status files

# make install clean

The Nginx config file is:

/usr/local/etc/nginx/nginx.conf
Edit rc.conf to start Nginx at boot:
# vi /etc/rc.conf
...
nginx_enable="YES"

Manually start Nginx:

# service nginx start

Test that Nginx is running by browing to the vm (e.g. http://localhost:8880).

Nginx will be configured later.

Install PHP processor

Install PHP:

# cd /usr/ports/lang/php55/
# make config
...
enable additional options:
FPM Build FPM version

# make install clean

Edit PHP php.ini configuration file:

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
#
# vi /usr/local/etc/php.ini
...
# uncomment session.save_path
session.save_path = "/tmp"
# add default date timezone
date.timezone = "America/Edmonton"

Install a motley assortment of PHP extensions (essentially the current requirements for phpMyAdmin, MediaWiki and the Yii framework).

# cd /usr/ports/lang/php55-extensions
# make config
...
enable additional extensions to install:
BZ2
CTYPE
CURL
DOM
FILTE
GD
ICONV
JSON
MBSTRING
MCRYPT
MYSQL
MYSQLI
OPENSSL
PDO
PDO_MYSQL (why PDO if not PDO_MYSQL ??)
READLINE
SESSION
SOAP
XML
ZIP
ZLIB

# make install clean

Configure PHP-FPM

I will be using the fastCGI process manager PHP-FPM (included with PHP starting with release 5.3.3) with Nginx.

Configure PHP-FPM by editing /usr/local/etc/php-fpm.conf:

# vi /usr/local/etc/php-fpm.conf
...
make following changes ("-" means delete, "+" means add):

-; events.mechanism = epoll
+events.mechanism = kqueue
...
-listen = 127.0.0.1:9000
+listen = /var/run/php-fpm.sock
...
-;listen.owner = www
-;listen.group = www
-;listen.mode = 0666
+listen.owner = www
+listen.group = www
+listen.mode = 0666

Edit rc.conf to start PHP-FPM at boot:

# vi /etc/rc.conf
...
php_fpm_enable="YES"

Manually start PHP-FPM:

# service php-fpm start

When user web applications are installed in Part 2, Nginx will be configured for each PHP application to use PHP-FPM.

Install phpMyAdmin

phpMyAdmin provides convenient management of the MariaDB database server, without requiring any client-side software. First, install phpmyadmin from ports:

# cd /usr/ports/databases/phpmyadmin/
# make config
...
disable options:
APC PHP APC (animated progress bar) support
# make install clean

It seems that pecl-APC (the APC option in the phpMyAdmin config) can’t be compiled with PHP 5.5 (see FreeBSD forum). I’d rather not downgrade to PHP 5.4, and I suspect I can make do without an “animated progress bar”, so I’m unselecting it for now.

Load pma tables:

# cd /usr/local/www/phpMyAdmin
# mysql -u root -p < ./examples/create_tables.sql

Configure Nginx:

# command
# command

Create the phpmyadmin configuration using the setup wizard (and copy to config.inc.php). Access http://hostname/phpmyadmin/setup, specify connection type: socket (instead of tcp) and use suggested names for all tables.

Increase max session before auto logout to 9 hrs (from 3 min):

# vi /usr/local/www/phpMyAdmin/config.inc.php
...
$cfg['LoginCookieValidity'] = 3600 * 9; // 3600 sec/hr * 9 hrs
...

Also edit session.gc_maxlifetime in php.ini:

# vi /usr/local/etc/php.ini
...
; increase max session time for phpMyAdmin. Max session time for phpMyAdmin
; set to 9 hrs in phpMyAdmin config.inc.php ((LoginCookieValidity), which
; requires increasing php garbage collection to greater than 9 hrs
; E.g. 32500 sec = (3600 sec/hr * 9 hrs) + 100 sec
session.gc_maxlifetime = 32500

Configure Nginx:

# command
# command
# command

Install requirements for PHP unit and functional testing (optional)

If you’re going to use the server for PHP unit and functional testing, you will likely want to install xdebug and testing frameworks.

Install php-xdebug:

# cd /usr/ports/devel/php-xdebug
# make install clean

Edit /usr/local/etc/php/extensions.ini and comment loading xdebug as std extension.

Edit /usr/local/etc/php.ini to add loading xdebug as zend_extension.

[xdebug]
; load xdebug as zend_extension (loading as std extension commented in php/extensions.ini)
zend_extension=/usr/local/lib/php/20100525/xdebug.so
; enable profiling
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp/profiler
; remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

Install pear and pear PHPUnit for unit testing Yii-based projects.

# cd /usr/ports/devel/pear
# make install clean
# pear config-set auto_discover 1
# pear install pear.phpunit.de/PHPUnit

Install PHP pear Selenium, which is a dependency for Yii PHPUnit testing, but is also used for functional testing. Install curl and PHP curl extension first if not already installed.

# cd /usr/ports/ftp/curl; make install clean
# cd /usr/ports/ftp/php5-curl; make install clean
# pear install phpunit/PHPUnit_Selenium

And that’s that!