Category Archives: software

How to change default editor

Each works well with your favorite text editor. It is important that there is a default editor known. In debian and in other linux distro, default editor is vi.

You could change default editor:

  1. during distro installation
  2. custom each user into .bashrc or .profile file with line:
    export EDITOR=/usr/bin/emacs
  3. custom locally in a shell session and/or particular program:
    env EDITOR=nano crontab -e

crontab

NAME
crontab – maintain crontab files for individual users (V3)
SYNOPSIS
crontab [ -u user ] file
crontab [ -u user ] { -l | -r [ -i ] | -e }

EXAMPLE
Stamp output about crontab file:
crontab -l

Modify crontab with default editor:
crontab -e

yum segmentation fault in centos

After an upgrading with yum program, yum will end with segmentation fault.

Last link about libz is the cause:
-rwxr-xr-x 1 root root  75028  9 gen  2007 libz.so.1.2.3
-rwxr-xr-x 1 root bin   96572  8 nov  2010 libz.so.1.2.5
-rw-r--r-- 1 root bin  101462  8 nov  2010 libz.a
lrwxrwxrwx 1 root root     13  8 apr  2011 libz.so -> libz.so.1.2.3
lrwxrwxrwx 1 root root     13  8 apr  2011 libz.so.1 -> libz.so.1.2.5

libz.so.1 need a different link:
lrwxrwxrwx 1 root root     13  8 apr  2011 libz.so.1 -> libz.so.1.2.3

Reference: yum fails with segfault after source zlib upgrade

Thread Safety in php

Thread safety is a computer programming concept applicable in the context of multi-threaded programs. A piece of code is thread-safe if it only manipulates shared data structures in a manner that guarantees safe execution by multiple threads at the same time.

There have been a few options available for a while to get PHP performing well on linux or IIS.
One solution is to configure web service to use PHP in FastCGI mode which allows PHP processes to be recycled rather than killed off after each PHP request and also allows you to run several PHP processes at once, making PHP much much faster with the added bonus that as it is using the CGI interface there is little or no incompatibility issues with PHP extensions.

The utilization of non thread safe binaries does not allow to use FastCGI mode!

On debian/ubuntu
Thread Safety enable.
# aptitude install apache2-mpm-worker libapache2-mod-fcgid php5-cgi && a2enmod fcgid && /etc/init.d/apache2 restartThread Safety disable.
# aptitude install apache2-mpm-prefork libapache2-mod-php5 && a2dismod fcgid && /etc/init.d/apache2 restart

If your non thread safe binaries software not works, it was because installing apache2-dev package on my system automatically installs apache2-thread-dev whose apxs2 tells the PHP build system to build with thread-safety on. Therefore, the solution was to directly install apache2-prefork-dev package.

Reference: Wikipedia, Tnread Safety dis/able, Install/Purge package

PHPmotion installation

PHPmotion
PHPmotion is a free video sharing software that also has support for other types of media such as audio/mp3 sharing. The Content Managent System or (media cms application) will allow you to create and run your very own Video Sharing website, Music Sharing Site, Picture Sharing Site.

Servers – Linux/Unix server
- PHP 4.3 and above (including support of CLI)
- MySQL database server
- LAME MP3 Encoder
- Libogg + Libvorbis
- Mencoder and also Mplayer
- FFMpeg-PHP
- GD Library 2 or higher
- CGI-BIN
- Be able to run background processes

PHP Settings
- open_basedir = (no value)
- upload_max_filesize = 100M
- post_max_size = 100M
- max_execution_time = 1500
- session.gc_maxlifetime = 14000
- safe_mode = off
- Thread saftery = disabled
- enable_dl = On

Libraries installation
Follow the steps on this page.

phpSHIELD loader
With this error:
PHP script /var/www/*/classes/config.php is protected by phpSHIELD and requires the phpSHIELD loader phpshield.5.3.lin. The phpSHIELD loader has not been installed, or is not installed correctly. Please visit the phpSHIELD php encoder site to download required loader.
Follow the steps on this page.

With this error:
PHP Fatal error: SourceGuardian Loader - This protected script does not support version 5.3.2-1ubu of PHP. Please contact the script author about this problem. Error code [07] in /var/www/*/classes/config.php on line 2
Assuming you have old revision installed, you need to update / upload 4 files from the php5.3 release (or download here)
/classes/config.php
/includes/mp3_id3_utils.php
/addons/customprofile/index.php
/addons/customprofile/pimp.class.php

Other error infamous
White screen

  • The following files MUST be uploaded in Binary mode
    /phpshiled/all files in this folder
    /classes/config.php
    /addons/customprofile/pimp.class.php
    /addons/customprofile/index.php
  • Set error_reporting to E_ALL or into apache configuration
    LogLevel debug
  • Set Thread Safety to disable (follow the steps on this page)
  • Your revision is too old that you must install last revision:
    • Backup your database and /upload and your /themes/*/templates directories
    • Install new release
    • Use old database during new intallation
    • Copy old /upload and your /themes/*/templates directories

Reference: PHPmotion System Requirements, PHPmotion Forum

qmail and simple configuration

qmail is a modern SMTP server and the second most popular MTA on the Internet. A number of large Internet sites are using qmail, Plesk is one. If you are on Plesk control panel, and need to change email account password then changing password from Plesk is a lengthy process.

qmail is installed into /var/qmail or similar. There are more directories, but four are important: bin, control, mailnames and users. bin directory contains all binary programs about manage qmail service. mailnames directory contains all mail divided by domain and user.

qmail-control
If you type this command:
man qmail-controlYou obtain info about files into /var/qmail/control directory.
We analize rejectnonexist, rcpthosts and virtualdomains.

rejectnonexist
File is the list of domains, one per line. qmail-smtpd will reject any envelope recipient address with a domain not listed in rejectnoexist.

rcpthosts
File is the list of domains, one per line. Allowed RCPT domains. If rcpthosts is supplied, qmail-smtpd will reject any envelope recipient address with a domain not listed in rcpthosts. Any details with command line:
man qmail-smptdvirtualdomains
List of virtual users or domains, one per line. A virtual user has the form user@domain:prepend, without any extra spaces. When qmail-send sees the recipient address user@domain, it converts it to prepend-user@domain and treats it as local. Any details with command line:
man qmail-send

qmail-users
If you type this command:
man qmail-usersYou obtain info about files into /var/qmail/users directory: assign and cdb.

assign
List of users addresses. File is a series of assignments, one per line. It ends with a line containing a single dot. Lines must not contain NUL.

cdb
It is a constant database (CDB). CDB is a binary format that can be accessed quickly by qmail-lspawn, even when there are thousands of assignments.

.qmail files
.qmail files contain a list of delivery instructions, one instruction per line. Delivery of a user’s mail is usually controlled by one or more “.qmail” (pronounced dot kyoo mail) files. The pseudo-user on all qmail systems whose home directory is usually /var/qmail/alias. About each user, home directory is usually /var/qmail/mailnames/domain/user/.qmail. Any details with command line:
man dot-qmail

Usage
You could use any programs to manage qmail service. Most popular is vpopmail. vpopmail is a set of API that manages virtual user accounts on a qmail system, and handles delivery for these virtual users. The command-line utilities, and Qmailadmin all use the vpopmail API, provided by the vpopmail library to manage the system. vpopmail does not work with Plesk. So that, you could run the Plesk or qmail commands. Options about Plesk commands line may differ from version to version: we are using v10.3. Any details, you could run each command with –help.

create a domain
If you want configure only domain mail into Plesk,
/usr/local/psa/bin/domain --create pandle.net -dns false -mail_service true -notify false -ip 192.168.1.11
else if you have Plesk panel, you could add new domain out to Plesk and you could add mail into qmail service.
This configuration is available only user with forward because it is disable change password without Plesk or vpopmail.
You must modify five files (assign, cdb, rejectnonexist, rcpthosts and virtualdomains) and create new directory into /var/qmail/mailnames.
/var/qmail/control
If the domain is pandle.net, add domain into files:
echo "pandle.net" >> /var/qmail/control/rejectnonexist
echo "pandle.net" >> /var/qmail/control/rcpthosts
To add domain into virtualdomains, and you are using prefix, you must use new prefix. Plesk uses progressive number like id domain. Show last prefix:
tail -n 1 /var/qmail/control/virtualdomains | awk -F ':' '{print $2}'
If last prefix number is 35, you could use 100 so that you could use again Plesk:
echo "pandle.net:100" >> /var/qmail/control/virtualdomains
/var/qmail/mailnames
mkdir /var/qmail/mailnames/pandle.net
echo "|bouncesaying This\ address\ no\ longer\ accepts\ mail." > /var/qmail/mailnames/pandle.net/.qmail-default
chown -R popuser.popuser /var/qmail/mailnames/pandle.net
chmod -R 700 /var/qmail/mailnames/pandle.net

/var/qmail/users
Show values about qmail user: popuser
grep popuser /etc/passwd
Output could be:
popuser:x:110:31:POP3 service user:/var/qmail/popuser:/bin/false
Add on the top domain line into /var/qmail/users/assign:
nano /var/qmail/users/assign
+100:popuser:110:31:/var/qmail/mailnames/pandle.net:::

Now run qmail-newu: it processes the assign file and generates a new cdb:
/var/qmail/bin/qmail-newu

create an user
If domain and mail are configured into Plesk and you must create new user,
/usr/local/psa/bin/mail --create biliards@pandle.net -passwd mypassword -mailbox true
else if domain and mail are configured into Plesk and you must update only password,
/usr/local/psa/bin/mail -u biliards@pandle.net -passwd mypassword
else if domain and mail are not configured into Plesk, commands are more than one. You must modify two files (assign and cdb) and create new directory into /var/qmail/mailnames/pandle.net. If the user name is biliards, add on the top user line into /var/qmail/users/assign:
nano /var/qmail/users/assign
=100-biliards:popuser:110:31:/var/qmail/mailnames/pandle.net/biliards:::

Now run qmail-newu: it processes the assign file and generates a new cdb:
/var/qmail/bin/qmail-newu
Make the user home directory:
mkdir /var/qmail/mailnames/pandle.net/biliards
mkdir /var/qmail/mailnames/pandle.net/biliards/\@attachments
mkdir /var/qmail/mailnames/pandle.net/biliards/Maildir
mkdir /var/qmail/mailnames/pandle.net/biliards/Maildir/cur
mkdir /var/qmail/mailnames/pandle.net/biliards/Maildir/new
mkdir /var/qmail/mailnames/pandle.net/biliards/Maildir/tmp

Make two files:
cat /var/qmail/mailnames/pandle.net/biliards/.qmail
| true
| /usr/bin/deliverquota ./Maildir

cat /var/qmail/mailnames/pandle.net/biliards/Maildir/maildirsize
0S,0C
0 0

Modify the owner and permissions:
chown -R popuser.popuser /var/qmail/mailnames/pandle.net/biliards
chmod -R 700 /var/qmail/mailnames/pandle.net/biliards
chmod 600 /var/qmail/mailnames/pandle.net/biliards/.qmail
chmod 644 /var/qmail/mailnames/pandle.net/biliards/Maildir/maildirsize

User password is configurable only Plesk or vpopmail programs. So that, if you have other domains configured into Plesk, you must use Plesk commands or you add line to user .qmail file to forward mailing:
cat /var/qmail/mailnames/pandle.net/biliards/.qmail
| true
| /usr/bin/deliverquota ./Maildir
&ittips@pandle.net

create an alias
If domain and mail are configured into Plesk and you must create new user alias,
for example, user biliards and alias bilardi and webmaster,
/usr/local/psa/bin/mail -u biliards@pandle.net -aliases add:bilardi,webmaster
else if you want create only alias about mail already configured,
nano /var/qmail/users/assign
=100-biliards:popuser:110:31:/var/qmail/mailnames/pandle.net/biliards:::

Now run qmail-newu: it processes the assign file and generates a new cdb:
/var/qmail/bin/qmail-newu

To test mail that you created, follow the steps on this page.

Reference: lifewithqmail.org, FAQ, vpopmail, pop account

phpSHIELD Loader

phpSHIELD is a premier php Encoder product. Loaders for phpSHIELD encoded scripts are free to download and install.

Check your servers PHP version. You do this by typing the command:
php -vCheck your system architecture. You do this by typing the command:
uname -i
The result will either be i386 or x86_64. You will need this information to download the correct PHPshield loaders.

Check your PHP extensions_directory. You do this by typing the command:
php -i|grep extension_dirMy path is
extension_dir => /usr/lib/php5/20090626 => /usr/lib/php5/20090626
You must first delete any loaders that may already be in your extensions directory
cd /usr/lib/php5/20090626
rm phpshield.*

Download PHPshield Loaders. You must now download the appropriate PHPshield loader, based on your system architecture. below is a list of the files we have available for download

  • Linux, i386, v5.2.x wget http://downloads.phpmotion.com/phpshield-loaders/32bit/phpshield.5.2.lin
  • Linux, x86_64, v5.2.x wget http://downloads.phpmotion.com/phpshield-loaders/64bit/phpshield.5.2.lin
  • Linux, i386, v5.3.x wget http://downloads.phpmotion.com/phpshield-loaders/linux/i386/ixed.5.3
  • Linux, x86_64, v5.3.x wget http://downloads.phpmotion.com/phpshield-loaders/linux/x86_64/ixed.5.3

v5.2.x
mv phpshield.5.2.lin /usr/lib/php5/20090626/
v5.3.x
mv ixed.5.3 /usr/lib/php5/20090626/
First you need to find out the location of your main php.ini file. This file is the main configuration file for PHP on your server.
You do this by typing the command belowphp -i|grep php.iniYou should get a result that shows something like thisLoaded Configuration File => /etc/php.ini
In the case of our example above, the path we want it /etc/php.ini (others, /etc/php5/apache2/php.ini)
Now run the command below. Remember to use your own php.ini directoy path in the command above
echo "extension=ixed.5.3" >> /etc/php.ini

Restart your web server
/etc/init.d/apache restart
OR
/etc/init.d/apache2 restart

Reference: phpSHIELD PHP encoder, Loaders

FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR Installation

Debian/Ubuntu
apt-get update
apt-get upgrade
apt-get install libjpeg-progs libjpeg62 libjpeg62-dev libsdl1.2-dev php5-dev build-essential subversion ruby libcurses-ruby git-core yasm unzip

Download all the files needed
cd /opt/phpmotion
wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.5.tar.gz
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-10.0.0.0.tar.bz2
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-10.0.0.0.tar.bz2
wget http://downloads.xiph.org/releases/theora/libtheora-1.1beta3.tar.gz
wget http://www8.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

Extract all the files
tar zxvf lame-3.99.5.tar.gz
tar zxvf libogg-1.3.0.tar.gz
tar zxvf libvorbis-1.3.3.tar.gz
bzip2 -cd amrnb-10.0.0.0.tar.bz2 | tar xvf -
bzip2 -cd amrwb-10.0.0.0.tar.bz2 | tar xvf -
tar zxvf libtheora-1.1beta3.tar.gz
tar jxvf ffmpeg-php-0.6.0.tbz2
tar zxvf flvtool2-1.0.6.tgz
tar jxvf essential-amd64-20071007.tar.bz2

Install lame
cd /opt/phpmotion/lame-3.99.5
./configure && make && make install

Install libogg
cd /opt/phpmotion/libogg-1.3.0
./configure && make && make install

Install libvorbis
cd /opt/phpmotion/libvorbis-1.3.3
./configure && make && make install

Install flvtool2
cd /opt/phpmotion/flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Copy Codecs for mplayer
mkdir /usr/local/lib/codecs
mv /opt/phpmotion/essential-amd64-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
We also need to secure the tmp directory
mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp

Install mplayer & mencoder
cd /opt/phpmotion/mplayer
svn update
./configure --enable-jpeg
make && make install

Install AMR (for 3gp conversion)
Debian Lenny and Ubuntu 10.04 users, not install AMR packages
cd /opt/phpmotion/amrnb-10.0.0.0
./configure && make && make install
cd /usr/local/src/amrwb-10.0.0.0
./configure && make && make install

Install libtheora (for ogg video encoding)
cd /opt/phpmotion/libtheora-1.1beta3
./configure && make && make install

Install ffmpeg
cd /opt/phpmotion/ffmpeg/
svn update
Debian Lenny and Ubuntu 10.04 users please use the following configure command:
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-nonfree --enable-libtheora
Debian Etch and Ubuntu 8.04 users please use the following configure command:
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libamr-wb --enable-nonfree --enable-libtheoraUbuntu 7.06 users please use the following configure command:
./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared --enable-libamr-nb --enable-libtheora
Now run these commands:
make
make install
ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
ln -s /usr/local/lib/libamrnb.so.3 /usr/lib/libamrnb.so.3
ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3

Install ffmpeg-php
Debian Lenny and Ubuntu 10.04 users please use the following configure command:
aptitude install php5-ffmpegOthers Debian and Ubuntu users please use the following configure command:cd /opt/phpmotion/ffmpeg-php-0.6.0/
phpize
./configure && make && make install
You now check if there is ffmpeg-php module:
grep -R ffmpeg /etc/php5/*
If there is not, then you now need to add the new ffmpeg-php module to the php.ini file
nano /etc/php5/apache2/php.ini
extension=ffmpeg.so (add this line to the end of the file)

Restart & done
/etc/init.d/apache2 force-reload

Reference: linux.justinhartman.com

Joomla and its customization

Joomla is fantastic because you could add or modify view or calculate intervening into particular events. It only needs to add or modify correct files. If you would like:

  1. modify template
    • creating your template in /templates/your-template-name and
    • overwriting css or html about modules or components
  2. modify modules
    • overwriting html from templates/your-template-name/html
    • from administration, copying module and add it with different parameters
    • copying module and install it as new module
    • changing module by your plugin
  3. add new plugins
  4. add new components

Zoo is a big component. It is so important that it has also more ways to add or modify view or calculate.
If you would like:

  1. modify template
    • from zoo administration interface
    • adding modules into zoo templates (full, related, item, teaser, ..)
  2. modify zoo component
    • from /media/zoo/applications with applications.php files
    • and all final files about full, related, item, teaser, .., templates

Joomla – Plugin load module into article

Load Module plugin
You will usually want to associate modules with articles in some way. The modules are allocated to module positions and the module positions appear somewhere on the Web page as determined by the template. However, it is sometimes useful to have a module actually embedded within the article.

To insert a module inside an article, use the {loadposition xx} command, as follows:

1. Create a module and set its position to any value that doesn’t conflict with an existing template position. You can type in the position value instead of selecting it from the drop-down list. For example, use the position myposition.
2. Assign the module to the Menu Items that contain the articles that you want the module to show in. You can also just assign the module to all Menu Items.
3. Edit the articles where you want this module to appear and insert the text
{loadposition myposition}
in the article at the place where you want the module.

Note that this only works when the Content – Load Module plugin is enabled. If this plugin is disabled, the text {loadposition myposition} shows unchanged in the article.

Load module into article
This plugin loads any module into an article.
Syntax in editor:
{module [27]}
where 27 is the modules id.

Modules Anywhere
With Modules Anywhere you can include a single module or complete module positions anywhere in your site, including inside 3rd party components and even inside other modules.

Why use Modules Anywhere, and not the {loadposition} plugin?
* It works anywhere, not only in articles. It even works in modules!
* You can load a single module, not only complete module positions.
* You can control the html display style from within the tag, not only one global setting.
* You have some security setting, so you can disable this feature for lower user types.
* It comes with a very easy to use editor button.

You can set Modules Anywhere to also handle the {loadposition} tags. In that case, you can safely disable the {loadposition} plugin all together.

Modules Anywhere does not show unpublished Modules by default. If you do want it to, you can change that behavior through the plugin parameters.

Load module into zoo
To load module into zoo content, you could use Modules Anywhere or modify template about zoo.
If you want load module into product catalog, then you could implement ProductApplication class as JPATH_BASE.DS.’plugins’.DS.’content’.DS.’loadmodule.php’ module (with function that return text modified) and use it into template file JPATH_BASE.DS.’media/zoo/applications/product/templates/default/renderer/item/full.php’ with
ProductApplication::your_function($html_content)
where your_function is public function that you implemented (as plgContentLoadModule about loadmodule.php) and $html_content is variable that contain your {loadposition xx}.

Reference: docs.joomla.org, Load module into article, Modules Anywhere