Showing posts with label centos. Show all posts
Showing posts with label centos. Show all posts

Saturday, March 27, 2010

Installing PHP 5.3.x on RedHat ES5, CentOS 5, etc

Some cases arise when we want to upgrade php and we do not want to affect any dependencies it has.

Obviously we can use YUM for this ;)
The step below will upgrade your php with all it dependencies to latest version. We have 5.3.1 at the moment.

To install PHP 5.3.1 (latest version) you can make use of a RPM repository maintained by Remi. We will cover here for ES5 stuff.
So first of all we will need to get the latest remi release
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm 
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
You now have the Remi repository on your system, however it is disabled by default. Obviously you don’t want all of your packages been effected by this repository, however to enable it for a specific package, run the following:yum --enablerepo=remi update php
Now you can just run 
php -v
This will give you the version of php.
You can now restart your server.

Upgrade to PHP 5.2.10 - CentOS5 using YUM


There is a version of PHP (5.2.10) in CentOS’s Testing repository. You could either download each rpm and install, or set up your yum to install from the testing repository.
Install the testing repository’s GPG key:
rpm --import http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
And download the CentOS-Testing repo file:
cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
Now you can install/update to PHP 5.2.10 by running
yum --disablerepo=* --enablerepo=c5-testing update php

Thursday, February 18, 2010

CentOS Sendmail error /etc/mail/submit.cf: line 544: --- Group writable directory

I was getting this error, when tried to send mail via SendMail server.
/etc/mail/submit.cf: line 544: fileclass: cannot open '/etc/mail/trusted-users': Group writable directory
Sendmail is default mail server for CentOS.

To test sendmail from ssh, use this:
echo "test" | mail -s testsubject abc@xyz.com
(replace abc@xyz.com with your email address, like hotmail or gmail etc.)

On doing this I was getting the above mentioned error.
Some forums said that the issue is because of permission problems. So run following command:
chmod -R 0755 /etc/mail
It will set 755 rights to all files in this folder.
It works in some cases but in my case it wasn't.

The solution for this is to edit the respective file, like /etc/mail/submit.cf
You can use vi to edit this.
Jump to line number mentioned in error. 544 in our case.
(Note: To see line numbers in vi, press Ctrl+G to get the line number of your cursor)
This is the line:
Ft/etc/mail/trusted-users
Now just change it to:
Ft-o /etc/mail/trusted-users

Done. Now try send the mail and it will work.

In some case the error line number and file changes, like e.g.
/etc/mail/sendmail.cf : line 91 : fileclass : Cannot open '/etc/mail/local-host-names' : World writable directory
Or
/etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': World writable directory
Etc etc..

Same procedure will be applied to this. Go to respective file and respective line number.
And you will find either Ft or Fw in start
Just add -o after Ft or Fw like Ft-o /etc.... and Fw-o /etc...

This should solve the issue...

Monday, January 18, 2010

Enable SOAP on CentOS / Fedora

CentOS, Fedora comes with a really good tool YUM.

yum is a software package manager. It is a tool for installing, updating, and removing packages and their dependencies on RPM-based systems. It automatically computes dependencies and figures out what things should occur to install packages. It makes it easier to maintain groups of machines without having to manually update each one using rpm.

So we will use yum to install our SOAP extension. Which we didn't enable while compiling php.

First of all you must be logged in with root.
If you are not you can use su to jump to root.

Now type:
yum install php-soap
This is all you have to do.
If you want to update soap, use this:
yum upgrade php-soap
And to remove it use:
yum remove php-soap
It is far better to recompile php ;)



Saturday, November 21, 2009

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/ffmpeg.so'


While Installing FFMPEG, when I was installing ffmpeg-php, I got this warning and it didn't work any further.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/ffmpeg.so' - /usr/lib/php/modules/ffmpeg.so: undefined symbol: le_ffmpeg_frame in Unknown on line 0


Tried to find the solution but didn't get any help. So I ended up reinstalling with different changes and using different guides. Following changes helped:::

First of all get 0.6.0 version, i.e ffmpeg-php-0.6.0.

Now after download: use vi to edit the ffmpeg_frame.c and search and replace PIX_FMT_RGBA32 with PIX_FMT_RGB32
To do this run the following commands:


cd ../ffmpeg-php-0.6.0
vi ffmpeg_frame.c
Now run this command:
:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

Now run ./configure && make && make install

This should solve the problem. Worked for me.


Installing FFMPEG on Centos

This is a bit troublesome work. I spent around 9 hours banging my head with ffmpeg and did many tries to install this. And there are alot of guides for this and ***I was honored*** to install using a few of them :P. I am compiling here the set of commands that worked for me and I will also include a few alternatives in some cases and solutions to some problem which may arise.

/*********Only for beginners***********/
First of all a very little introduction to installing FFMPEG. We will be follow these procedures:
  1. We will first download the required packages (different libs and extensions). These include::: mplayer, flvtool2, lame, libogg, libvorbis, ffmpeg-php etc.
  2. The above packages are in compressed form so we will uncompress those.
  3. The uncompressed set of files are source for those, so we will compile and build them.
  4. At the end we will configure these with our apache.

To download wget is used.
e.g. wget --no-check-certificate https://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
To extract, we use:
tar -xjf amrwb-7.0.0.3.tar.bz2 etc
To compile we use:
./configure
make
make install
This will make its binaries.
/******end of Only for beginners******/

/******Real stuff starts here*********/

First of all get all the packages we need:
//Better make a separate folder for this stuff here:::
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget --no-check-certificate https://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
wget http://biznetnetworks.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz
wget http://jaist.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.4.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.3.tar.gz
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2
(If any of the above links are expired, you may just search google for these, but prefer using the latest version. An IMPORTANT note, use ffmpeg-php-0.6.0. Older version will make problems. This solves most of the issues.

Now extract them all.
tar -xjf amrwb-7.0.0.3.tar.bz2
tar -xjf essential-20071007.tar.bz2
tar -xjf ffmpeg-php-0.6.0.tbz2
tar -xzf flvtool2-1.0.6.tgz
tar -xzf lame-398-2.tar.gz
tar -xzf libogg-1.1.4.tar.gz
tar -xzf libvorbis-1.2.3.tar.gz
Now make directory for codecs and move them there.
mkdir /usr/local/lib/codecs
mv essential-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
We will now download MPlayer and FFMPEG using SVN and update.
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk mplayer
cd mplayer/
svn update
IMPORTANT: Download these both from SVN, by other ways it will give error (I got them).

If you do not have SVN, you can install it using:
yum install subversion
yum install ruby
yum install ncurses-devel
or you can use apt-get too
Some guides asked to update configuration file too. But for me it worked without it. To update libs use vi
vi /etc/ld.so.conf
It will open up vi editor. Add the following line:
/usr/local/lib
and then load config file using
ldconfig -v
Now make all other libs

cd amrwb-7.0.0.3
./configure
make
make install

cd ../flvtool2-1.0.6
ruby setup.rb config && ruby setup.rb setup && ruby setup.rb install

cd ../lame-398-2
./configure
make
make install

cd ../libogg-1.1.4
./configure
make
make install

ldconfig -v

cd ../libvorbis-1.2.3
./configure
make
make install

cd ../mplayer/
./configure
make
make install

cd ../ffmpeg
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
make
make install
Here, you may have problem with ffmpeg. I was having some issues with libvorbis. I first tried it by removing this. It works but you may need libvorbis. You may try using other version of vorbis we downloaded above. FFMPEG will take some time too on ./configure and make.
Also some of the guides used
echo '#define HAVE_LRINTF 1' >> config.h
after configure. I didn't use it but I think it will help.

Now add links to codecs:
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.50 /usr/lib/libavutil.so.50
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3
Now here comes an IMPORTANT part. This is a must do, it solved my all issues :P
Goto ffmpeg-php and edit ffmpeg_frame.c

cd ../ffmpeg-php-0.6.0
vi ffmpeg_frame.c
Now run this command:
:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32
save and quit. Use :wq for this.

Now in the same folder (i.e. ffmpeg-php-0.6.0) do the following.
phpize
./configure
make
make install
Now major stuff is done. We just have to add the php extension to php.ini file. You will first need to locate php.ini. You may find it in /etc/
vi /etc/php.ini
Add this line at the end
extension=ffmpeg.so
Ok, all done now. Just restart the server and check phpinfo for ffmpeg extension.
To restart use:
/etc/init.d/httpd restart
You can also use your server's cpanel/plesk for restarting the service.

Now to test you may run php command for phpinfo. Use this:
php -r 'phpinfo();' | grep ffmpeg
You should get version info and build date etc.
ffmpeg
ffmpeg-php version => 0.6.0-svn
ffmpeg-php built on => Nov 21 2009 23:35:23
ffmpeg-php gd support => enabled
ffmpeg libavcodec version => Lavc52.32.0
ffmpeg libavformat version => Lavf52.36.0
ffmpeg swscaler version => SwS0.7.1
ffmpeg.allow_persistent => 0 => 0
ffmpeg.show_warnings => 0 => 0
PWD => /usr/src/ffmpeg-php-0.6.0
_SERVER["PWD"] => /usr/src/ffmpeg-php-0.6.0
_ENV["PWD"] => /usr/src/ffmpeg-php-0.6.0
I will discuss a serious error in another post.

Developer Instincts