Installing New Components

Ever been in a Plesk box but can’t find certain components, like ASP support, or the backup manager? This is because Plesk installs whatever you tell it to at the initial install, and only whatever you tell it to. This leads to a lot of missing components that you might be used to having access to. Plesk won’t tell you anything in the GUI except that the component is not installed, so you must hunt down this binary:

/usr/local/psa/admin/bin/autoinstaller

This is the Plesk Autoinstaller, which will allow you, through its byzantine menu corridors, to find the gold that is the component you need. Navigating it is fairly simple, although you’ll probably want to read all of the text on the screen if this is your first time.

However, a more sinister condition awaits you – the fact that the Plesk autoinstaller apparently doesn’t know how to fucking resolve rpm dependencies. Why is it called an autoinstaller if it doesn’t automatically install anything extra? I don’t know.

Resolving Plesk Component Dependencies

Luckily, it’s not that difficult to resolve RPM dependency errors. Did you get an error message that looks something like this?


Retrieving information about the installed packages...
File downloading PSA_9.3.0/dist-rpm-CentOS-5-x86_64/build-9.3.0-cos5-x86_64.hdr.gz: 10%..20%..30%..40%..50%..60%..70%..80%..90%..100% was finished.
File downloading PSA_9.3.0/update-rpm-CentOS-5-x86_64/update-9.3.0-cos5-x86_64.hdr.gz: 10%..20%..30%..40%..50%..60%..70%..80%..90%..100% was finished.
File downloading PSA_9.3.0/thirdparty-rpm-CentOS-5-x86_64/thirdparty-9.3.0-cos5-x86_64.hdr.gz: 13%..25%..31%..40%..54%..60%..72%..83%..95%..100% was finished.
Determining the packages that need to be installed.
ERROR: Unable to install the "psa-backup-manager-9.3.0-cos5.build93091230.06.x86_64" package.
Not all packages were installed.
Please, contact product technical support.
[root@host2 plesk]#


Not to worry! First, try Google to find that RPM – Plesk allows their FTP server to be directory indexed, so it shouldn’t be hard to find the exact RPM it’s erroring out on. Try downloading the .rpm file and installing it manually using rpm -i:

wget http://autoinstall.swsoft.com.cn/PSA_9.3.0/dist-rpm-CentOS-5-x86_64/opt/backup/psa-backup-manager-9.3.0-cos5.build93091230.06.x86_64.rpm
rpm -i psa-backup-manager-9.3.0-cos5.build93091230.06.x86_64.rpm

If all goes well, you’ll get output messages listing the failed dependencies. Ignore any Plesk-looking dependencies, the auto-installer actually fixes these. Use yum to install any other system packages you may need.

 

Because I lose track of it all the time, this is the location to the php.ini file for cPanel’s built-in PHP installation.

/usr/local/cpanel/3rdparty/etc/php.ini

And, since it’s slightly relevant, you can rebuild the internal PHP installation with this script:

/scripts/makecppphp

 

There are many tutorials on how to install ffmpeg for cPanel. I will be combining one with my own modifications. Please submit modifications or corrections when necessary and I will update this post. The last update to this post was February 7th, 2012.

Some Prerequisites

There are a few things you’ll need to prepare if you’re on a fresh installation.

  1. Subversion
  2. Subversion is required to download and install ffmpeg and mplayer. First, you need to allow yum to install Perl packages.

    nano -w /etc/yum.conf

    In the exclude= line, remove “perl*” – save (CTRL+O) and exit (CTRL+X).

    yum install subversion

    Be sure to add the perl* line back to /etc/yum.conf after you install subversion! This is to prevent yum from accidentally overwriting cPanel’s Perl modules.

  3. Git
  4. Git is required because for some reason, when you install mplayer, it forces you to download a Git repository of ffmpeg. Don’t use this repository for installing ffmpeg – it breaks with a strange error message. How you install Git will vary across OSes. On CentOS 5.5 x64, there are several dependencies as well.

    yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel
    cd /usr/local/src
    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
    tar -zxf git-1.7.7.tar.gz
    cd git-1.7.7
    make prefix=/usr/local all
    make prefix=/usr/local install

  5. Ruby
  6. Ruby is required for flvtool. You can install this using the cPanel script:

    /scripts/installruby

    If you’re not using cPanel, you can probably install this using your package manager.

  7. libXext
  8. libXext is required for MP4Box. It’s in the yum repositories.

    yum install libXext libXext-devel

  9. Remove any other installations
  10. You might already have ffmpeg installed. If it was compiled in, that’s fine, this will overwrite it. But if you have RPM binaries installed, this will cause issues. Run the following:

    rpm -qa | grep ffmpeg
    rpm -qa | grep mplayer
    rpm -qa | grep mencoder
    rpm -qa | grep 264

    Remove with rpm -e any libraries, common files, or binary installations of these packages to prevent conflicts.

Download All The Things

One note; the official distribution release of ffmpeg-php no longer compiles. The SVN version available here works, but the SVN tarball link here can’t easily be downloaded in a terminal session, so I’ve rehosted the file here on this server. This is not my file, I haven’t modified it, and I take no responsibility for it – it’s merely a copy of the file available from the above link.

  1. Let’s get started! This step can and probably should be copy/pasted into your terminal all in one block.

  2. cd /usr/local/src
    wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
    tar zxf flvtool2-1.0.6.tgz
    wget http://switch.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz
    tar zxf lame-398-2.tar.gz
    wget http://hasaninter.net/ffmpeg-php.tar.gz
    tar xzf ffmpeg-php.tar.gz
    wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.3.tar.bz2
    tar xjf libvorbis-1.2.3.tar.bz2
    wget http://downloads.xiph.org/releases/ogg/libogg-1.1.4.tar.gz
    tar xzf libogg-1.1.4.tar.gz
    wget http://sourceforge.net/projects/opencore-amr/files/opencore-amr/0.1.2/opencore-amr-0.1.2.tar.gz/download
    tar xzf opencore-amr-0.1.2.tar.gz
    wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
    tar xjf libtheora-1.1.1.tar.bz2
    wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
    tar zxf xvidcore-1.3.2.tar.gz
    wget http://downloads.sourceforge.net/faac/faad2-2.7.tar.gz
    tar zxf faad2-2.7.tar.gz
    wget http://downloads.sourceforge.net/faac/faac-1.28.tar.gz
    tar zxf faac-1.28.tar.gz
    mkdir /usr/local/lib/codecs
    wget ftp://ftp.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
    tar xjf essential-20071007.tar.bz2
    wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
    tar zxf yasm-1.2.0.tar.gz
    cp /usr/local/src/essential-20071007/* /usr/local/lib/codecs/
    chmod -R 755 /usr/local/lib/codecs/
    mkdir /usr/local/src/tmp
    chmod 777 /usr/local/src/tmp
    export TMPDIR=/usr/local/src/tmp
    svn co https://gpac.svn.sourceforge.net/svnroot/gpac/trunk/gpac gpac
    git clone git://git.videolan.org/x264.git

  3. Now it’s time to grab mplayer and ffmpeg, the latest versions possible.

  4. git clone git://git.videolan.org/ffmpeg.git ffmpeg
    svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

Let’s Compile This Shit!

Alright, now we’re down to the good stuff – compilation! Hopefully if the above steps went correctly this will just fly by. However I do not recommend that you copy and paste the entire command tree into the terminal at this point. Run everything one step at a time to catch any errors if they do occur. Google is your friend, but feel free to leave a comment here if you run in to any problems.

  1. Lame

  2. cd /usr/local/src/lame-398-2/
    ./configure
    make
    make install

  3. Libogg

  4. cd /usr/local/src/libogg-1.1.4
    ./configure
    make
    make install

  5. Libvorbis

  6. cd /usr/local/src/libvorbis-1.2.3
    ./configure
    make
    make install

  7. yasm

  8. cd /usr/local/src/yasm-1.2.0
    ./configure
    make
    make install

  9. Libxvid

  10. cd /usr/local/src/xvidcore/build/generic
    ./configure
    make
    make install

  11. Libx264

  12. cd /usr/local/src/x264
    ./configure --enable-shared
    make
    make install

  13. Flvtool

  14. cd /usr/local/src/flvtool2-1.0.6
    ruby setup.rb config
    ruby setup.rb setup
    ruby setup.rb install

  15. Opencore-amr

  16. cd /usr/local/src/opencore-amr-0.1.2
    ./configure
    make
    make install

  17. Libtheora

  18. cd /usr/local/src/libtheora-1.1.1
    ./configure
    make
    make install

  19. faad2

  20. cd /usr/local/src/faad2-2.7
    ./configure
    make
    make install

  21. faac

  22. cd /usr/local/src/faac-1.28
    ./configure
    make
    make install

  23. MP4Box

  24. cd /usr/local/src/gpac
    ./configure
    make
    make install

  25. ldconfig
  26. To make sure mplayer and ffmpeg install using the correct libs, we need to make sure ld knows where to find our libraries. First, check:

    nano /etc/ld.so.conf

    Make sure that this file contains the line:

    /usr/local/lib

    If you’re on a 64-bit system you should also add:

    /usr/local/lib64

    Save (CTRL+O), exit (CTRL+W), and then update:

    ldconfig

    If you run in to any “file not found” errors, it’s probably ldconfig.

  27. Mplayer – remember, this will download a new version of ffmpeg for some crazy reason. When it asks, just hit enter and allow it to download. It’s only used for compiling mplayer. We must use –yasm=” because we’ve switched from yasm to nasm and mplayer can’t deal with that.

  28. cd /usr/local/src/mplayer/
    ./configure --enable-jpeg
    make
    make install

  29. FFMpeg

  30. cd /usr/local/src/ffmpeg
    ./configure --enable-libmp3lame --enable-libvorbis --enable-shared --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree --enable-libtheora --enable-version3 --enable-gpl --enable-libxvid
    make
    make install

  31. FFMpeg-PHP – at this point you may receive an error message. To fix this error refer to the second code block.

  32. cd /usr/local/src/ffmpeg-php
    phpize
    ./configure
    make
    make install


    nano -w ffmpeg_frame.c
    CTRL+W CTRL+R PIX_FMT_RGBA32 [enter] PIX_FMT_RGB32
    A
    CTRL+O CTRL+X

    What this does is replaces all instances of PIX_FMT_RGBA32 with PIX_FMT_RGB32, saves, and exits. This will happen after the “make” step – you will need to run “make” again, then “make install.”

  33. php.ini – All that’s left is to modify your php.ini file! Add the following near the top of the file /usr/local/lib/php.ini (to avoid conflicts)

  34. extension=ffmpeg.so

  35. Restart Apache
  36. /etc/init.d/httpd restart

That’s It!

At this point you should have a fully functional ffmpeg installation compiled in to PHP. You can test this with the following:


php -m | grep ffmpeg

You should get the output:

ffmpeg

Thank you very much to serverhostingsecrets.com for providing a very stable base for me to build this tutorial on!

© 2012 has an internet? Suffusion theme by Sayontan Sinha