Compile Phalcon Extension on Centminmod

Wow, almost a year I didn’t touch this blog. At least this blog still have visitor from nowhere πŸ™‚

Ok, today I have challenge to install phalcon php extension (at the moment the version is 3.4.2). The vps server already has centminmod installed using latest version of CentOS 7.

Since the server is critical so I decide to use other vps server (get free $25 in credit for new user here) to get the recipe and share it here for others that might need it.

Lets get start!

Update CentOS

# yum update

Check current php version

# php -v

PHP 7.0.33 (cli) (built: Feb 16 2019 10:38:06) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

Yes, this legacy app run on php 7.0.33

Compile Phalcon php

# git clone --branch v3.4.2 --depth=1 "git://github.com/phalcon/cphalcon.git"

# cd cphalcon/build/

# ./install

Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
appending configuration tag “CXX” to libtool
mkdir .libs
gcc -I. -I/root/cphalcon/build/php7/64bits -DPHP_ATOM_INC -I/root/cphalcon/build/php7/64bits/include -I/root/cphalcon/build/php7/64bits/main -I/root/cphalcon/build/php7/64bits -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DPHALCON_RELEASE -DHAVE_CONFIG_H -march=native -mtune=native -O2 -fomit-frame-pointer -c /root/cphalcon/build/php7/64bits/phalcon.zep.c -fPIC -DPIC -o .libs/phalcon.o

gcc -shared .libs/phalcon.o -march=native -mtune=native -Wl,-soname -Wl,phalcon.so -o .libs/phalcon.so
creating phalcon.la
(cd .libs && rm -f phalcon.la && ln -s ../phalcon.la phalcon.la)
cp ./.libs/phalcon.so /root/cphalcon/build/php7/64bits/modules/phalcon.so
cp ./.libs/phalcon.lai /root/cphalcon/build/php7/64bits/modules/phalcon.la
PATH=”$PATH:/sbin” ldconfig -n /root/cphalcon/build/php7/64bits/modules
———————————————————————-
Libraries have been installed in:
/root/cphalcon/build/php7/64bits/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/
Installing header files: /usr/local/include/php/

Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation

Enable phalcon extension

# nano /etc/centminmod/php.d/phalcon.ini

fill with this line :

extension=phalcon.so

save the file and restart

# nprestart

Check if phalcon extension installed

echo ‘<?php phpinfo();?>’ > /usr/local/nginx/html/info2.php

then access it with browser

or using command line

# php -m | grep phalcon

Handling rewrite problem

“Mod-Rewrite is not enabled

Please enable rewrite module on your web server to continue”

# nano /usr/local/nginx/conf/conf.d/learn.digitalfusi.com.ssl.conf

Change these sections :

1. root /home/nginx/domains/url/public/public;
2. try_files $uri $uri/ /index.php?_url=$uri&$args;

save.

Update 1 :

section 2 need to update as this :

try_files $uri $uri/ @rewrite;

and make new section for @rewrite :

location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
} #rewrite

Update 2 :

Handling error message :

“warning: Remote branch v3.4.3 not found in upstream origin, using HEAD instead”

wget -c https://github.com/phalcon/cphalcon/archive/v3.4.3.tar.gz

tar xvzf v3.4.3.tar.gz

cd cphalcon-3.4.3/build/

./install

Try if rewrite rule work

Edit controller file

# nano /home/nginx/domains/url/public/app/controllers/IndexController.php

Modify the content to this

<?php

class IndexController extends ControllerBase
{

public function indexAction()
{

}

public function testAction($id1,$id2,$id3)

{
echo ‘really nice bro ‘.$id1.’ var 2 :’.$id2.’ var 3 : ‘.$id3;
}
}

save the file.

Access the address from browser

https://url/index/test/d/e/f

and the output will be

really nice bro d var 2 :e var 3 : f

Great, since the value of d,e and f printed correctly then rewrite rule work perfectly.

Note :

  • I upload sample project inside public folder so for root (document root) I change it to public/public.
  • url in this note is depend on you. It might be tld os subdomain
  • I enable https by default so I only deal with ssl.conf file
  • webtools only available from localhost, enable it from cmd -> phalcon project projectname –enable-webtools
in Blog | 819 Words

UpCloud review : another FreeBSD supported VPS

My friend ask me to try upcloud and want me to recap my review in pictures as usual. Well, after use his referrall link (I got free $25 in credit plus $10 in deposit to lift trial limitation) I’m ready to go πŸ™‚

My observation for upcloud

Pros

#1 Easy to use interface

I have no problem in using their UI. Separation important feature are well organized (ssh key, initialization scripts).

#2 Fast Server

I use freebsd ports to compile a stack (famp) and seem to work well. I think they use newer hardware that accelerate well.

#Backup system

smooth daily backup, very important for me.

#3 Many europe zone

I just realize if Helsinki exist.

#4 Good internal IP

I’ve just found out that internal ip is work for my limited vpn stuff.

#5 Timezone

It will eliminate the step for change date during post install process.

#6 Reverse DNS name

Handy for dns related configuration.

#7 FreeBSD support

Yes, the OS available under OS Template -> CDROM

FreeBSD 11.0-RELEASE amd64 Installation CD

 

Cons

#1 No Paypal

My bad, looks like it supported now πŸ™‚

#2 no OpenBSD, DragonFlyBSD and NetBSD support

I hope they can add those OS on CDROM collection or just enable custom CDROM like vultr did.

#3 No reinstall option

I hope they can add this feature soon

#4 No block or storage support

I hope they will add ‘space’ or block like DigitalOcean.

#5 No TFA login

Add more security for us please.

Overall its good service and with Nokia spirit I hope they can grow bigger like others so we can get more reliable provider in the future.

If you want to try upcloud then you can use my referrall link and get free $25.

Install Ted on Centos 7.4

Long time hiatus πŸ™‚ . Yes, being busy with unnecessary things but its fine I come back after a year hahaha.

Today I want to share proces for install Ted, I need this for rtftopdf purpose. rpm file not work for my case since I use latest CentOS (7.4 at this moment).

The install process is straight, lets get start!

Install required tools

yum install gcc gcc-c++ autoconf automake libXpm-devel pcre-devel
zlib-devel ImageMagick libtiff-devel libpng-devel libjpeg-devel gtk+
gtk+-devel gtk2-devel zlib-devel libpng-devel libjpeg-devel gtk2-devel

Get latest Ted and install

wget http://ftp.nluug.nl/pub/editors/ted/ted-2.23.src.tar.gz

tar xvzf ted-2.23.src.tar.gz

cd Ted-2.23/
make
make package
make install

which Ted
/usr/bin/Ted

To get rtf2pdf work you’ll need ghostscript

Install Ghostscript

yum install ghostscript

Download rtf to pdf

wget http://ftp.nluug.nl/pub/editors/ted/rtf2pdf.sh

Done.

Free $20 for DevOps Class – openbsd, freebsd, dragonflybsd and netbsd vps

Update : The offer seem no longer available.

I have to prepare for new class that required vps access. The class will teach unix based system like openbsd, freebsd, dragonfly bsd plus netbsd in 12 meets.

This class will be basic for devops but most important thing for me is my student can get full environment in every OS. Vps came to my mind and this March 2017 is really great since Vultr announce great news :

They double everything and they also provide ‘sanbox plan’ for beginner.

In nutshell you’ll get 1GB memory and 25Gb space vps on the OS you choose. SSD speed also superb :

dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync
16384+0 records in
16384+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.87756 s, 277 MB/s

For limited time Vultr offer free $20 that you can use for many things;

  • Set git server using gitlab.
  • Set up aws compatible cloud with minio
  • Testing zfs latest FreeBSD 12 vs Hammer in dragonflybsd
  • Tes mysql replicate while setting master in Germany Vps and mysql slave in Paris or Amsterdam.

Long time ago I’ll need $10 server to achieve that but now I just need $5 vps server /mo to get 1GB server which is awesome πŸ™‚

I just spread the news to let others know and grab your free $20 by using this link.

Long live the queen!

in Blog | 221 Words

Install Laravel Valet on macOS Sierra

Just quick note for myself when try Laravel Valet on macOS Sierra (10.12.2)

InstallΒ  homebrew (if not installed) :

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Install PHP 7.1

Libpng

brew link libpng

Linking /usr/local/Cellar/libpng/1.6.28… 18 symlinks created

brew install homebrew/php/php71

test :

php -v

PHP 7.1.0 (cli) (built: DecΒ  2 2016 11:32:42) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies

Install Composer

brew install composer

Install Valet

composer global require laravel/valet
cd
nano .bash_profile

Add this line :

export PATH=$PATH:~/.composer/vendor/bin

save.

source .bash_profile
echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/alamsyahrasyid/.composer/vendor/bin

valet install

Password:
[nginx] is not installed, installing it now via Brew… ?
[dnsmasq] is not installed, installing it now via Brew… ?

Valet installed successfully!

Start valet

valet start

Valet services have been started.

Install mysql

brew install mariadb
brew services start mariadb

 

in Blog | 163 Words