PHP Warning: PHP Startup: Unable to load dynamic library /usr/lib64/php/ modules/zip.so

CentOS 7 with PHP

# php --ini
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/zip.so’ – /usr/lib64/php/modules/zip.so: undefined symbol: php_pcre_exec in Unknown on line 0
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/10-opcache.ini,
/etc/php.d/20-bcmath.ini,
/etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
.
.
.

Install Apache, MySQL, PHP 5.6 on Centos 7

Solution

# yum install php-zip

# service httpd restart
Redirecting to /bin/systemctl restart httpd.service

PHP Check Loaded Modules

# php -m
[PHP Modules]
apc
apcu
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
json
libxml
mbstring
mcrypt
memcache
memcached
mhash
mongo
msgpack
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
recode
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
SQLite
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

PHP Check Loaded ini files
# php --ini

# php -v
PHP 5.6.31 (cli) (built: Jul 6 2017 08:06:11)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

Install Apache, MySQL, PHP 5.6 on Centos 7

Install Apache

# yum update
# yum install httpd
# systemctl start httpd.service

Now Browser your Apache Server http://Server_IP_address/

Enable Apache to start at server boot

# systemctl enable httpd.service

Install Mariadb MySQL

# yum install mariadb-server mariadb
# systemctl start mariadb
# mysql_secure_installation

Enable MySQL to start at server boot

# systemctl enable mariadb.service

Install PHP 5.6

Install EPEL repository

# rpm -Uvh http://vault.centos.org/7.0.1406/extras/x86_64/Packages/epel-release-7-5.noarch.rpm

Note: Make sure you installed “epel-release-7-5.noarch.rpm” else google it for different location …. search on Google “index of” + epel-release-7-5.noarch.rpm

Install remi repository

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

Note: Make sure you installed “remi-release-7.rpm” else google it for different location

Enable remi

# yum --enablerepo=remi,remi-php56 install php php-common

Install php 5.6 on Centos 7

# yum --enablerepo=remi,remi-php56 install php-cli php-pear php-pdo php-mysql php-mysqlnd php-pgsql php-sqlite php-gd php-mbstring php-mcrypt php-xml php-simplexml php-curl php-zip

# systemctl restart httpd.service
# chown -R apache:apache /var/www/html/

# chmod -R 775 /var/www/

<?php phpinfo(); ?>

http://Server_IP_address/phpinfo.php

CentOS 7 + SELinux + Apache + PHP write/access permission

CentOS 7 have SELinux, it is security enhancement to Linux which allows users more control over access control.

SELinux make problem to access or write files or directories

– Can’t serve files on directory
– Can’t write to file

SELinux is blocking the read/write operations

# chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/ (if you want to allow full web root)

# chcon -Rv --type=httpd_sys_rw_content_t /var/www/html/uploads/ (Or just uploads folder)

Ownership
# chown apache:apache -R /var/www/html/

Recursive File permissions
# find . -type f -exec chmod 0644 {} \;

Recursive Directory permissions
# find . -type d -exec chmod 0755 {} \;

Resursive SELinux serve files off Apache
# chcon -t httpd_sys_content_t /var/www/html/ -R

Allow write to specific directories
# chcon -t httpd_sys_rw_content_t /var/www/html/logs/ -R
# chcon -t httpd_sys_rw_content_t /var/www/html/uploads/ -R

httpd_sys_content_t – allow Apache to serve contents
httpd_sys_rw_content_t – allow Apache to write to those path.

Creating Zip Without Recording ROOT Paths

Simply use chdir() to change the working directory before you exec()

Or you can use ….

exec(“cd /var/www/html/media; zip -r -9 Media.zip . 2>&1”, $log);

exec(“mv /var/www/html/media/Media.zip /var/www/html/Media.zip”);

Get zip file size

exec(“ls -ls /var/www/html/Media.zip | awk ‘{print $6}’ 2>&1”, $size);

$zipsize = implode(” “, $size);

Without this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 15:10 /var/www/html/media/dialogs/
125305 08-07-12 16:31 /var/www/html/media/dialogs/1.3.mp3
125305 08-07-12 16:33 /var/www/html/media/dialogs/1.5.mp3
184864 08-07-12 16:32 /var/www/html/media/dialogs/1.4.mp3
125305 08-07-12 16:30 /var/www/html/media/dialogs/1.1.mp3
125305 02-24-13 16:48 /var/www/html/media/dialogs/1.2.mp3
125305 08-07-12 16:34 /var/www/html/media/dialogs/1.6.mp3

With this solution

Length Date Time Name
——– —- —- —-
0 03-08-13 16:40 dialogs/
125305 08-07-12 16:51 dialogs/1.3.mp3
125305 08-07-12 16:53 dialogs/1.5.mp3
184864 08-07-12 16:52 dialogs/1.4.mp3
125305 08-07-12 16:50 dialogs/1.1.mp3
125305 02-24-13 16:58 dialogs/1.2.mp3
125305 08-07-12 17:04 dialogs/1.6.mp3

PHP Run Background Process using Exec

If you need to start process in background and get its PID to manage it later using PHP.

<?php

function runInBackground($command,$log,$priority=0)
{
if($priority)
   $PID=shell_exec("nohup nice -n $priority $command > $log 2>&1 & echo $!");
else
   $PID=shell_exec("nohup $command > $log 2>&1 & echo $!");
return($PID);
}

?>
PHP Process
PHP Process

echo $! will return process ID
# Command & echo $!

 

Check if process is running

<?php

function isProcessRunning($PID)
{

if($PID==0)return false;
if($PID=="")return false;

exec("ps -p $PID 2>&1",$state);
return(count($state)>=2);

}

?>

 

Display Process Logs

<?php

function displayProcessLog($logfile)
{

exec('cat $logfile 2>&1',$log);
return implode("\r\n",$log);

}

?>

 

Kill Process

<?php

function killProcess($PID)
{
 exec('kill '.$PID.' 2>&1',$status);
 return implode("\r\n",$status);
}

?>

 

Save Process ID to file

#!/bin/bash
Command &
echo $! >/path/to/pid.file

Install Apache, PHP, MySQL on HP Cloud

I am playing with all cloud services these days, so today we will try to setup Apache, PHP, MySQL on HP Cloud. HP Cloud is based on OpenStack Compute

Hope you already read our old article “Installing Apache, MySQL, PHP in CentOS 5.5 on Rackspace Cloud”?

In the HP Cloud Console Area you can manage

– Servers / Storage
– Floating IPs
– Images
– Key Pairs
– Security Groups
– Volumes

First you need to create Key Pairs and some rule in security default group…

Security Group Rules
Security Group Rules

HP Cloud Compute Overview

HP Cloud Object Storage Overview

You can start any type of server CentOS, Ubuntu using HP Cloud GUI …

Server on HP Cloud
Server on HP Cloud

Also you can manage running instances easily…

Manager Server on HP Cloud
Manager Server on HP Cloud

You can connect to server using SSH on port 22

# ssh -i KEYPair.pem root@IP-Address

In windows.. create PPK file from PEM Keypair using PuTTYgen

Install Apache

# sudo yum install httpd mod_ssl

Install MySQL

# yum install mysql mysql-server
# /etc/init.d/mysqld start

Install PHP

# yum install php php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml php-mbstring

# /etc/init.d/httpd start

You can access HP Cloud using HP Cloud Services APIs and HP Cloud Services CLI

FFmpeg – ERROR: librtmp not found

I was installing FFmpeg for segmenting Red5 Streams to stream live video from Red5 Server to iOS or Android devices.

RTMP (Red5) -> FFMpeg -> Segementer -> .ts files -> iOS (m3u8)

I really needed mp4 (AAC/H.264) and ogg (Vorbis/Theora) format for best HTML5 output.

I checkout FFmpeg source and tryed below command to install / configure it

# ./configure –enable-gpl –enable-nonfree –enable-libmp3lame –enable-libfaac –enable-librtmp –enable-libtheora –enable-libvorbis –enable-libx264 –enable-shared –enable-postproc

error while loading shared libraries: libfaac.so.0:

I have already installed all dependencies, but links to shared libraries was not found … so …

# echo “/usr/local/lib” >> /etc/ld.so.conf
# echo “/usr/lib” >> /etc/ld.so.conf
# ldconfig

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.

Another error ERROR: librtmp not found

# ls /usr/local/lib/librtmp*

/usr/local/lib/librtmp.a /usr/local/lib/librtmp.so

On CenOS before compiling ffmpeg, make sure you have valid path of packages in PKG_CONFIG_PATH

# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

We worked on RTMP (Live Red5 CAM) to iOS (iPhone or iPad). Get more help for HTTP Live Video Stream Segmenter and Distributor Contact Us

Read more…. VOD to iOS | Red5 Media Server iOS Android Setup

Recover MySQL root Password

1. Stop the MySQL server.

# /etc/init.d/mysql stop

2. Start the MySQL server process with the –skip-grant-tables option so that it will not prompt for password.

# mysqld_safe –skip-grant-tables &

3. Connect to mysql server as the root.

# mysql -u root

mysql password
mysql password

Welcome to the MySQL monitor….
………..
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>

4. Setup new mysql root account password i.e. reset mysql password.

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

5. Exit and restart the MySQL server.

# /etc/init.d/mysql stop

6. Start MySQL server.

# /etc/init.d/mysql start
# mysql -u root -p

 

 

Install ImageMagick

ImageMagick can be installed on Windows, Unix and Unix-like operating systems including Linux, Solaris, FreeBSD, Mac OS X, and others.

How to Install Imagemagick?
How to Install Imagemagick?

Note: Make sure you have installed GhostScript and FreeType already 😉
More help https://www.svnlabs.com/blogs/install-openmeetings/

Download & Unpack

# wget http://www.imagemagick.org/download/ImageMagick.tar.gz
# tar xvfz ImageMagick.tar.gz

Configure

# cd ImageMagick-6.8.0-4 (or current version)
# ./configure

Build

# make

Install

# make install

Commands

[root@svnlabs ImageMagick-6.8.0-4]# which convert
/usr/local/bin/convert

[root@svnlabs ImageMagick-6.8.0-4]# which display
/usr/local/bin/display

Use ImageMagick to convert, edit, or compose bitmap images in a variety of formats. In addition, resize, rotate, shear, distort or transform images automatically.

Red5 Media Server iOS Android Setup

Hope you already read our previous article “VOD to iOS” ?

 

How you can use Red5 Server for streaming to iPhone, iPads and Android?

S V N Labs Softwares implements an iOS/Android add-on setup for Red5 Server to stream both Flash, iOS and Android devices. This add-on also supports setup of JW Player, Flowplayer and HTML5 embed player using Red5 live and on-demand streams. We are expert in setting up Red5 applications and developing custom apps and plug-ins for Red5 and other media servers including Wowza, Flash Media Server, Union etc.

Red5 Recorder allows wordpress users to easily use Red5 Recorder Player on their website to record Video / Audio Streams.
Users can record their video response / review using embedable red5 recorder and after recording they can send video email to wordpress admin. Both user and admin will get email from Red5 Recorder system to get Red5 Recorded Video Streams.

Red5 includes support for the latest multi-user API’s including NetConnection, NetStream and SharedObject’s while providing a powerful RTMP / Servlet implementation. In addition to support for the RTMP protocol, the application server has an embedded Tomcat Servlet container for JEE Web Applications. Application development draws additional benefits from the Spring Framework and Scope based event driven services.

Open Source Red5 Media Server also help you for developing extensible platform that can be used in Video Conferences, Multi-User Gaming and Enterprise Application Software. S V N Labs Softwares are also expert in RED5 and most other media servers including Wowza, Flash Media Server, Union etc. and we can assist to set up transcoding, segmenting, and ipad/iphone/android server-side configuration.

Get more help for HTTP Live Video Stream Segmenter and Distributor Contact Us