Currently Viewing Posts in L.A.M.P.

php Benchmark test on php 7.2

Now it is a php 7.2. Included in the Ubuntu 18.04.

My site is running on this platform. I also want to try to run the php Benchmark test, and see how fast it is.

 

--------------------------------------
|        PHP BENCHMARK SCRIPT        |
--------------------------------------
Start : 2018-06-07 11:38:41
Server : webexample.win@50.116.5.237
PHP version : 7.2.5-0ubuntu0.18.04.1
Platform : Linux
--------------------------------------
test_ifelse               : 0.159 sec.
test_loops                : 0.249 sec.
test_stringmanipulation   : 0.394 sec.
test_math                 : 0.284 sec.
--------------------------------------
Total time:               : 1.086 sec.

I ran five times and the average time is 1.113 second.

Compare with the previous PHP.

  • php 7.0, 2.342 seconds
  • HHVM 5.6.99,  1.4 seconds
  • php 5.5, 5.646 seconds
  • php 5.4, 5.417 seconds
  • php 5.3, 6.567 seconds

Continue reading “php Benchmark test on php 7.2”

Color Scheme for the command line of bash

When I install the Ubuntu server and ssh to the server, the default shell is bash.

It looks like below.

I prefer to have a colorful terminal window. So I goole it and find the solution:

  • open ~/.bashrc in an editor
  • copy this and add it at the end of .bashrc file:
PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '

  • save the file and restart bashrc:
source ~/.bashrc

After that, the terminal window changed as below:

The user name, host name, path have different colors.

 

Continue reading “Color Scheme for the command line of bash”

Waiting for the Ubuntu 18.04 LTS

Based on the schedule of release, Ubuntu 18.04 LTS (Bionic Beaver) will be released on April 26, 2018, the day after tomorrow.

Now, my all VPS is running on the Ubuntu 16.04 LTS. LTS is an abbreviation for “Long Term Support”.  An LTS version is released every two years. So after Ubuntu 16.04 LTS, it is Ubuntu 18.04 LTS.  Now all LTS version has five years support.

I can use Ubuntu 16.04 LTS until 2021. Security updates will be released during the time period.

I am waiting for the release of Ubuntu 18.04 LTS. I would like to try it on my staging server, or a virtual machine. Try all my existing web programs on Ubuntu 18.04 LTS. Find the compatible problems then fix them.

Maybe after a few months testing. I am sure there are no issues with it. I will install a new VPS with Ubuntu 18.04 LTS and move the websites to it.

Continue reading “Waiting for the Ubuntu 18.04 LTS”

Extend VirutalBox disk of Ubuntu 16.04

Resize the partition

I have a VM using VirtualBox on Windows 10. The VM was created last year. Now I feel it is too small.  I am going to increased the disk without damaging the data on it.

The basic information of the VM.

  • It is Ubuntu 16.04 server mode. It means no GUI installed.
  • The original disk size is 8GB.
  • VDI disk file.
  • LVM file system was used when I installed the VM.
  • Windows 10 pro (15063.674 build) is the host system.
  • VirtualBox 5.1.28 when I do the following.

I am going to increased the disk size from 8Gb to 12GB.

Step 1: Increase the vdi file.

D:\VirtualBox VM>"C:\Program Files\Oracle\VirtualBox\VBoxmanage" modifyhd "ubuntu 16.04.vdi" --resize 12000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Step 2: Use Gparted CD image to modify the size of partition.

  • Download the latest verion of Gparted v0.30 iso file.
  • Attached the iso file to storage of the VM.
  • Start the VM.
  • Using default option of Gparted tool.
  • The following screen shown in the VM terminal window.

partition with the lockThere are two locks on the partitions, sda2 and sda5.

I have to unlock them first.  Highlight the sda5, right-click and choose Deactivate.

Deactive the partition Continue reading “Extend VirutalBox disk of Ubuntu 16.04”

php-fpm can not use html as php

I have a site, which use nginx as web server and php-fpm as php interpreter. Most of the files use html extension name.

My nginx conf file has following section.

location ~ \.html|php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

But, when I enter the url such as https://example.com/sample.html, whose content is php script. It did not work.

The solution is to change the config of php.

SSH to the VPS.
Edit /etc/php/7.1/fpm/pool.d/www.conf
Find the security.limit_extensions and uncomment it, add html at the end.

security.limit_extensions = .php .php3 .php4 .php5 .php7 .html

After it, reload nginx, all done.

SphinxSearch WARNING: word overrun buffer, clipped!!!

It is a warning information when the cronjob running every night.  This cronjob is used to update or re-index the phpBB powered forum, which is a Chinese forum.

The whole error is a kind of a list of warning with same problem.

WARNING: word overrun buffer, clipped!!!
clipped (len=126, word='请注意只有使用中国付款互联网付款服务支持的中国信用卡和借记卡才可以启动该话务中心的服')
original (len=126, word='请注意只有使用中国付款互联网付款服务支持的中国信用卡和借记卡才可以启动该话务中心的服')
WARNING: word overrun buffer, clipped!!!
clipped (len=126, word='我想不管你后面是因为衣服的问题还是喜欢不喜欢的问题应该不能退了如果当时店里的人已经告')
original (len=126, word='我想不管你后面是因为衣服的问题还是喜欢不喜欢的问题应该不能退了如果当时店里的人已经告')
WARNING: word overrun buffer, clipped!!!
clipped (len=126, word='新的网上申请表含有条形码而这些条形码将可以允许我们电子传输信息从而减少了签证申请过程')
original (len=126, word='新的网上申请表含有条形码而这些条形码将可以允许我们电子传输信息从而减少了签证申请过程')

How to solve the problem with the overrun buffer warning?

Continue reading “SphinxSearch WARNING: word overrun buffer, clipped!!!”

Bashrc is not loading? (Fixed)

I have the .bashrc file, but it is not loading when I connect my VPS through SSH.

The content of .bashrc looks like below:

alias ls='ls --color=auto'
force_color_prompt=yes
PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '

It provides a colorful terminal look.

How to fix the problem of .bashrc not loading?

Continue reading “Bashrc is not loading? (Fixed)”

Make a Bluetooth Speaker with Raspberry Pi with Bluetooth 4.0

I have tried to make a Bluetooth speaker with raspberry Pi three months ago. It was failed because of the old Bluetooth 2.0 USB device. It is too slow to get the smooth audio transferring.

Now I have a new Bluetooth 4.0 USB dongle.

I checked the information from the terminal window.

The procedure of installation is same as the post I posted before.

The dongle I got is $2.99 each. Good price. After I tested it, I can say Good quality.

At DX.com http://www.dx.com/p/ultra-mini-bluetooth-csr-4-0-usb-dongle-adapter-black-143276#.WQ_KC8ZlC70

 

How to connect DBF file and read data by PHP script

Afte last post, my php-fpm support the dbase database file now.  Here is an example php script.

$db = dbase_open('../db/clients.dbf',0);

if ($db){
	$record_numbers = dbase_numrecords($db);
	
	for ($i = 1; $i <= $record_numbers; $i++) {
		  $row = dbase_get_record_with_names($db, $i);
		  if ( strpos(trim($row['CLIENTNAME']), $clientname)  !== FALSE and $row['deleted'] != 1) {
			  	$clientid =  $row['CLIENTID']);
				
				echo 'Customer ID Number: ',$clientid,';
                 }
     }
}

0) The dbase file has two columns, one is CLIENTID, the other one is CLIENTNAME.

1) Open the dbase file, clients.dbf,  by relative path.

2) If the dbf file exists, get the total number of records.

3) Go through all records. If field CLIENTNAME is same as the variable, $clientname,  print client id.

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

  • Archives