Tuesday, March 2, 2010

Install XCache

XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested (on linux) and supported on all of the latest PHP. It optimizes performance by removing the compilation time of PHP scripts by caching the compiled state of PHP scripts into the shm (RAM) and uses the compiled version straight from the RAM. This will increase the rate of page generation time by up to 5 times as it also optimizes many other aspects of php scripts and reduce server load.

To install follow the steps

1. Download and extract the source for XCache .

# cd /usr/local/src/
# wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
# tar -xzvf xcache-1.2.2.tar.gz

2. Build, configure and install the XCache module.
# cd xcache-1.2.2
# phpize
# ./configure --enable-xcache
# make && make install

You can see a message like this . Note the extension directory.

=============
Build complete.
Don’t forget to run ‘make test’.

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
==============

3. Now configure the php.ini file ( To find .ini file, use the command `php -i | grep php.ini` )

# cat xcache.ini >> /usr/local/lib/php.ini

Replace the following line in php.ini with correct path ,which describes the Installed shared extensions that we noted above.

zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so

It will become like this,

zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so

4. Restart apache and confirm the Xcache installation.
# /etc/init.d/httpd restart

# php -v

it will show you as
-----------
php -v
PHP 5.2.8 (cli) (built: Feb 16 2009 05:42:38)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
--------

Monday, March 1, 2010

htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

How to solve “.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable”

My error log shows:-
[sat Jan 13 01:15:32 2009] [crit] [client 218.208.xxx.xxx] (13)Permission denied: /home/mydomain/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

And the site is showing “403 Forbidden Error”.
At first, I suspect it’s .htaccess problem, but actually it’s caused by Frontpage Extension.

To solve “.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable” follow the steps below:-

* Login into your CPanel account
* Click on “Frontpage Extensions” icon
* Click on “Reinstall extensions” button beside your problem domain.
*If you do not use any frontpage extensions, it’s good to uninstall this extension
* Done. The “.htaccess pcfg_openfile: unable to check htaccess file” problem has been fixed.

Reverse DNS: how to check it?

Check RDNS using NSLOOKUP command ,HOST (on linux server ) command or centralops.net.

NSLOOKUP
--------------
1)You can check RDNS is setup or not from command prompt using nslookup command
Server which has RDNS set-

C:\>nslookup 10.11.12.13

Server: vnsc-pri.sys.gtei.net
Address: 4.2.2.1
Name: host.myhostname.com
Address: 10.11.12.13

Here if "Name" is your "hostname" then RDNS is setup for this server.


If RDNS is not setup you will see the "datacenter name " in front of "Name" as below.
C:\>nslookup 11.12.13.14
Server: vnsc-pri.sys.gtei.net
Address: 14.13.12.11
Name: bc.d3.7bae.static.theplaneet.com
Address: 11.12.13.14

Here "Name" is not your hostname, thus rdns is not set up for this server.


Using HOST command (on linux server)
-----------------------------------------------
1)on server
root@shell [~]# host 10.11.12.13
output-
13.12.11.10.in-addr.arpa domain name pointer host.myhostname.com.
=> If output line is ended with hostname, then rdns is setup for this.

2)on linux server -
root@shell [~]# host 1.2.3.4
output-
4.3.2.1.in-addr.arpa domain name pointer bc.d3.7bae.static.theplanet.com.
=> output line is not ended with hostname, thus rdns is not set for this .


Use centralops.net
---------------------------------------
browse http://centralops.net
1) open browser http://centralops.net/co/ >> Domain Dossier
put ip in it and see dns report
canonical name should be your hostname
and in dns report

13.12.11.10.in-addr.arpa IN PTR host.myhostname.com

ptr line should contain hostname.


3) open browser http://centralops.net/co/ >> Domain Dossier
put ip in it and see dns report
canonical name should be your hostname
and in dns report

"4.3.2.1.in-addr.arpa IN PTR ba.d3.7bae.static.theplanet.com"

ptr line does not contain hostname, thus no rdns set for this.

Installing cPanel/WHM

cpanel can offer 15-day test licenses for no cost.


Installing cPanel/WHM

To begin your installation, use the following commands:

1. cd /home — Opens the directory /home.
2. wget -N http://layer1.cpanel.net/latest — Fetches the latest installation file from the cPanel servers.
3. sh latest — Opens and runs the installation files.



4.(If you have purchased license for cpanel)
/usr/local/cpanel/cpkeyclt — Activates your license after installation.

5. Login to WHM and proceed with the intial WHM Setup.


Obtaining a cPanel/WHM License:

If you do not have a license for cPanel/WHM, you will need to obtain one for your IP address. You can obtain a license at http://www.cpanel.net/store.

create VPS container

Create VPS container on hardware node using virtuozzo control panel.

1. Log in to https://ip:4643/vz/cp
2. Click on >> Containers >>New Container
3. Number of Containers to create* 1
4. Hardware Node Selection - Click on radio button against - Select Hardware Node Manually
5. Click on NEXT
6. General Configuration >>

Name* = Domain name (domain.com)
Description = root
Select Container Sample = Select 256, 512, 1024 MB ram as per vps order
OS Template/Version* = will be selected automatically once you have selected the ram in the above step.

Administrative Password = Type Password ..Retype the password

Click on NEXT

Global Network

Hostname = hots.domain.com
DNS Server IP Address 4.2.2.1 .. Click on the PLUS ICON (+) and enter 4.2.2.2 in the second DNS Server IP Address box

Routed Network

IP Address >> Keep it on auto .. Click on PLUS ICON (+) two times as we need to give 3 ips.


Click on NEXT

CPU Parameters

diskspace Soft Limit 20,40,60 GB Hard Limit 21, 41, 61
diskinodes Soft Limit 200000, 300000, 400000 Hard Limit 220000, 320000, 420000 ( as per requirements)
quotaugidlimit - Enable by clicking on the check box against it. Set value 250, 350, 500 (as per VPS configuration)
quotatime - 60 seconds
ioprio - 4

Memory Parameters

slmmemorylimit - Soft Limit 256,512,1024 MB (as per requirement) Hard Limit 256,512,1024 MB

Click oN NEXT

Available Applications(81) - Click on the check box against [devel] . Add it to Scheduled for Installation by clicking on >>


After selecting devel, click on check box against Scheduled for Installation(1)

Click on NEXT

Please review the new Container configuration. ( MAKE SURE TO CHECK EVERYTHING)

FINALLY CLICK ON CREATE

Once the vps is created log into shell. Now you have to install yum and control panel on the server.

Sunday, February 28, 2010

find command:

find command:

Find man page

Form of command: find path operators

Examples:

* Search and list all files from current directory and down for the string ABC:
find ./ -name "*" -exec grep -H ABC {} \;
find ./ -type f -print | xargs grep -H "ABC" /dev/null
egrep -r ABC *

* Find all files of a given type from current directory on down:
find ./ -name "*.conf" -print

* Find all user files larger than 5Mb:
find /home -size +5000000c -print

* Find all files owned by a user (defined by user id number. see /etc/passwd) on the system: (could take a very long time)
find / -user 501 -print

* Find all files created or updated in the last five minutes: (Great for finding effects of make install)
find / -cmin -5

* Find all users in group 20 and change them to group 102: (execute as root)
find / -group 20 -exec chown :102 {} \;

* Find all suid and setgid executables:
find / \( -perm -4000 -o -perm -2000 \) -type f -exec ls -ldb {} \;
find / -type f -perm +6000 -ls

Note: suid executable binaries are programs which switch to root privileges to perform their tasks. These are created by applying a "sticky" bit: chmod +s. These programs should be watched as they are often the first point of entry for hackers. Thus it is prudent to run this command and remove the "sticky" bits from executables which either won't be used or are not required by users. chmod -s filename

* Find all world writable directories:
find / -perm -0002 -type d -print

* Find all world writable files:
find / -perm -0002 -type f -print
find / -perm -2 ! -type l -ls

* Find files with no user:
find / -nouser -o -nogroup -print

* Find files modified in the last two days:
find / -mtime 2 -o -ctime 2

* Compare two drives to see if all files are identical:
find / -path /proc -prune -o -path /new-disk -prune -o -xtype f -exec cmp {} /new-disk{} \;

Partial list of find directives:



Directive Description
-name Find files whose name matches given pattern
-print Display path of matching files
-user Searches for files belonging to a specific user
-exec command {} \; Execute Unix/Linux command for each matching file.
-atime (+t,-t,t) Find files accessed more that +t days ago, less than -t or precisely t days ago.
-ctime (+t,-t,t) Find files changed ...
-perm Find files set with specified permissions.
-type Locate files of a specified type:
  • c: character device files
  • b: blocked device
  • d: directories
  • p: pipes
  • l: symbolic links
  • s: sockets
  • f: regular files
-size n Find file size is larger than "n" 512-byte blocks (default) or specify a different measurement by using the specified letter following "n":
  • nb: bytes
  • nc: bytes
  • nk: kilobytes
  • nw: 2-byte words


Tuesday, February 2, 2010

Installing FFMpeg on cpanel server.

Installing FFMpeg

1)yum install ffmpeg ffmpeg-devel

If you get package not found, then you will need to add few lines in the yum repository for dag packages installation. Create a file named dag.repo in /etc/yum.repos.d with the following contents on it

[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux

baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1

then

yum install ffmpeg ffmpeg-devel

If everything is fine, then the installation should proceed smoothly

2)To check the FFmpeg working:

Finally, check the ffmpeg whether it is working or not.

> ffmpeg
> ffmpeg -formats
> ffmpeg --help
// This lists path of mpeg, its modules and other path information


ffmpeg -i Input.file Output.file

****Install FFMPEG-PHP Extension*****
FFmpeg-php is a very good extension and wrapper for PHP which can pull useful information about video through API interface. Inorder to install it you will need to download the source file and then compile and install extension in your server. You can download the source tarball : http://ffmpeg-php.sourceforge.net/

wget /path/to/this/file/ffmpeg-php-0.5.2.1.tbz2

tar -xjf ffmpeg-0.5.2.1.tbz2

phpize

./configure
make
make install

****Editing PHP.INI

Once you have done that without any problems then you will see the php extension file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so and you will need mention that extension in php.ini file

nano /usr/local/lib/php.ini

Put the below two lines at the end of the php.ini file

[ffmpeg]
extension=ffmpeg.so

Then restart the server service httpd restart

****To check whether ffmpeg enabled with php, point your browser to test.php file. It should show the confirmation of installed ffmpeg php extension

// #test.php