Category Archives: NSA310

Compiling google’s mod_pagespeed for nginx

This post is intended mainly to Zyxel NSA310 users.

Prerequisites
See first https://adrhc.go.ro/blog/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
Before starting do declare the environment variables specified to the link above.

Environment & other preparations
NEW_BUILD_NAME=ngx_pagespeed
NEW_BUILD_VER=20150317
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

wget -O ngx_pagespeed-$NEW_BUILD_VER.zip https://github.com/pagespeed/ngx_pagespeed/archive/master.zip
unzip ngx_pagespeed-$NEW_BUILD_VER.zip
mv ngx_pagespeed-master/ ngx_pagespeed-$NEW_BUILD_VER

Build procedure
Read then do first https://adrhc.go.ro/blog/install-configure-googles-mod_pagespeed-for-apache/
cd ~/compile/mod_pagespeed/src/net/instaweb/automatic
~/x.sh ffpg1
make BUILDTYPE=Release AR.host="$PWD/../../../build/wrappers/ar.sh" AR.target="$PWD/../../../build/wrappers/ar.sh" all

Other considerations
See also https://github.com/pagespeed/ngx_pagespeed/wiki/Building-PSOL-From-Source

Compiling protobuf-2.5.0 on synology

# repairing some system bugs
mkdir -p ~/temp/opt/i686-linux-gnu/lib
mv -v /opt/i686-linux-gnu/lib/libpthread-0.10.so ~/temp/opt/i686-linux-gnu/lib
ln -s /lib/libpthread.so.0 /opt/i686-linux-gnu/lib/libpthread-0.10.so
mkdir -p /usr/local/i686-linux-gnu/i686-linux-gnu/lib
ln -s /opt/lib/libstdc++.la /usr/local/i686-linux-gnu/i686-linux-gnu/lib/libstdc++.la

export CPPFLAGS="-march=i686"
export CXXFLAGS="-march=i686"

cd ~/compile
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar xvzf protobuf-2.5.0.tar.gz
cd ~/compile/protobuf-2.5.0
~/x.sh ffpg-no-m4
./configure --prefix=$HOME/apps --enable-dependency-tracking

Compiling PHP 7.0.0RC2

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=php
NEW_BUILD_VER1=7.0.0RC2
NEW_BUILD_VER=$NEW_BUILD_VER1-zts
MYSQL_BUILD_NAME_AND_VER=mysql-5.6.25
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

sed -i s/"HAVE_GD_XPM\s1"/"HAVE_GD_XPM 0"/g configure
sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g configure

./configure --prefix=/ffp --enable-re2c-cgoto=shared,/ffp --with-apxs2=/ffp/opt/apache-2.2.29-worker/bin/apxs --enable-fpm --with-config-file-path=/ffp/etc/php.ini --with-config-file-scan-dir=/ffp/etc --with-libxml-dir=/ffp --with-openssl=shared,/ffp --with-pcre-regex=/ffp --with-zlib=shared,/ffp --enable-bcmath --with-bz2=shared,/ffp --enable-calendar --with-curl=shared,/ffp --with-enchant=shared,/ffp --enable-exif --enable-ftp --with-gd=shared,/ffp --with-jpeg-dir=/ffp --with-png-dir=/ffp --with-freetype-dir=/ffp --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext=shared,/ffp --with-gmp=shared,/ffp --with-mhash=shared,/ffp --enable-intl --with-icu-dir=/ffp --enable-mbstring --with-mcrypt=shared,/ffp --with-mysql-sock=/ffp/var/run/mysql/mysql.sock --with-mysqli=shared,/ffp/bin/mysql_config --enable-opcache --enable-pcntl --with-pdo-mysql=shared,/ffp --with-readline=shared,/ffp --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-libexpat-dir=/ffp --with-xmlrpc=shared,/ffp --with-iconv=shared,/ffp --with-xsl=/ffp --enable-zip --with-pear --with-pcre-dir=/ffp --with-openssl-dir=/ffp --with-zlib-dir=/ffp --with-iconv-dir=/ffp --with-webp-dir=/ffp --enable-opcache-file

sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g Makefile
sed -i s/"define\sHAVE_GD_XPM\s0"/"undef HAVE_GD_XPM"/g main/php_config.h

./Makefile
BUILD_PHPDBG = $(LIBTOOL) --mode=link $(CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_PHPDBG_OBJS) $(EXTRA_LIBS) $(PHPDBG_EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -lreadline -o $(BUILD_BINARY)
BUILD_CGI = $(LIBTOOL) --mode=link $(CC) -export-dynamic $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(EXTRA_LDFLAGS_PROGRAM) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_CGI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -lreadline -o $(SAPI_CGI_PATH)

#INSTALL
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
mkdir -p $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cp -v /ffp/opt/apache-2.2.29-worker/conf/httpd.conf $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
INSTALL_ROOT=$HOME/temp/$NEW_BUILD_NAME_AND_VER make install
#if after make you are asked for running 'libtool --finish ...' then do it:
libtool --finish libs
#You'll get something like this:
#Libraries have been installed in:
#   /ffp/home/root/compile/$NEW_BUILD_NAME_AND_VER/libs -> here you'll find libphp5.so and libphp5.la
rm -vr $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
ls -l /tmp/php-*
ls -l ~/ffp_0.7_armv5/packages/php-*
#for the files found below remove the -n or/and -q php's call options:
grep -nr "\s\(-q\|-n\)\s" ffp/bin/
sed -i s/"\s-q"/""/ ffp/bin/peardev
sed -i s/"\s-q"/""/ ffp/bin/pear
sed -i s/"\s-q"/""/ ffp/bin/pecl
sed -i s/"\s-n"/""/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pear
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/peardev
makepkg $NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER $NEW_BUILD_VER 0
cp -v /tmp/php-*.txz $HOME/ffp_0.7_armv5/packages/
funpkg -i $HOME/ffp_0.7_armv5/packages/$NEW_BUILD_NAME_AND_VER-arm-0.txz

Compiling Perl 5.22.0

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

#search http://search.cpan.org/ for modules
#see http://www.thegeekstuff.com/2008/09/how-to-install-perl-modules-manually-and-using-cpan-command/
#Installing Perl modules from CPAN (didn't work): http://perl.about.com/od/packagesmodules/qt/perlcpan.htm

#environment
export CFLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error"
export BUILD_FLAGS="$CFLAGS -I/ffp/include"
#export LIBS="-lintl"
#export LDFLAGS="-L/ffp/lib $LIBS"
unset LIBS
export LDFLAGS="-L/ffp/lib"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"

NEW_BUILD_NAME=perl
NEW_BUILD_VER=5.22.0
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

#building perl
cd ~/compile
wget http://www.cpan.org/src/5.0/perl-5.22.0.tar.gz
tar xvzf perl-5.22.0.tar.gz
cd ~/compile/$NEW_BUILD_NAME_AND_VER
nohup ~/x.sh ffpg &

#build configuration
./Configure -Dprefix=/ffp -Dusethreads -Duseshrplib
Build a threading Perl? [n] y
What libraries to use? [-lpthread -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat]
What optimizer/debugger flag should be used? [-O2] -O2 -march=armv5te
Any additional cc flags? -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe $BUILD_FLAGS
Shall I use /ffp/bin/nm to extract C symbols from the libraries? [y] n
List of earlier versions to include in @INC? [5.20.1 5.14.2] none
Do you want to install perl as /ffp/bin/perl? [n] y
Do you wish to use dynamic loading? [y]
Any special flags to pass to cc to create a dynamically loaded library? -shared $BUILD_FLAGS -L/ffp/lib
Your host name appears to be "nsa310". Right? [y] n
Please type the (one word) name of your host: adrhc
What is your domain name? [.localdomain] .go.ro
What is your e-mail address? [root@adrhc.go.ro] ***************
What shall I put after the #! to start up perl ("none" to not use #!)? [/ffp/bin/perl5.22.0] /ffp/bin/perl
Shall I ignore gethostname() from now on? [n] y
Run make depend now? [y] n

#Manually modify config.sh:
cccdlflags='-fPIC'
ccdlflags='-Wl,-E -Wl,-rpath,/ffp/lib/perl5/5.22.0/armv5tel-linux-thread-multi/CORE'
ccflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error -I/ffp/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
ccflags_uselargefiles='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
usrinc='/ffp/include'
glibpth='/ffp/lib /ffp/lib/386 /usr/shlib /lib /lib/386 /usr/ccs/lib /usr/ucblib /ffp/lib '

#run after config.sh is manually modified:
sh Configure -S

#ERROR
	"can't get tcp protocol by name" for perl dist/Net-Ping/t/ tests
#SOLUTION
	#see http://forum.nas-central.org/viewtopic.php?f=249&t=16561&hilit=iana
	#see http://www.iana.org/assignments/port-numbers
	#see http://sethwklein.net/iana-etc
	#you must have already installed one of these (they are the same considering the functionality gain): 
	https://adrhc.go.ro/ffp_0.7_armv5/packages/iana-etc-2.30-arm-0.txz -> this one has more comments (compared with stripped version)
	https://adrhc.go.ro/ffp_0.7_armv5/packages/iana-etc-2.30-arm-0-stripped.txz
	http://www.inreto.de/ffp/0.7/arm/packages/iana-etc-2.30-arm-1.txz
	#then add to fun_plug.local the commands below
	cp /ffp/etc/protocols /etc/protocols
	cp /ffp/etc/services /etc/services

#ERROR
	POSIX.xs:992:18: error: 'FE_TOWARDZERO' undeclared (first use in this function)
	   case 0: return FE_TOWARDZERO;
#SOLUTION
	Comment three rows in ext/POSIX/POSIX.xs:
	/*#ifdef I_FENV
	#include <fenv.h>
	#endif*/

#make
make depend
nohup make -C . &
tail -f nohup.out
nohup /ffp/bin/make test -C . &
tail -f nohup.out

#install
rm /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

#Install CPAN minus module
wget http://search.cpan.org/CPAN/authors/id/M/MI/MIYAGAWA/App-cpanminus-1.7036.tar.gz
tar xvzf App-cpanminus-1.7036.tar.gz
ffpg-all
perl Makefile.PL
make
make test
make install

#In order to work CPAN minus requires:
#ln -s /ffp/etc/protocols /etc/protocols
#CPAN minus might require Mozilla's CA Bundle certificate (search /ffp/bin/cpanm for cert.pem after installation).
#download the Mozilla's CA Bundle certificate:
#wget -nv http://curl.haxx.se/ca/cacert.pem -O /ffp/etc/ssl/cert.pem

#Install cpan-outdated module (recommended way):
cpan install App::cpanoutdated
#or build yourself:
cd ~/compile
wget http://search.cpan.org/CPAN/authors/id/T/TO/TOKUHIROM/App-cpanoutdated-0.24.tar.gz
tar xvzf App-cpanoutdated-0.24.tar.gz
cd ~/compile/App-cpanoutdated-0.24
~/x.sh ffpg
perl Makefile.PL
#installing cpanoutdated required modules
cpanm CPAN::DistnameInfo
cpanm LWP
cpanm Module::Metadata
cpanm local::lib
... and others if asked ...
make
make test
make install
#In order to learn about outdated modules run:
cpan-outdated

#Install cpanlistchanges with CPAN (recommended way):
cpan install App::cpanlistchanges
#or with CPAN minus:
cpanm App::cpanlistchanges
#If you want to see what is changed (Change-log) for CPAN module than run:
cpan-listchanges CPAN

#Building & installing Module-Build module (installed anyway when running "cpan install App::cpanoutdated").
cd ~/compile
wget http://www.cpan.org/authors/id/L/LE/LEONT/Module-Build-0.4210.tar.gz
tar xvzf Module-Build-0.4210.tar.gz
cd Module-Build-0.4210
~/x.sh ffpg
perl Build.PL
./Build
./Build test
./Build install

#Building & installing gettext module.
#needs:
export LIBS="-lintl"
export LDFLAGS="-L/ffp/lib $LIBS"
cd ~/compile/
wget http://search.cpan.org/CPAN/authors/id/P/PV/PVANDRY/gettext-1.05.tar.gz
tar xvzf gettext-1.05.tar.gz
cd gettext-1.05
~/x.sh ffpg
perl Makefile.PL
make
make test
make install

#When building help2man and perl has the module Locale::gettext I get the error:
#sh: error while loading shared libraries: libintl.so.8: cannot open shared object file: No such file or directory
#solved by (adding /ffp/lib to the end):
#export LD_LIBRARY_PATH=/usr/local/zy-pkgs/lib:/ffp/opt/serf-1.3.6/lib:/ffp/lib
#and also the error:
#help2man: can't get `--help' info from ./help2man
#Try `--no-discard-stderr' if option outputs to stderr
#solved by removing Locale::gettext perl module:
perl ~/tools/uninstall_perl_module.pl Locale::gettext -> only shows what files should be removed
#then remove by hand the Locale::gettext specific files

#Listing PERL modules
#original article http://www.linuxquestions.org/questions/linux-general-1/how-to-list-all-installed-perl-modules-216603/
instmodsh	-> also have capabilities to show module's files
#or
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'
#or
#Perl Module Tools (https://metacpan.org/release/pmtools)
pmall - get all installed modules pmdesc descriptions
pminst - find what's installed
#or
cpan -l

#using cpanm to install App::cpanlistchanges module
cpanm App::cpanlistchanges
#using cpanm to reinstall XML::Simple module
cpanm --reinstall XML::Simple
#Shows the primary maintainers for XML::Simple module
cpan -A XML::Simple
#Show the XML::Simple module details
cpan -D XML::Simple

#upgrade a module using CPAN
#enter CPAN shell using:
cpan
#press h then ENTER for CPAN shell help
#report updates for DB_File module:
r DB_File
#report updates for CGI::Fast module:
r CGI::Fast
#upgrade CGI::Fast module:
upgrade CGI::Fast

Compiling Python 2.7.10

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

#Compiling Python-2.7.10
export CFLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error"
#export BUILD_FLAGS="$CFLAGS -I/ffp/include -I/ffp/opt/apache-2.2.29-worker/include"
export BUILD_FLAGS="$CFLAGS -I/ffp/include"
export LIBS="-lintl -lreadline -lncurses"
export LDFLAGS="-L/ffp/lib $LIBS"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export PATH=/ffp/sbin:/ffp/bin

NEW_BUILD_NAME=Python
NEW_BUILD_VER=2.7.10
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

#ERROR
	Failed to build these modules:
	_curses_panel      readline
#SOLUTION (before configure)
	use -lreadline -lncurses for BUILD_FLAGS and LDFLAGS

#ERROR (make)
	export PATH=/ffp/sbin:/ffp/bin
	/ffp/bin/mkdir -p Include
	./Parser/asdl_c.py -h Include ./Parser/Python.asdl
	/ffp/bin/env: python: No such file or directory
	make: *** [Include/Python-ast.h] Error 127
#SOLUTION (apply before configure)
	#somehow python uses the existing version of python (any) to compile itself (current sources)
	#force to ignore the existing version of python when building itself:
	touch Include/Python-ast.h Python/Python-ast.c

#ERROR (test after installing)
	cd ~/temp/$NEW_BUILD_NAME_AND_VER
	ffp/bin/python
	Python 2.7.9 (default, Jan 11 2015, 18:08:14)
	[GCC 4.9.2] on linux2
	Type "help", "copyright", "credits" or "license" for more information.
	>>> help('modules')
	Please wait a moment while I gather a list of all available modules...
	ffp/bin/python: symbol '_PyErr_ReplaceException': can't resolve symbol
#SOLUTION (apply before configure)
	#See http://bugs.python.org/issue23781.
	wget http://bugs.python.org/file38697/capi_PyErr_ReplaceException.patch
	#modify capi_PyErr_ReplaceException.patch (remove a/ and b/ source path prefixes)
	#apply capi_PyErr_ReplaceException.patch accepting all defaults
	patch -p0 -i capi_PyErr_ReplaceException.patch

cd ~/compile/$NEW_BUILD_NAME_AND_VER
patch -p0 -i capi_PyErr_ReplaceException.patch
touch Include/Python-ast.h Python/Python-ast.c
#./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl --with-ensurepip=upgrade
#configure without pip; better install manually pip-6.0.6 in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip
./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl

#ERROR (before make)
	./Parser/asdl_c.py -h Include ./Parser/Python.asdl
	/ram_bin/usr/bin/python: /ffp/lib/libpthread.so.0: no version information available (required by /usr/lib/libpython2.6.so.1.0)
	make: *** [Include/Python-ast.h] Segmentation fault (core dumped)
#SOLUTION
	touch Include/Python-ast.h Python/Python-ast.c

#ERROR (before make)
	Failed to build these modules:
	_curses_panel
#SOLUTION
	slacker -u br2:ncurses-5.9_20140927-arm-1.txz

touch Include/Python-ast.h Python/Python-ast.c
nohup /ffp/bin/make -C . &
tail -f nohup.out

#ERROR (after make)
	Python build finished, but the necessary bits to build these modules were not found:
	_tkinter           bsddb185           nis
	sunaudiodev
	To find the necessary bits, look in setup.py in detect_modules() for the module's name.
#SOLUTION
	This means won't build the following modules (is ok):
	_tkinter (requires X11 libraries), bsddb185 (Berkeley DB 1.85 library), nis (Interface to Sun’s NIS), sunaudiodev (Access to Sun audio hardware)

rm /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

#From now on RESTORE ENVIRONMENT to that specified at https://adrhc.go.ro/wordpress/common-commands-when-building:
export CFLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -Wno-error"
export BUILD_FLAGS="$CFLAGS -I/ffp/include"
unset LIBS
export LDFLAGS="-L/ffp/lib"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"

#In order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (provided by setuptools module)
#download the Mozilla's CA Bundle certificate:
wget -nv http://curl.haxx.se/ca/cacert.pem -O /ffp/etc/ssl/cert.pem

#You could use easy_install (provided by setuptools module) in order to install modules (or simply use pip).
#When using pip and required to use the "--egg" option than you better compile the module manually.
#see http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309

#List python modules:
python
#then, from python's shell/prompt:
help('modules')
help('setuptools') -> info about setuptools module
help('jinja2') -> info about jinja2 module (observe lower case usage)

#ERROR (la instalarea multor pachete)
	AttributeError: Distribution instance has no attribute 'include_package_data'
#SOLUTION
	Nu instala setuptools folosind:
	wget https://bitbucket.org/pypa/setuptools/get/default.tar.gz#egg=setuptools-dev

#Install setuptools-17.0
cd ~/compile
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-17.0.tar.gz#md5=fd15d24ed1e4c95e56d8c6e812f3a84f
tar xvzf setuptools-17.0.tar.gz
cd setuptools-17.0
~/x.sh ffpg
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install pip-7.0.3 (requires setuptools-17.0).
#pip-7.0.3 has no CERTIFICATE_VERIFY_FAILED error
cd ~/compile
wget https://pypi.python.org/packages/source/p/pip/pip-7.0.3.tar.gz#md5=54cbf5ae000fb3af3367345f5d299d1c
tar xvzf pip-7.0.3.tar.gz
cd pip-7.0.3
~/x.sh ffpg
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install SCons (better compile manually SCons because its files have non-FFP paths)
#SCons install doesn't work without --egg option.
#see also http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309
pip install SCons -vvv --egg --log /ffp/var/log/python/SCons.txt
#Modify the paths used by /ffp/bin/scons* files.
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/scons-time-2.3.0
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/scons-time
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/scons-2.3.0
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/sconsign-2.3.0
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/sconsign
sed -i s/"\/usr\/bin"/"\/ffp\/bin"/ /ffp/bin/scons
cd /ffp/lib/scons-2.3.0
~/x.sh ffpg

#Install Jinja2-2.7.3
cd ~/compile
wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
tar xvzf Jinja2-2.7.3.tar.gz
cd Jinja2-2.7.3
~/x.sh ffpg
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Uninstall a python module
cd ~/compile/pip-1.2.1 -> has CERTIFICATE_VERIFY_FAILED error at install
cd ~/compile/pip-1.5.6 -> has CERTIFICATE_VERIFY_FAILED error always
cd ~/compile/pip-6.0.6 -> has no CERTIFICATE_VERIFY_FAILED error
cat module-files.txt | xargs rm -rf
find /ffp/lib/python2.7/ -name "*pip*"
rm -r /ffp/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg

#Using pip:
python -m pip help
python -m pip list
#varianta cu freeze e o listare care arata si eventualele probleme ale pachetelor
python -m pip freeze
python -m pip help install
python -m pip search simplejson
python -m pip install simplejson -> nu a functionat
python -m pip install cryptography 0.6.1
python -m pip install pyOpenSSL 0.14 -vvv --log /ffp/var/log/python/pyOpenSSL-0.14.txt
python -m pip list --outdated
python -m pip install -U CherryPy -> updating CherryPy
pip install -U setuptools -v --log /ffp/var/log/python/setuptools -> updating CherryPy and recording in log
python -m pip install rst2html5 -> required by aria2
python -m pip uninstall pycurl
pip install pycurl -v --log /ffp/var/log/python/pycurl.txt
pip install PIL --allow-unverified PIL
# install yenc with allow-all-external and "--allow-unverified yenc"
pip install --allow-all-external --allow-unverified yenc yenc -v --log /ffp/var/log/python/yenc
# install from archive url
pip install -v --log /ffp/var/log/python/yenc http://www.golug.it/pub/yenc/yenc-0.4.0.tar.gz

#List module's files:
pip show -f Jinja2

#Install pycurl-7.19.5 -> required by pyLoad and easier to install using pip or easy_install (from setuptools)
cd ~/compile
wget http://pycurl.sourceforge.net/download/pycurl-7.19.5.tar.gz
tar xvzf pycurl-7.19.5.tar.gz
cd pycurl-7.19.5
~/x.sh ffpg
python setup.py --help-commands
python setup.py --help

#ERROR0
	python: symbol 'CRYPTO_set_locking_callback': can't resolve symbol
	python: symbol 'CRYPTO_num_locks': can't resolve symbol
	python: symbol 'CRYPTO_set_id_callback': can't resolve symbol
	Traceback (most recent call last):
	File "<stdin>", line 1, in <module>
	ImportError: unknown dlopen() error
#SOLUTION0
	Nu compila cu openssl:
	python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl --openssl-dir=/ffp
	Modifica setup.py:
	# self.libraries = []
	self.libraries = ["crypto"]

python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl
python setup.py install --record module-files.txt
#test installation:
python
import pycurl
CTRL+D

#certifi (14.5.14)	-> required in order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)
#pip (6.0.6)		-> required version in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip

#Requirements files are used to hold the result from pip freeze for the purpose of achieving repeatable installations. 
#In this case, your requirement file contains a pinned version of everything that was installed when pip freeze was run.
pip freeze > /ffp/opt/apache-htdocs/public/python2.7-packages.txt
pip install -r /ffp/opt/apache-htdocs/public/python2.7-packages.txt

#ecdsa module below must be corrected after installation:
cd /ffp/lib/python2.7/site-packages/ecdsa
ffpg

# pip freeze
certifi==2015.4.28
cffi==1.1.2
Cheetah==2.4.4
CherryPy==3.7.0
cryptography==0.9.3
enum34==1.0.4
Flask==0.10.1
idna==2.0
ipaddress==1.0.14
itsdangerous==0.24
Jinja2==2.8
Markdown==2.6.2
MarkupSafe==0.23
peewee==2.6.3
pyasn1==0.1.8
pycparser==2.14
pycurl==7.19.5.1
pyOpenSSL==0.15.1
requests==2.7.0
six==1.9.0
snor==0.0.8
transmissionrpc==0.11
Werkzeug==0.10.4
yenc==0.4.0

Compiling mysql 5.6.24

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting declare the environment variables specified at the link above.

NEW_BUILD_NAME=mysql
#NEW_BUILD_VER=5.6.24.large
NEW_BUILD_VER=5.6.24.small+innodb
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd $HOME/compile
rm -r $HOME/compile/$NEW_BUILD_NAME_AND_VER
tar -xzvf mysql-5.6.24.tar.gz
cd $HOME/compile/$NEW_BUILD_NAME_AND_VER
~/x.sh ffpg

#all params with help text
#cmake . -LAH > cmake.help.txt

#Clear/reset previously run configure & generate:
make clean
rm CMakeCache.txt

#large = embedded + archive + federated + blackhole + innodb
#cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=large -DMYSQL_DATADIR=/ffp/opt/srv/mysql/data -DSYSCONFDIR=/ffp/etc -DTMPDIR=/ffp/opt/srv/mysql/tmp -DWITH_DEBUG=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

#small = embedded
#below we have small + innodb
cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=small -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/ffp/opt/srv/mysql/data -DSYSCONFDIR=/ffp/etc -DTMPDIR=/ffp/opt/srv/mysql/tmp -DWITH_DEBUG=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

#ERROR (FEATURE_SET=large)
	/ffp/home/root/compile/mysql-5.6.24/sql/sql_table.cc:2020:7: error: 'old_part_info' was not declared in this scope
	   if (old_part_info)
		   ^
	make[2]: *** [sql/CMakeFiles/sql.dir/sql_table.cc.o] Error 1
#SOLUTION
	#Modify /ffp/home/root/compile/mysql-5.6.24/sql/sql_table.cc to this:
	end:
	#ifdef WITH_PARTITION_STORAGE_ENGINE
	  if (old_part_info)
	  {
		lpt->table->file->set_part_info(old_part_info, false);
	  }
	#endif
	DBUG_RETURN(error);

nohup /ffp/bin/make -C . &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1` -p `pidof ccmake`
tail -f nohup.out

rm -v /tmp/$NEW_BUILD_NAME-*.txz
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

# see also CREATE SYSTEM DB (first step and mandatory before using mysql)
# search my blog for: CREATE SYSTEM DB

Compiling nginx 1.9.2

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=nginx
NEW_BUILD_VER=1.9.1
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd /ffp/home/root/compile/$NEW_BUILD_NAME_AND_VER
~/x.sh ffpg-all
./configure --help > configure.help.txt

#additional modules
#+nginx-dav-ext-module
#+ngx_devel_kit-0.2.19
#+lua-nginx-module-0.9.16rc3
#+echo-nginx-module-0.58
#+rds-json-nginx-module-0.14
#+drizzle-nginx-module-0.1.9
#+set-misc-nginx-module-0.29
#
#--with-pcre-jit -> must be the last

./configure --prefix=/ffp --conf-path=/ffp/etc/nginx/nginx.conf --error-log-path=/ffp/log/nginx-error.log --pid-path=/ffp/var/run/nginx.pid --user=nobody --group=nobody --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-perl=/ffp/bin/perl --http-log-path=/ffp/log/nginx-access.log --http-client-body-temp-path=/ffp/tmp/nginx/client-body --http-proxy-temp-path=/ffp/tmp/nginx/proxy --http-fastcgi-temp-path=/ffp/tmp/nginx/fastcgi --http-uwsgi-temp-path=/ffp/tmp/nginx/uwsgi --http-scgi-temp-path=/ffp/tmp/nginx/scgi --with-stream --with-stream_ssl_module --with-cc=/ffp/bin/cc --with-cpp=/ffp/bin/cpp --with-cpu-opt=armv5te --with-debug --add-module=$HOME/compile/nginx-modules/nginx-dav-ext-module --add-module=$HOME/compile/nginx-modules/ngx_devel_kit-0.2.19 --add-module=$HOME/compile/nginx-modules/set-misc-nginx-module-0.29 --add-module=$HOME/compile/nginx-modules/drizzle-nginx-module-0.1.9 --add-module=$HOME/compile/nginx-modules/echo-nginx-module-0.58 --add-module=$HOME/compile/nginx-modules/rds-json-nginx-module-0.14 --add-module=$HOME/compile/nginx-modules/lua-nginx-module-0.9.16rc3 --with-pcre --with-pcre-jit

#ERROR (lua-nginx-module-0.9.16rc1)
	ngx_http_lua_initworkerby.c:(.text+0x2b8): undefined reference to `ngx_http_set_connection_log'
	objs/addon/src/ngx_http_lua_timer.o: In function `ngx_http_lua_timer_handler':
	ngx_http_lua_timer.c:(.text+0x4c0): undefined reference to `ngx_http_set_connection_log'
#SOLUTION
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_timer.c
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_initworkerby.c

#ERROR (drizzle-nginx-module-0.1.8)
	/ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.9/src/ngx_http_drizzle_util.c:607:13: error: 'ngx_http_upstream_state_t' has no member named 'response_sec'
		 u->state->response_sec = tp->sec;
				 ^
	/ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c:608:13: error: 'ngx_http_upstream_state_t' has no member named 'response_msec'
		 u->state->response_msec = tp->msec;
#SOLUTION
	#Replace any "->response_msec" with "->response_time".
	#Comment any line containing: "->response_sec =".
	#Replace any "&& u->state->response_time" with "&& u->state->response_time".
	#Do the above replacements/comments using these commands:
	sed -i s/"\s\s\su->state->response_sec"/"\/\/u->state->response_sec"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c
	sed -i s/"u->state->response_msec"/"u->state->response_time"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c
	sed -i s/"u->state->response_sec"/"u->state->response_time"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c

nohup /ffp/bin/make -C ~/compile/$NEW_BUILD_NAME_AND_VER &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1` -p `pidof ccmake`
tail -f nohup.out

#directories required by nginx in order to run with default settings
mkdir -p /ffp/tmp/nginx/client-body
mkdir -p /ffp/tmp/nginx/proxy
mkdir -p /ffp/tmp/nginx/fastcgi
mkdir -p /ffp/tmp/nginx/uwsgi
mkdir -p /ffp/tmp/nginx/scgi

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling boost 1.46.0

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=boost
NEW_BUILD_VER=1.46.0
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd ~/compile
wget http://sourceforge.net/projects/boost/files/boost/1.46.0/boost_1_46_0.tar.gz/download
tar xvzf boost_1_46_0.tar.gz
cd ~/compile/boost_1_46_0
~/x.sh ffpg

ERROR
	Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS
SOLUTION
	cd ~/compile/boost_1_46_0
	wget https://svn.boost.org/trac/boost/raw-attachment/ticket/6165/libstdcpp3.hpp.patch
	patch -p0 -i libstdcpp3.hpp.patch

#for compilation with mpi do:
echo "using mpi ;" >> tools/build/v2/user-config.jam
wget https://svn.boost.org/trac/boost/raw-attachment/ticket/6165/libstdcpp3.hpp.patch
patch -p0 -i libstdcpp3.hpp.patch

./bootstrap.sh

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
#compilation with mpi
#requires http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz
#or http://www.open-mpi.org/software/ompi/v1.8/
nohup ./bjam --prefix=$HOME/temp/boost-$NEW_BUILD_VER/ffp variant=release install &
#or compile it without mpi:
nohup ./bjam --prefix=$HOME/temp/boost-$NEW_BUILD_VER/ffp --without-mpi variant=release install &

cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling LuaJIT-2.0.3

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=LuaJIT
NEW_BUILD_VER=2.0.3
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd /ffp/home/root/compile/LuaJIT-2.0.3
~/x.sh ffpg
sed -i s/"PREFIX= \/usr\/local"/"PREFIX= \/ffp"/ Makefile
make

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling and using luarocks

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=luarocks
NEW_BUILD_VER=2.2.2
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd /ffp/home/root/compile/luarocks-2.2.2
~/x.sh ffpg
./configure --help > configure.help.txt
./configure --prefix=/ffp
make build

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

#using luarocks
luarocks search cjson
luarocks install lua-cjson --deps-mode all
luarocks install router --deps-mode all
#*.lua rocks are installed to /ffp/share/lua/5.1/
#*.so rocks are installed to /ffp/lib/lua/5.1/

#nginx configuration
lua_package_cpath	'/ffp/lib/lua/5.1/?.so;;';
lua_package_path	'/ffp/share/lua/5.1/?.lua;;';

#using router; for some versions ngx.var.request_method must be lower-case: 
router:execute(string.lower(ngx.var.request_method), ngx.var.restPaths)

Compiling nginx 1.9.0

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=nginx
NEW_BUILD_VER=1.9.0
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=1

cd /ffp/home/root/compile/nginx-1.9.0
~/x.sh ffpg
./configure --help > configure.help.txt

#additional modules
#+nginx-dav-ext-module
#+ngx_devel_kit-0.2.19
#+lua-nginx-module-0.9.16rc1
#+echo-nginx-module-0.57
#+rds-json-nginx-module
#+drizzle-nginx-module
#
#--with-pcre-jit -> must be the last

./configure --prefix=/ffp --conf-path=/ffp/etc/nginx/nginx.conf --error-log-path=/ffp/log/nginx-error.log --pid-path=/ffp/var/run/nginx.pid --user=nobody --group=nobody --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-perl=/ffp/bin/perl --http-log-path=/ffp/log/nginx-access.log --http-client-body-temp-path=/ffp/tmp/nginx/client-body --http-proxy-temp-path=/ffp/tmp/nginx/proxy --http-fastcgi-temp-path=/ffp/tmp/nginx/fastcgi --http-uwsgi-temp-path=/ffp/tmp/nginx/uwsgi --http-scgi-temp-path=/ffp/tmp/nginx/scgi --with-cc=/ffp/bin/cc --with-cpp=/ffp/bin/cpp --with-cpu-opt=armv5te --with-debug --add-module=$HOME/compile/nginx-modules/nginx-dav-ext-module --add-module=$HOME/compile/nginx-modules/ngx_devel_kit-0.2.19 --add-module=$HOME/compile/nginx-modules/drizzle-nginx-module --add-module=$HOME/compile/nginx-modules/echo-nginx-module-0.57 --add-module=$HOME/compile/nginx-modules/rds-json-nginx-module --add-module=$HOME/compile/nginx-modules/lua-nginx-module-0.9.16rc1 --with-pcre --with-pcre-jit

ERROR
	ngx_http_lua_initworkerby.c:(.text+0x2b8): undefined reference to `ngx_http_set_connection_log'
	objs/addon/src/ngx_http_lua_timer.o: In function `ngx_http_lua_timer_handler':
	ngx_http_lua_timer.c:(.text+0x4c0): undefined reference to `ngx_http_set_connection_log'
SOLUTION
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_timer.c
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_initworkerby.c

nohup /ffp/bin/make -C ~/compile/$NEW_BUILD_NAME_AND_VER &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1` -p `pidof ccmake`
tail -f nohup.out

#directories required for nginx to run with default settings
mkdir -p /ffp/tmp/nginx/client-body
mkdir -p /ffp/tmp/nginx/proxy
mkdir -p /ffp/tmp/nginx/fastcgi
mkdir -p /ffp/tmp/nginx/uwsgi
mkdir -p /ffp/tmp/nginx/scgi

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling boost 1.49.0

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=boost
NEW_BUILD_VER=1.49.0
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd ~/compile
wget http://sourceforge.net/projects/boost/files/boost/1.49.0/boost_1_49_0.tar.gz/download
tar xvzf boost_1_49_0.tar.gz
cd ~/compile/boost_1_49_0
~/x.sh ffpg

#modify boostcpp.jam to this (removed /usr/local):
#install-requirements += <install-default-prefix> ;
#modify boost-build.jam, boostcpp.jam, bootstrap.sh:
#replace any /usr or /usr/local to /ffp
./bootstrap.sh
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
nohup ./b2 --prefix=$HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp --without-mpi variant=release install &

cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling anyterm-1.1.29

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

cd ~/compile
wget http://anyterm.org/download/anyterm-1.1.29.tbz2
tar jxf anyterm-1.1.29.tbz2
cd anyterm-1.1.29
~/x.sh ffpg

NEW_BUILD_NAME=anyterm
NEW_BUILD_VER=1.1.29
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

ERROR
	execinfo.h not found
SOLUTION
	sed -i s/"#include <execinfo"/"\/\/#include <execinfo"/ libpbe/src/segv_backtrace.cc
	sed -i s/"signal(SIGSEGV,SIG_DFL"/"\/*signal(SIGSEGV,SIG_DFL"/ libpbe/src/segv_backtrace.cc
	sed -i s/"raise(signum);"/"raise(signum);*\/"/ libpbe/src/segv_backtrace.cc

ERROR (UBUNTU too)
	../src/SmtpClient.cc: In member function 'void SmtpClient::wait_for_reply(int, int)':
	../src/SmtpClient.cc:82:35: error: 'sscanf' was not declared in this scope
		 int rc = sscanf(buf,"%d",&code);
SOLUTION
	#grep -r sscanf /usr/include/" finds /usr/include/stdio.h
	#<cstdio> must be included to anyterm-1.1.29/libpbe/src/SmtpClient.cc:
	sed -i s/"using namespace std"/"#include <cstdio>\nusing namespace std"/ libpbe/src/SmtpClient.cc

ERROR
	Terminal.o: In function `Terminal::~Terminal()':
	Terminal.cc:(.text+0x10): undefined reference to `libiconv_close'
	Terminal.o: In function `Terminal::write_normal_char(wchar_t)':
	Terminal.cc:(.text+0x1250): undefined reference to `libiconv'
	Terminal.o: In function `Terminal::Terminal(int, int, Screen&)':
	Terminal.cc:(.text+0x1e38): undefined reference to `libiconv_open'
SOLUTION
	common.mk must have iconv added to LINK_FLAGS:
	sed -i s/"lutil"/"lutil -liconv"/ common.mk

ERROR on UBUNTU
	In file included from ../src/URI.cc:21:0:
	/usr/include/boost/spirit.hpp:18:4: warning: #warning "This header is deprecated. Please use: boost/spirit/include/classic.hpp" [-Wcpp]
	 #  warning "This header is deprecated. Please use: boost/spirit/include/classic.hpp"
		^
	../src/URI.cc:22:50: fatal error: boost/spirit/actor/insert_at_actor.hpp: No such file or directory
	 #include 
	###############################################################
	# This means that won't find some hpp (as example error above).
SOLUTION
	# Commented replacement only solves a warning but imply the error: ‘rule’ does not name a type.
	#sed -i s"/boost\/spirit.hpp"/"boost\/spirit\/include\/classic.hpp"/ ./libpbe/src/URI.cc
	sed -i s"/actor\/insert_at_actor.hpp"/"home\/classic\/actor\/insert_at_actor.hpp"/ ./libpbe/src/URI.cc
	sed -i s"/dynamic\/if.hpp"/"home\/classic\/dynamic\/if.hpp"/ ./libpbe/src/URI.cc
	sed -i s"/utility\/loops.hpp"/"home\/classic\/utility\/loops.hpp"/ ./libpbe/src/URI.cc
	sed -i s"/iterator\/multi_pass.hpp"/"home\/classic\/iterator\/multi_pass.hpp"/ ./libpbe/src/URI.cc
	#sed -i s"/boost\/spirit.hpp"/"boost\/spirit\/include\/classic.hpp"/ ./libpbe/src/parse_http_request.cc
	sed -i s"/actor\/insert_at_actor.hpp"/"home\/classic\/actor\/insert_at_actor.hpp"/ ./libpbe/src/parse_http_request.cc
	sed -i s"/dynamic\/if.hpp"/"home\/classic\/dynamic\/if.hpp"/ ./libpbe/src/parse_http_request.cc
	sed -i s"/utility\/loops.hpp"/"home\/classic\/utility\/loops.hpp"/ ./libpbe/src/parse_http_request.cc
	sed -i s"/iterator\/multi_pass.hpp"/"home\/classic\/iterator\/multi_pass.hpp"/ ./libpbe/src/parse_http_request.cc

# On Ubuntu requires:
sudo apt-get install libboost-all-dev

#Modify cols & rows count in anyterm-1.1.29/src/Anyterm.cc
sed -i s/"int rows=25, int cols=80"/"int rows=500, int cols=155"/ src/Anyterm.cc
sed -i s/"rows\",25"/"rows\",500"/ src/Anyterm.cc
sed -i s/"cols\",80"/"cols\",155"/ src/Anyterm.cc
sed -i s/"pty_rows=25, int pty_cols=80"/"pty_rows=500, int pty_cols=155"/ src/SubProcess.hh
sed -i s/",25,80,"/",500,155,"/ browser/anyterm.html

# make using multiple cores: make -j 4
make -j 4
cp anytermd /ffp/bin
cp anytermd ~/ffp_0.7_armv5/packages/anytermd-500x155

Compiling mysql 5.6.23

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=mysql
NEW_BUILD_VER=5.6.23
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd $HOME/compile
rm -r $HOME/compile/mysql-5.6.23
tar -xzvf mysql-5.6.23.tar.gz
cd $HOME/compile/mysql-5.6.23
~/x.sh ffpg

#all params with help text
#cmake . -LAH > cmake.help.txt

#Clear/reset previously run configure & generate:
make clean
rm CMakeCache.txt

#interactive configure
cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=large -DMYSQL_DATADIR=/ffp/opt/srv/mysql/data -DSYSCONFDIR=/ffp/etc -DTMPDIR=/ffp/opt/srv/mysql/tmp -DWITH_DEBUG=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_EMBEDDED_SHARED_LIBRARY=ON -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

nohup /ffp/bin/make -C ~/compile/$NEW_BUILD_NAME_AND_VER &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1` -p `pidof ccmake`
tail -f nohup.out

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

# see also CREATE SYSTEM DB (first step and mandatory before using mysql)
# search my blog for: CREATE SYSTEM DB

Compiling PHP 5.6.x

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=php
NEW_BUILD_VER1=5.6.13
NEW_BUILD_VER=$NEW_BUILD_VER1-zts
MYSQL_BUILD_NAME_AND_VER=mysql-5.6.25
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd ~/compile
wget -O $NEW_BUILD_NAME_AND_VER.tar.gz http://ro1.php.net/get/php-$NEW_BUILD_VER1.tar.gz/from/this/mirror
tar -xzf $NEW_BUILD_NAME-$NEW_BUILD_VER1.tar.gz
mv $NEW_BUILD_NAME-$NEW_BUILD_VER1 $NEW_BUILD_NAME_AND_VER
cd ~/compile/$NEW_BUILD_NAME_AND_VER
nohup ~/x.sh ffpg &
tail -f nohup.out
cp -r . ../$NEW_BUILD_NAME_AND_VER+ffpg
  
#REINSTALL (start from here when reinstalling)
cd ~/compile
rm -r ~/compile/$NEW_BUILD_NAME_AND_VER
cp -r ~/compile/$NEW_BUILD_NAME_AND_VER+ffpg ~/compile/$NEW_BUILD_NAME_AND_VER
cd ~/compile/$NEW_BUILD_NAME_AND_VER
 
./configure --help > configure.help.txt
cat configure.help.txt
 
ERROR0:
    don't know how to define struct flock on this system ... set --enable-opcache=no
SOLUTION0:
    funpkg -r libgd-2.1.0-arm-0
 
#When using --with-apxs2=/ffp/opt/apache-2.2.9-prefork/bin/apxs we'll get php-non-ZTS!
#When using --with-apxs2=/ffp/opt/apache-2.2.29-worker/bin/apxs we'll get php-ZTS!
#--with-recode -> couldn't build it for the moment
#--with-tidy -> too old, makes no sense to use it
#--without-sqlite3=/ffp -> doesn't work (stupid option)
#--enable-mysqlnd -> I don't use it
#--enable-dba=shared -> somehow disables mysqli

sed -i s/"HAVE_GD_XPM\s1"/"HAVE_GD_XPM 0"/g configure
sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g configure

./configure --prefix=/ffp --enable-re2c-cgoto=shared,/ffp --with-apxs2=/ffp/opt/apache-2.2.29-worker/bin/apxs --enable-fpm --with-config-file-path=/ffp/etc/php.ini --with-config-file-scan-dir=/ffp/etc --with-libxml-dir=/ffp --with-openssl=shared,/ffp --with-pcre-regex=/ffp --with-zlib=shared,/ffp --enable-bcmath --with-bz2=shared,/ffp --enable-calendar --with-curl=shared,/ffp --with-enchant=shared,/ffp --enable-exif --enable-ftp --with-gd=shared,/ffp --with-jpeg-dir=/ffp --with-png-dir=/ffp --with-freetype-dir=/ffp --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext=shared,/ffp --with-gmp=shared,/ffp --with-mhash=shared,/ffp --enable-intl --with-icu-dir=/ffp --enable-mbstring --with-mcrypt=shared,/ffp --with-mysql=shared,/ffp --with-mysql-sock=/ffp/var/run/mysql/mysql.sock --with-mysqli=shared,/ffp/bin/mysql_config --enable-opcache --enable-pcntl --with-pdo-mysql=shared,/ffp --with-readline=shared,/ffp --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-libexpat-dir=/ffp --with-xmlrpc=shared,/ffp --with-iconv=shared,/ffp --with-xsl=/ffp --enable-zip --with-pear --with-pcre-dir=/ffp --with-openssl-dir=/ffp --with-zlib-dir=/ffp --with-iconv-dir=/ffp

sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g Makefile
sed -i s/"define\sHAVE_GD_XPM\s0"/"undef HAVE_GD_XPM"/g main/php_config.h

#make
nohup make -C . &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1`
tail -f nohup.out
#tests
nohup make test &

#INSTALL
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
mkdir -p $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cp -v /ffp/opt/apache-2.2.29-worker/conf/httpd.conf $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
INSTALL_ROOT=$HOME/temp/$NEW_BUILD_NAME_AND_VER make install
#if after make you are asked for running 'libtool --finish ...' then do it:
libtool --finish libs
#You'll get something like this:
#Libraries have been installed in:
#   /ffp/home/root/compile/$NEW_BUILD_NAME_AND_VER/libs -> here you'll find libphp5.so and libphp5.la
rm -vr $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
ls -l /tmp/php-*
ls -l ~/ffp_0.7_armv5/packages/php-*
#for the files found below remove the -n or/and -q php's call options:
grep -nr "\s\(-q\|-n\)\s" ffp/bin/
sed -i s/"\s-q"/""/ ffp/bin/peardev
sed -i s/"\s-q"/""/ ffp/bin/pear
sed -i s/"\s-q"/""/ ffp/bin/pecl
sed -i s/"\s-n"/""/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pear
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/peardev
makepkg $NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER $NEW_BUILD_VER 0
cp -v /tmp/php-*.txz $HOME/ffp_0.7_armv5/packages/
funpkg -i $HOME/ffp_0.7_armv5/packages/$NEW_BUILD_NAME_AND_VER-arm-0.txz
 
#AFTER INSTALL
#INSTALL PEAR & PECL
wget http://pear.php.net/go-pear.phar
#go-pear.phar installs also pecl
php go-pear.phar
#ERROR (when running go-pear.phar)
	SHA1 signature could not be verified: broken signature
#SOLUTION
	Don't modify go-pear.phar with "~/x.sh ffpg" command!!!
	Configure php.ini: phar.require_hash = Off.
	Execute with specific php.ini:
	php -c /ffp/etc/php.ini go-pear.phar

#Modify the following /ffp/bin/ files: pear, peardev, pecl, pecl-gen:
##!/bin/sh -> #!/ffp/bin/sh

#USING PECL: https://adrhc.go.ro/wordpress/using-pecl/
#USING PEAR: https://adrhc.go.ro/wordpress/using-pear/

#ERROR (make)
	PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
#SOLUTION (do it after installing pear)
	A part of the solution is to at least install PEAR package PHP_Archive.
	PHP_Archive is required for running phar files (see http://php.net/manual/en/intro.phar.php).

#My personal setup:
pecl channel-update pecl.php.net
pear install --alldeps PHP_Archive-0.11.4
pecl install --alldeps --force APCu-4.0.7
pecl install --alldeps msgpack-0.5.6
pecl install --alldeps --force pthreads-2.0.10

#INSTALL APCu manually (compile or use https://adrhc.go.ro/wordpress/using-pecl/)
cd ~/compile
wget http://pecl.php.net/get/apcu-4.0.7.tgz
tar zxfv apcu-4.0.7.tgz
cd ~/compile/apcu-4.0.7
phpize
./configure --with-php-config=/ffp/bin/php-config --enable-apcu
make install

#dezactiveaza autentificarea in ~/compile/apcu-4.0.7/apc.php: defaults('USE_AUTHENTICATION',0)
#Nu copia apc.php in /i-data/60cb70cf/www/pages/wordpress/wp-content/plugins/wp-apc-panel/include/ pt ca deja exista!
cp -v ~/compile/apcu-4.0.7/apc.php $HOME/tools/

#show php modules
php -m
 
#Using php5_module with Apache:
LoadModule php5_module /usr/local/zy-pkgs/lib/libphp5.so
Link required: /usr/local/zy-pkgs/php/php.ini -> /ffp/etc/php.ini
PHPIniDir /usr/local/zy-pkgs/php
AddHandler php5-script .php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps