CopyDisable

Tuesday, 8 May 2012

Installing PHPMotion Media Sharing CMS

PHPMotion is a video sharing application and it also has functionalities for sharing images and music.
In this document I will install PHPMotion in an Ubuntu Linux server. The version of Ubuntu I used in 12.04 and it is 32bit.
While installing Ubuntu I installed the LAMP so that I already have the required Apache, PHP and MySQL. It can also be installed easily using apt-get.
The PHP version I used is 5.3.
Check the modules installed with PHP using the command
$ php –m
This command will list the PHP modules already installed. From this command I found that the GD Library is missing. To install GD library use the command:
$ sudo apt-get install php5-gd
 
Note: If you are at root user shell, just run the commands without sudo. Also in this doc I used pico editor to edit files, you can use any editor you like.
 
Also we need PHP curl library
$ sudo apt-get install php5-curl
Restart Apache after the installation
$ sudo service apache2 restart
To check details of PHP we can use the following script
$ sudo pico /var/www/info.php
 
image
Save the script in default apache root directory .i.e /var/www and open in a web-browser.
 
image
 
Next we have to install LAME mp3 encoder.
$ sudo apt-get install lame
 
Next we have to install Libogg and Libvorbis. First we have to install Libogg otherwise if we first try to install Libvorbis we will get error.
Also we need C compiler installed, otherwise we will get configure: error: no acceptable C compiler found in $PATH error while we try to compile Libogg and Libvorbis.
I am going to install the GCC compiler as do not have any C compiler installed in my computer.
$ sudo apt-get install gcc
If make is not installed, install make
$ sudo apt-get install make
 
Download Libogg
$ wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
Extract the downloaded file
$ tar xzvf libogg-1.3.0.tar.gz
Now we are going to compile the libogg, go to the libogg-1.3.0 directory
$ cd libogg-1.3.0
$ sudo ./configure
$ sudo make
$ sudo make install
 
Download Libvorbis and compile it
$ wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
$ tar xzvf libvorbis-1.3.3.tar.gz
$ cd libvorbis-1.3.3
$ sudo ./configure
$ sudo make
$ sudo make install

 
Install Mencoder and also Mplayer
$ sudo apt-get install mencoder
 
Install FFMpeg
$ sudo apt-get install ffmpeg
 
Install Flvtool2
$ sudo apt-get install flvtool2
 
Open PHP configuration file /etc/php5/apache2/php.ini and set the following:
open_basedir =
upload_max_filesize = 100M 
post_max_size = 100M
(Note: PHPMotion suggests above two parameters value as 100M, but it depends on your need. If you want to upload files larger than 100M set it accordingly)
max_execution_time = 1500
session.gc_maxlifetime = 14000
safe_mode = Off
enable_dl = On
 
Restart apache to load the changes.
$ sudo service apache2 restart
 
Download PHPMotion 3.5 version and extract it.
$ unzip phpmotion.zip
 
Copy Phpmotion to the Apache web server. In this example, I will deploy PHPMotion to the default root folder of Apache.
$ sudo cp -rf * /var/www/
 
We have to change the permission of the cgi-bin folder of phpmotion application to 755
$ cd /var/www
$ sudo chmod -R 755 ./cgi-bin
 
Now we could start the setup of PHPMotion.
Open the URL for PHPMotion and click on Continue button
image
 
In the second step PHPMotion checks for required components. Oopssss…… error for PHPShield.
 
image
 
To resolve this issue go to the Instruction manual http://wiki.phpmotion.com/PHPShield53
Check the PHP extensions directory
pranabs@ubuntu:/var/www$ php -i | grep extension_dir
extension_dir => /usr/lib/php5/20090626+lfs => /usr/lib/php5/20090626+lfs

My PHP extensions directory is /usr/lib/php5/20090626+lfs , go to this directory
$ cd /usr/lib/php5/20090626+lfs
 
Check is there any phpshield loader
 
pranabs@ubuntu:/usr/lib/php5/20090626+lfs$ ls
curl.so  gd.so  mysqli.so  mysql.so  pdo_mysql.so  pdo.so

 
Download the PHPShield loader from the link provided in http://wiki.phpmotion.com/PHPShield53
 
pranabs@ubuntu:/usr/lib/php5/20090626+lfs$ sudo wget http://downloads.phpmotion.com/phpshield-loaders/linux/i386/ixed.5.3
 
Now we have to add this new extension to PHP configuration file
$ cd /etc/php5/conf.d/
Create a new file ixed.5.3.ini
$ sudo pico ixed.5.3.ini
 
Add the line extension=ixed.5.3 to the new file and save it.
image
 
Restart Apache.
$ sudo service apache2 restart
 
Now go to the PHPMotion setup and refresh the page.
 
image
 
Now everything looks OK and we can continue the setup. Click on Continue button.

OMG… again some error. Its very simple just have to change permissions for some folders in PHPMotion.

image

pranabs@ubuntu:/var/www$ cd /var/www
pranabs@ubuntu:/var/www$ sudo chmod -R 777 addons
pranabs@ubuntu:/var/www$ sudo chmod -R 777 uploads
pranabs@ubuntu:/var/www$ sudo chmod -R 777 classes
pranabs@ubuntu:/var/www$ sudo chmod -R 777 logs
pranabs@ubuntu:/var/www$ sudo chmod -R 777 setup
pranabs@ubuntu:/var/www$ sudo chmod -R 777 pictures
pranabs@ubuntu:/var/www$ sudo chmod -R 777 temp


Click on the Check Again button after changing the permissions.
image

Click on Continue to proceed.
In this step we have to configure database connection to MySQL server. Connect to MySQL server and create the database and user.
mysql> create database phpmotion;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on phpmotion.* to 'phpmotion'@'localhost' identified by 'passw0rd';
Query OK, 0 rows affected (0.00 sec)


Enter the database details and click on Continue:
image

Enter the website information and other details and click Continue
image

Our setup is complete, remove the setup folder from PHPMotion root directory and click Login to Siteadmin to administer PHPMotion.
image

Installation is done, I can get the admin console:
image

But for proper functioning of this application we have to do some additional configurations.

Right now if we go to links like Video, Audios etc. we will get URL not found error
image

image

Also while uploading video the following error comes:
image

We have to change Apache config file to fix these issues

Open Apache config file /etc/apache2/sites-available/default and edit. My default file after editing looks as follows:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
     <Directory "/var/www/cgi-bin">
            AllowOverride None
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
      </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
 
save and restart Apache. Also make sure that .htaccess file is present in the PHPMotion root folder. i.e. in my case in /var/www folder.
 
Ooopssss Server error after restarting Apache
image
 
Lets check the Apache error log.
/var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://mediaserver.mkcl.org/uploader.php
Error related to RewriteEngine i.e. mod_rewrite of Apache. May be it is not loaded by Apache. Lets check all the loaded modules of Apache.
 
pranabs@ubuntu:/var/www$ apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
setenvif_module (shared)
status_module (shared)

Rewrite module is not loaded, we have to enable rewrite module
pranabs@ubuntu:/var/www$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart

pranabs@ubuntu:/var/www$ sudo service apache2 restart
 
Now check whether rewrite module has been loaded or not
pranabs@ubuntu:/var/www$ apachectl -t -D DUMP_MODULES
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
 rewrite_module (shared)setenvif_module (shared)
status_module (shared)
 
Wow…. I can see the rewrite module.
 
Now all the links of PHPMotion site are working fine :) .
 
Also I found one issue, in the new user registration page, the captcha image is not getting displayed and new users unable to register to the site.
image
 
If I check the Apache error log I get the message:
PHP Warning:  imagettfbbox(): Could not find/open font in /var/www/includes/captcha.php on line 53, referer: http://mediaserver.mkcl.org/join.php
 
I got the solution for this problem from PHPMotion Forum.
Open the file captcha.php located inside includes directory of PHPMotion root directory, i.e. in my case /var/www/includes/captcha.php
pranabs@ubuntu:~$ sudo pico /var/www/includes/captcha.php
Change the var $font = 'DoradoHeadline.ttf'; to var $font = './DoradoHeadline.ttf';
 
image
 
Save this file and and check again. This will resolve the issue.
image
 
That's all we have to do. Relax and enjoy your PHPMotion installation.