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 :

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

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 | 783 Words

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

How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 2 – TLS & Unix Auth

In 1st part of this post I have very general setting for pure-ftp configured. In this post we’ll explore about testing functionality of this ftp server using simple auth plus how configure TLS section.

To test the server I need to add user. I used to use sysinstall for this purpose but since sysinstall no longer available on FreeBSD then I use bsdconfig.

Introduce bsdconfig

From bsconfig manual :

bsdconfig is used to set up many system configuration settings, both for
new systems, as well as changing configuration settings of existing systems.

bsdconfig optionally takes    a command as an    argument.  If invoked with no arguments,
it will bring up an interactive    menu listing the available modules.

I like gui version so I type bsdconfig or you can use full path : /usr/sbin/bsdconfig

If not available you can install it.

From ports

# /usr/ports/sysutils/bsdconfig && make install

From pkg

# pkg install bsdconfig

For pure-ftp purpose I need bsdconfig for add new user :

#bsdconfig

Choose “Login/Group Management”

bsdconfig as sysinstall replacement

Continue reading

in Blog | 800 Words

How to install latest WordPress on FreeBSD 10 : enable web server

In my last post I decide to investigate how to install wordpress on FreeBSD 10 (latest version of FreeBSD at the moment). I use two methods of installation; first using ports and second using pkg. After try it myself I prefer to use pkg for future deployment for following reason :

  1. Fast installation; you don’t have to wait for hours as you did with ports.
  2. More secure; you have binary package. No need for compiler stuff installed in my server.

Of course ports can supply you with so many different options with its dialog but as Michael W Lucas said, he prefer to do other job that pay his bills than watch compile process. Me too 🙂

Ok, back to wordpress. Last install is not complete one as I don’t see web server and database.

pkg info result

# pkg info

ca_root_nss-3.17.1             The root certificate bundle from the Mozilla Project
curl-7.38.0_2                  Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
freetype2-2.5.3_2              Free and portable TrueType font rendering engine
jpeg-8_5                       IJG’s jpeg compression utilities
kbproto-1.0.6                  KB extension headers
libICE-1.0.9,1                 Inter Client Exchange library for X11
libSM-1.2.2_2,1                Session Management library for X11
libX11-1.6.2_2,1               X11 library
libXau-1.0.8_2                 Authentication Protocol library for X11
libXaw-1.0.12_2,2              X Athena Widgets library
libXdmcp-1.1.1_2               X Display Manager Control Protocol library
libXext-1.3.2_2,1              X11 Extension library
libXmu-1.1.2_2,1               X Miscellaneous Utilities libraries
libXp-1.0.2_2,1                X print library
libXpm-3.5.11_2                X Pixmap library
libXt-1.1.4_2,1                X Toolkit library
libpthread-stubs-0.3_6         This library provides weak aliases for pthread functions
libxcb-1.10_2                  The X protocol C-language Binding (XCB) library
libxml2-2.9.1_1                XML parser library for GNOME
pcre-8.35_1                    Perl Compatible Regular Expressions library
php5-5.4.33_1                  PHP Scripting Language
php5-curl-5.4.33_1             The curl shared extension for php
php5-gd-5.4.33_1               The gd shared extension for php
php5-mysql-5.4.33_1            The mysql shared extension for php
php5-tokenizer-5.4.33_1        The tokenizer shared extension for php
php5-xml-5.4.33_1              The xml shared extension for php
php5-zip-5.4.33_1              The zip shared extension for php
pkg-1.3.8_3                    Package manager
png-1.5.18                     Library for manipulating PNG images
printproto-1.0.5               Print extension headers
t1lib-5.1.2_4,1                Type 1 font rasterization library for Unix/X11
wordpress-4.0,1                State-of-the-art semantic personal publishing platform
xextproto-7.3.0                XExt extension headers
xproto-7.0.26                  X11 protocol headers

Lets continue : Continue reading