Currently Viewing Posts Tagged installation

The simple way to install the dbase extension on php7.0

Here is the simple way to install the dbase extension. One command only.

 

sudo pecl install dbase-7.0.0beta1

It will install the extension for you. You just need to restart php7.0-fpm service.

Check the php information.

If your php is version 5 to 5.7. Change the command to

sudo pecl install dbase

Go to php.net and look at the introduction of dBase section.

This extension has been moved to the PECL repository and is no longer bundled with PHP as of PHP 5.3.0.

That’s why we have to install this extension from pecl installation.

https://pecl.php.net/package/dbase

https://php.net/manual/en/intro.dbase.php

Post your new Blog post notice on Facebook from MovableType

I have a blog which is powered by MovableType.

Everyone use facebook, almost everyone. I think to put a notice on Facebook when I have new post on my Blog is a good idea. So I did a search and finally found this one, FBWallPost.

FBWallPost is build by the same author of PostTwiOauth.

PostTwiOauth is another plugin for MovableType, which is used to publish a tweet on twitter when a new blog post published.

FBWallPost can do the same job, but on Facebook.

The latest version of FBWallPost is v 0.17.

My experience of it is as below:

  • MovableType 6.2.2.
  • Facebook API 2.5

fbwallpost-settings

Continue reading “Post your new Blog post notice on Facebook from MovableType”

Tools to check your SSL Installation

I have tried some tools to diagnose my SSL certificate installation.

Some related to correct certificate, and more on certificate chain issues.

SSL Certificates are trusted from its parent, or issued by its high lever certificate. It looks like a chain, one connect to other one and gos to the CA root.

Say, I have a SSL certificate for domain seo.g2soft.net.

  • Certificate of seo.g2osft.net is issued by Comodo RSA domain Validation Secure Server CA
  • Comodo RSA domain Validation Secure Server CA is issued by Comodo RSA certification Authority
  • Comodo Rsa Certification Authority is issued by AddTrust External CA Root.

The last one, AddTrust External CA Root is one of root CAs.  It is issued by itself. Root Certificates was installed in every computer or browsers already. It is trusted and in the trust store.

certificate-chain

The above is a corrected installation.

Tool One:

Geocerts SSL Checker

https://www.geocerts.com/ssl_checker

Tool Two:

DigiCert SSL Installation Diagnostics Tool

https://www.digicert.com/help/

Continue reading “Tools to check your SSL Installation”

Certificate Installation: NGINX with Comodo SSL

Here is the guide to show you how to install the Comodo SSL certificate in Nginx.

  1. Order Comodo Certificate. And received the Certificate files.
    I don’t discuss how to get it, where to get it. It is another topic. You will receive following files.
    Positive SSL certificate, it is a zip file emailed to you. Unzip it and get four files.
    PositiveSSL-Shalom-Campus1

    • Root CA Certificate – AddTrustExternalCARoot.crt
    • Intermediate CA Certificate – COMODORSAAddTrustCA.crt
    • Intermediate CA Certificate – COMODORSADomainValidationSecureServerCA.crt
    • Your PositiveSSL Certificate – www_example_com.crt (or the subdomain you gave them)
  2. Make the file for Nginx
    cat  www_example_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt > your_domain_crt.pem 

    I just need your certificate and intermediate certificates. Root is already installed in every single computer or browser. The order of certificates is important.

  3. Save this file into the place you want Nginx use
    mv your_domain_crt.pem /etc/nginx/ssl/
  4. Save your private key in the same place
    mv your_domain_key.pem
  5. Make sure your Nginx config file looks like below
    server {
    listen 443 ssl;
    
    ssl_certificate /etc/nginx/ssl/your_domain_crt.pem;
    ssl_certificate_key /etc/nginx/ssl/your_domain_key.pem;
    
    # side note: only use TLS since SSLv2 and SSLv3 have had recent vulnerabilities
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
    # ...
    
    }
  6. Reload Nginx and check if it works by enter https://www.your_domain.com/

How to install HHVM, Nginx, MariaDB in Ubuntu 14.04 LTS

It is just a record for reference.

0) I have my Ubuntu 14.04 installation done on my VirtualBox

512MB memory

1 CPU.

Install Ubuntu 14.04 server with openssh server only. No other server software installed.

1) Install Nginx

Nginx can be found in the Ubuntu repository, but it is often outdated. To get the latest stable version, add the following PPA to system.

sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
sudo service nginx start

The latest version of Nginx as of this post is 1.6.2.

nginx-version

Enter “http://your-ip/” into web browser see the default welcome page.

nginx-welcome

Continue reading “How to install HHVM, Nginx, MariaDB in Ubuntu 14.04 LTS”

Enable jpeg in PHP GD support

I have a PHP 5.5.13 which is compiled from source. With GD support.

I saw some image thumb is not shown in the webpage of Joomla. The error log has following errors:
Call to undefined function: imagecreatefromjpeg()

When I check the phpinfo, I saw GIF enabled, PNG enabled, WBMP enabled, XBM enabled, but jpeg is missing.
gd-without-jpeg
The screenshot above is get from inside of Joomla system information.

I checked the PHP official site. The solution is as below.

1) Make sure JPEG is installed

yum install libjpeg libjpeg-devel

2) Re-compile PHP 5.5.13
Because I make and install PHP just hours ago in the same source folder, I have to clean the folder first.

cd php-5.5.13
make clean

Then, make and install (Because it is a X86 system, or 32bit system, the lib directory is lib, jpeg-dir is /usr/lib)

./configure --prefix=/usr/local/php55 \
    --with-config-file-path=/etc/php55 \
    --with-config-file-scan-dir=/etc/php55/php.d \
    --with-libdir=lib \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi \
    --enable-exif \
    --enable-zip \
    --with-gmp \
    --enable-ftp \
    --enable-shmop \
    --enable-sockets \
    --with-jpeg-dir=/usr/lib
make
make install

It is just a re-compiling for PHP, nothing else changed. So restart Apache to make it effect.

gd-with-jpeg
It is from phpinfo page.

Install XCache 3.1.0 from souce on PHP 5.4.28

I have a staging server. I have installed php5.3, 5.4, and 5.5 on it. Today I tried to install XCache 3.1.0 on it with PHP 5.4.28.

First, I recompiled the PHP 5.4.28 with more features. So noted below:

1) Install additional required dev packages

yum install gmp gmp-devel

2) Compile and install php 5.4.28

cd php-5.5.12
./configure --prefix=/usr/local/php54 \
    --with-config-file-path=/etc/php54 \
    --with-config-file-scan-dir=/etc/php54/php.d \
    --with-libdir=lib64 \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi \
    --enable-exif \
    --enable-zip \
    --with-gmp \
    --enable-ftp \
    --enable-shmop \
    --enable-sockets
make
make install

Restart Apache

service httpd restart

Then, I start to install XCache from source, the latest version of XCache is 3.1.0.

3) Download and decompress it.

wget http://xcache.lighttpd.net/pub/Releases/3.1.0/xcache-3.1.0.tar.gz
tar -xvzf xcache-3.1.0.tar.gz

4) Compile XCache based on current PHP 5.4.28 installation

cd xcache-3.1.0
/usr/local/php54/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php54/bin/php-config
make
make install
cp xcache.ini /etc/php54/php.d/xcache.ini
service httpd restart

Then reload the phpinfo page and get following information.

web2-php54-fastcgi-withxcache

And XCache web interface:

xcache-3.1.0-php5.4.28

Install Multiple Version of PHP on CentOS 6.5 as Fastcgi

It is a guide of how to install multiple version of PHP on CentOS 6.5 64bit. All different PHP as fastcgi.
It is works on Apache, one web server, each virtualhost has its own different php version support.

0) Prepare the testing environment

Disable SELinux and stop iptables. It is for testing environment. For production machine, you should implement firewall carefully.

setenforce 0
service iptables stop

1) Enable rpmforge and epel yum repository

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

2) Install required dev packages and Apache, mod_fcgid

yum install gcc libxml2-devel bzip2-devel zlib-devel \
    curl-devel libmcrypt-devel libjpeg-devel \
    libpng-devel gd-devel mysql-devel
yum install httpd mod_fcgid 

3) Create the system startup links for Apache and start it:

chkconfig --levels 235 httpd on
/etc/init.d/httpd restart 

4) Compile and install php 5.5.12

wget http://us1.php.net/get/php-5.5.12.tar.gz/from/this/mirror
tar -xvzf mirror
cd php-5.5.12
./configure --prefix=/usr/local/php55 \
    --with-config-file-path=/etc/php55 \
    --with-config-file-scan-dir=/etc/php55/php.d \
    --with-libdir=lib64 \
    --with-mysql \
    --with-mysqli \
    --enable-mbstring \
    --disable-debug \
    --disable-rpath \
    --with-bz2 \
    --with-curl \
    --with-gettext \
    --with-iconv \
    --with-openssl \
    --with-gd \
    --with-mcrypt \
    --with-pcre-regex \
    --with-zlib \
    --enable-cgi
make 
make install
mkdir /etc/php55
cp php.ini-production /etc/php55/php.ini

Edit php.ini

vi /etc/php55/php.ini

Add the following in the end of the file

cgi.fix_pathinfo = 1

Restart Apache

service httpd restart

5) Creating Vhosts For web1.example.com

5.1) Create user and group

groupadd web1
useradd -s /bin/false -d /var/www/web1 -m -g web1 web1
chmod 755 /var/www/web1

5.2) Then we create the document roots and make them owned by the users/groups web1:

mkdir -p /var/www/web1/web
chown web1:web1 /var/www/web1/web

5.3) We will run PHP using suExec; suExec’s document root is /var/www, as the following command shows:

[root@localhost ~]# /usr/sbin/suexec -V
 -D AP_DOC_ROOT="/var/www"
 -D AP_GID_MIN=100
 -D AP_HTTPD_USER="apache"
 -D AP_LOG_EXEC="/var/log/httpd/suexec.log"
 -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
 -D AP_UID_MIN=500
 -D AP_USERDIR_SUFFIX="public_html"

5.4) create the wrapper scripts in subdirectories of /var/www/php-fcgi-scripts

mkdir -p /var/www/php-fcgi-scripts/web1
vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter

Enter following into php-fcgi-starter

#!/bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/local/php55/bin/php-cgi

5.5) The php-fcgi-starter scripts must be executable, and they (and the directories they are in) must be owned by the web site’s user and group:

chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter
chown -R web1:web1 /var/www/php-fcgi-scripts/web1

5.6) Create Vhost for web1.example.com

vi /etc/httpd/conf/httpd.conf
[...]
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName web1.example.com
  DocumentRoot /var/www/web1/web/

  <IfModule mod_fcgid.c>
    SuexecUserGroup web1 web1
    <Directory /var/www/web1/web/>
      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/web1/php-fcgi-starter .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

</VirtualHost>

Restart Apache

service httpd restart

5.7) Now we create a small PHP test file

vi /var/www/web1/web/info.php

Add following content into it.

<?php
phpinfo();
?>

6) In Browser, you can see following infomation page.
web1-php55-fastcgi

 

7) Compile and install php 5.4.28 and php 5.3.28

Repeat the step 4, 5, and 6. Just change something respect to php 5.4.28 and php5.3.28.

7.1) php 5.4.28

http://us1.php.net/get/php-5.4.28.tar.gz/from/this/mirror

web2.example.com

/usr/local/php54

/etc/php54

user web2

group web2

web2-php54-fastcgi

 

7.2) php 5.3.28

http://us1.php.net/get/php-5.3.28.tar.gz/from/this/mirror

web3.example.com

/usr/local/php53

/etc/php53

user web3

group web3

web3-php53-fastcgi

Then, I have three hosts on the same one Apache web server at CentOS 6.5 64bit server.

Each host has its own php version installed, from 5.3 to 5.5.

So, you can use the above as a template.

Install multiple version of php on CentOS 6.5

This is a how-to of install php 5.3 an dphp 5.5 on one server, CentOS and use them simultaneously.

It is based on CentOS 6.5, 64bit for Apache only.

1) Enable rpmforge and epel yum repository


wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

 

2) Install php 5.3

CentOS has php 5.3 built-in-box, simply install it with yum


yum install php php-mysql php-mbstring php-mcrypt

3) Compile and install php 5.5 from source

For php 5.5, we prefer to install it from source, the point is to install php at different location, which does not conflict with the php 5.3.

PHP 5.3 is installed as an apache module, we can only use one version of php at the same time. If we need to run different version of php at the same time, fastcgi and php-fpm works on it.

Build and install php 5.5 with fpm enabled, the latest version of php 5.5 is php 5.5.12.

3.1) Install required dev packages

yum install gcc libxml2-devel bzip2-devel zlib-devel \
	curl-devel libmcrypt-devel libjpeg-devel \
	libpng-devel gd-devel mysql-devel

3.2) Compile and install


wget http://ca2.php.net/get/php-5.5.12.tar.bz2/from/this/mirror

tar -xjf mirror

cd php-5.5.12
./configure --prefix=/usr/local/php55 \
	--with-config-file-path=/etc/php55 \
	--with-config-file-scan-dir=/etc/php55/php.d \
	--enable-fpm \
	--with-fpm-user=apache \
	--with-fpm-group=apache \
	--with-libdir=lib64 \
	--with-mysql \
	--with-mysqli \
	--enable-mbstring \
	--disable-debug \
	--disable-rpath \
	--with-bz2 \
	--with-curl \
	--with-gettext \
	--with-iconv \
	--with-openssl \
	--with-gd \
	--with-mcrypt \
	--with-pcre-regex \
	--with-zlib

make -j4 && sudo make install
mkdir /etc/php55
cp php.ini-production /etc/php55/php.ini
sed -i -e 's#php_fpm_CONF=\${prefix}/etc/php-fpm.conf#php_fpm_CONF=/etc/php55/php-fpm.conf#' \
	sapi/fpm/init.d.php-fpm
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod a+x /etc/init.d/php-fpm
/sbin/chkconfig --add php-fpm
/sbin/chkconfig php-fpm on
cp sapi/fpm/php-fpm.conf /etc/php55/

3.3) Configure php-fpm
Edit /etc/php55/php-fpm.conf, change some settings. This step is mainly to uncomment some settings.

vi /etc/php55/php-fpm.conf
pid = run/php-fpm.pid
listen = 127.0.0.1:9000
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15

Then, start php-fpm

/etc/init.d/php-fpm start

3.4) Install and setup mod_fastcgi

yum install libtool httpd-devel apr-devel
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -xzf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
make top_dir=/usr/lib64/httpd/ install
sh -c "echo 'LoadModule fastcgi_module modules/mod_fastcgi.so' > /etc/httpd/conf.d/mod_fastcgi.conf"

4) Prepare hosts and add web sites settings
4.1) Add the following line to /etc/hosts

127.0.0.1 php53.example.com php55.example.com

4.2) Create web document root and drop and index.php under it to show php information.

mkdir /var/www/fcgi-bin
for i in {1..2}; do
	web_root=/var/www/web$i
	mkdir $web_root
	echo "<?php phpinfo(); ?>" > $web_root/index.php
done

4.3) Create Apache config file(append it to httpd.conf)

vi /etc/httpd/conf/httpd.conf

Modify httpd.conf Per below

NameVirtualHost *:80

# module settings
# mod_fastcgi with php-fpm

<IfModule mod_fastcgi.c>
        FastCgiExternalServer /var/www/fcgi-bin/php-fpm -host 127.0.0.1:9000
</IfModule>

# virtual hosts...

#################################################################
#1st virtual host, use mod_php, run php-5.3.3
#################################################################
<VirtualHost *:80>
        ServerName php53.example.com
        DocumentRoot "/var/www/web1"

        <ifmodule mod_php5.c>
                <FilesMatch \.php$>
                        AddHandler php5-script .php
                </FilesMatch>
        </IfModule>

        <Directory "/var/www/web1">
                DirectoryIndex index.php index.html index.htm
                Options -Indexes FollowSymLinks
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

#################################################################
#2nd virtual host, use mod_fastcgi + php-fpm, run php-5.5.12
#################################################################
<VirtualHost *:80>
        ServerName php55.example.com
        DocumentRoot "/var/www/web2"


        <IfModule mod_fastcgi.c>
                ScriptAlias /fcgi-bin/ /var/www/fcgi-bin/
                AddHandler php5-fastcgi .php
                Action php5-fastcgi /fcgi-bin/php-fpm
        </IfModule>

        <Directory "/var/www/web2">
                DirectoryIndex index.php index.html index.htm
                Options -Indexes FollowSymLinks +ExecCGI
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

4.4) Restart apache. Visit these two sites and view phpinfo page.

service httpd restart

http://php53.example.com
php53-example
http://php55.example.com
php55-example

You can use the one of the virtual host as a template to create new virtual host.

How to install Crontab in CentOS 6.5 64bit

Linode default CentOS 6.5 64bit deployment does not include Crontab or Cron Job. Here is a reference for the people like me.

Install the package and dependencies

#yum install vixie-cron

Enable the package on boot and start

# /sbin/chkconfig crond on
# /etc/init.d/crond start

crontab command option:

crontab: usage error: unrecognized option
usage:  crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
(default operation is replace, per 1003.2)
-e      (edit user’s crontab)
-l      (list user’s crontab)
-r      (delete user’s crontab)
-i      (prompt before deleting user’s crontab)
-s      (selinux context)

  • Archives