Install php 5.2.17 on FreeBSD 9.2

Mysql Apache Linux PHP Mugs
Another server came and the requirement still same. PHP 5.2.17 is a must. I only have 2 options from the vendor; using ubuntu or freebsd.

Its 2013 and all support for php 5.2 on ubuntu server already gone. I have one option left for this job. FreeBSD. Since my last work with FreeBSD I also think FreeBSD 9.2 already throw PHP 5.2 but I’ll try it first.

Install Ports, PHP 5.2.17, Apache 2.2 and MySQL Server 5.1

# portsnap fetch

Looking up portsnap.FreeBSD.org mirrors… 7 mirrors found.
Fetching public key from ec2-ap-southeast-2.portsnap.freebsd.org… done.
Fetching snapshot tag from ec2-ap-southeast-2.portsnap.freebsd.org… done.
Fetching snapshot metadata… done.
Fetching snapshot generated at Mon Nov 25 07:07:20 WIT 2013:

# portsnap extract

Install latest supported PHP 5.2

# cd /usr/ports/lang/php52

Choose required stuff, Apache as web server.

Selection_019

===>   NOTICE:

This port is deprecated; you may wish to reconsider installing it:

PHP 5.2 series is strongly discouraged for new  installations, migrate now.

It is scheduled to be removed on or after 2014-03-01.

Wew. At least it work for my job now :-)

For apache selection, let it as is.

Selection_020

Install PHP Extensions

# cd /usr/ports/lang/php52-extensions && make install

choose extensions that you like. ( I pick MySQL, Curl, GD beside default options).

Tips : add WITHOUT_X11=yes to /etc/make.conf to prevent system install X11 related software.

Install MySQL Server

# cd /usr/ports/databases/mysql51-server && make install

Configuration

Add service to /etc/rc.conf :

# echo mysql_enable=YES >> /etc/rc.conf

# echo apache22_enable=YES >> /etc/rc.conf

Starting Service

# /usr/local/etc/rc.d/mysql-server start
Starting mysql.

Add php handler

# ee /usr/local/etc/apache22/httpd.conf

Make sure these lines exists :

LoadModule php5_module        libexec/apache22/libphp5.so

in load module list

DirectoryIndex index.php index.html

in IfModule dir_module

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

inside IfModule mime_module directive.

# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.

Testing

Create php script

# ee /usr/local/www/apache22/data/info.php

put these lines :

<?php
phpinfo();
?>

save.

Open via lynx

lynx localhost/info.php

then I get

Selection_023

Picture source : Mysql Apache Linux PHP Mugs by Zerotees

Get bootstrap manual for offline reading

Bootstrap CSS Framework Purple T-Shirt I’m programmer and not designer. That is my main reason to use css framework. To speed up development, specially in early development phase. Feature change and so on, no need to get polished and clean interface. Just simple but logic presentation. Bootstrap come to rescue and since version 3 the documentation is lack and force me to read online. I read offline documentation and the doc say about install it using bower. I try to document the process :

Install node

$ cd
$ git clone git://github.com/ry/node.git
$ cd node
$ ls

android-configure  ChangeLog        deps     Makefile   test
AUTHORS            common.gypi      doc      node.gyp   tools
benchmark          configure        lib      README.md  vcbuild.bat
BSDmakefile        CONTRIBUTING.md  LICENSE  src

$ ./configure

{ ‘target_defaults’: { ‘cflags’: [],
‘default_configuration’: ‘Release’,
‘defines’: [‘OPENSSL_NO_SSL2=1’],
‘include_dirs’: [],
‘libraries’: []},
‘variables’: { ‘clang’: 0,
‘gcc_version’: 47,
‘host_arch’: ‘ia32’,
‘node_install_npm’: ‘true’,
‘node_prefix’: ”,
‘node_shared_cares’: ‘false’,
‘node_shared_http_parser’: ‘false’,
‘node_shared_libuv’: ‘false’,
‘node_shared_openssl’: ‘false’,
‘node_shared_v8’: ‘false’,
‘node_shared_zlib’: ‘false’,
‘node_tag’: ”,
‘node_use_dtrace’: ‘false’,
‘node_use_etw’: ‘false’,
‘node_use_mdb’: ‘false’,
‘node_use_openssl’: ‘true’,
‘node_use_perfctr’: ‘false’,
‘python’: ‘/usr/bin/python’,
‘target_arch’: ‘ia32’,
‘uv_parent_path’: ‘/deps/uv/’,
‘uv_use_dtrace’: ‘false’,
‘v8_enable_gdbjit’: 0,
‘v8_enable_i18n_support’: 0,
‘v8_no_strict_aliasing’: 1,
‘v8_optimized_debug’: 0,
‘v8_random_seed’: 0,
‘v8_use_snapshot’: ‘true’}}
creating  ./config.gypi
creating  ./config.mk

$ sudo make install

check version

$ npm -v
1.3.14

Install Bower

$ sudo npm install -g bower

Install Bootstrap

$ bower install bootstrap

Check ruby and install Jekyll

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-linux]

$ sudo gem install rdoc
$ sudo gem install jekyll

Successfully installed jekyll-1.3.0
1 gem installed
Installing ri documentation for jekyll-1.3.0…
Installing RDoc documentation for jekyll-1.3.0…

Generate Bootstrap Documentation

$cd bower_components/bootstrap

$jekyll serve
Configuration file: /home/alamsyah/bower_components/bootstrap/_config.yml
Source: /home/alamsyah/bower_components/bootstrap
Destination: ./_gh_pages
Generating… done.
Server address: http://0.0.0.0:9001
Server running… press ctrl-c to stop

Open browser and type : lcoalhost:9001

.Selection_021

Voila. I got offline version of Bootstrap documentation.

Picture : Bootstrap CSS Framework Purple T-Shirt by adamcoulombe187

Deploy google app engine : appcfg.py

Deploy php script aka application to google app engine is interesting. I came from traditional ftp-ing (so 1999 hehehe), scp and cpanel. Google app engine provide 2 ways of deployment; through appcfg.py and via git. I’ll try to explore both options now.

Preparation

In this stage, application need to get register first to App Engine Administration Console. Visit this address to get it done :

https://appengine.google.com/

Selection_008

Choose google account to use for this purpose.

Selection_009

click “Create Application” button.

Selection_010

make sure to check name availability and quota application (max 10).

Selection_011

Google app engine will need grant access from your google account.

Selection_012

Click ‘Accept” button to get started.

 

Deployment using appcfg.py

$ google_appengine/appcfg.py –oauth2 update digitalfusi/

08:59 PM Application: difuphp; version: 1
08:59 PM Host: appengine.google.com
08:59 PM
Starting update of app: difuphp, version: 1
08:59 PM Getting current resource limits.
Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=xxxxx6889yyy.apps.googleusercontent.com&access_type=offline

If your browser is on a different machine then exit and re-run this
application with the command-line parameter

–noauth_local_webserver

(process:3287): GLib-CRITICAL **: g_slice_set_config: assertion `sys_page_size == 0′ failed
Authentication successful.
09:01 PM Scanning files on local disk.
09:01 PM Cloning 2 application files.
09:01 PM Uploading 2 files and blobs.
09:01 PM Uploaded 2 files and blobs
09:01 PM Compilation starting.
09:01 PM Compilation completed.
09:01 PM Starting deployment.
09:01 PM Checking if deployment succeeded.
09:01 PM Deployment successful.
09:01 PM Checking if updated app version is serving.
09:01 PM Completed update of app: difuphp, version: 1

Testing the result by visit http://difuphp.appspot.com

Selection_013

appcfg.py is very straightforward command. Combine with oauth option I can upload all my php script to google infrastructure. Awesome.

 

Testing php script on google app engine

On last post I’ve wrote about howto install the google app SDK for PHP . Today I want to continue with simple testing.

How to run php script using google app engine on my Ubuntu 13.04 desktop :

1. Setting PATH to google app engine by edit .profile

$ cd
$ nano .profile

add this line :

PATH=”$HOME/google_appengine:$PATH”

save.

2. Export the PATH for current operation

$ export PATH=”$HOME/google_appengine:$PATH”
$ echo $PATH

”/home/alamsyah/google_appengine:/home/alamsyah/android-sdk-linux/tools:/home/alamsyah/android-sdk-linux/platforms:/home/alamsyah/android-sdk-linux/platform-tools:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games”

3. Create testing directory

$ mkdir digitalfusi

4. Create php script

$ nano digitalfusi/index.php

put these lines :

<?php

echo “Hello world from rasyid.net <p>”;

phpinfo();

?>

save.

5. Create yaml file (configuration file).

$ nano digitalfusi/app.yaml

Put these lines :

application: digitalfusi
version: 1
runtime: php
api_version: 1

handlers:
– url: /.*
script: index.php

save. For full list of yaml option you can refer to this link.

6. Run the script

Google app engine need to know which php-cgi that work.

if you use php-cgi from ubuntu stock you can run the server using this command :

$ google_appengine/dev_appserver.py –php_executable_path=/usr/bin/php-cgi digitalfusi

INFO     2013-11-23 06:50:46,610 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-11-23 06:50:59,891 sdk_update_checker.py:261] Update check failed: HTTP Error 404: Not Found
INFO     2013-11-23 06:50:59,927 api_server.py:138] Starting API server at: http://localhost:39378
INFO     2013-11-23 06:50:59,951 dispatcher.py:171] Starting module “default” running at: http://localhost:8080
INFO     2013-11-23 06:50:59,961 admin_server.py:117] Starting admin server at: http://localhost:8000

Selection_007

Using previous location of php-cgi :

$ google_appengine/dev_appserver.py –php_executable_path=$HOME/php-5.4.22/installdir/bin/php-cgi digitalfusi

INFO     2013-11-23 06:47:20,067 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-11-23 06:47:27,422 sdk_update_checker.py:261] Update check failed: HTTP Error 404: Not Found
INFO     2013-11-23 06:47:27,452 api_server.py:138] Starting API server at: http://localhost:46100
INFO     2013-11-23 06:47:27,477 dispatcher.py:171] Starting module “default” running at: http://localhost:8080
INFO     2013-11-23 06:47:27,482 admin_server.py:117] Starting admin server at: http://localhost:8000

Selection_006

install php sdk for google app engine on ubuntu 13.04

Another need for try php on google app engine make install all required stuff :

Install python

$ sudo apt-get install python

Check version :

$ python -V
Python 2.7.4

Install PHP CGI

Download latest php 5.4 from download page :

$ wget -c http://au1.php.net/get/php-5.4.22.tar.gz/from/this/mirror -O php-5.4.22.tar.gz

$ tar xvzf php-5.4.22.tar.gz

$ cd php-5.4.22/

$ sudo apt-get install gcc libmysqlclient-dev libxml2-dev

$ ./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql

$ make install

Check version :

$ pwd

/home/alamsyah/php-5.4.22

using absolute path

$ /home/alamsyah/php-5.4.22/installdir/bin/php-cgi -v

PHP 5.4.22 (cgi-fcgi) (built: Nov 23 2013 11:22:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Google APP engine SDK for PHP

Download latest version from here.

$ cd

$ wget -c http://googleappengine.googlecode.com/files/google_appengine_1.8.8.zip

$ unzip google_appengine_1.8.8.zip

MySQL Server

$ sudo apt-get install mysql-server-5.5 mysql-client-5.5

check :

$ dpkg -l | grep mysql

ii  libdbd-mysql-perl                         4.021-1                                i386         Perl5 database interface to the MySQL database
ii  libmysqlclient-dev                        5.5.34-0ubuntu0.13.04.1                i386         MySQL database development files
ii  libmysqlclient18:i386                     5.5.34-0ubuntu0.13.04.1                i386         MySQL database client library
ii  mysql-client-5.5                          5.5.34-0ubuntu0.13.04.1                i386         MySQL database client binaries
ii  mysql-client-core-5.5                     5.5.34-0ubuntu0.13.04.1                i386         MySQL database core client binaries
ii  mysql-common                              5.5.34-0ubuntu0.13.04.1                all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server-5.5                          5.5.34-0ubuntu0.13.04.1                i386         MySQL database server binaries and system database setup
ii  mysql-server-core-5.5                     5.5.34-0ubuntu0.13.04.1                i386         MySQL database server binaries

Great, client and server installed.

At this stage all requirement has installed correctly. I need php editor and I choose sublime text 2.

Install Sublime Text 2

$sudo add-apt-repository ppa:webupd8team/sublime-text-2

$sudo apt-get update

$sudo apt-get install sublime-text

Selection_005