Php useful commands

Issue this command to check your pear/pecl config:

pecl config-show

To Find any extension installed for PHP

php -i | grep “extension”

To Find the right file of php issue command as

php –ini



Published in: on October 29, 2010 at 12:56 pm  Comments Off on Php useful commands  

What is a PHP extension?

A PHP extension, in the most basic of terms, is a set of instructions (i.e. code) that is designed to add functionality to PHP. For example, the widely used GD library (used for the creation of dynamic images) is an extension. This library added new functionality by allowing PHP to generate images on the fly. Another example is the MySQL extension, which allows us to connect to and work with MySQL databases.

What are PHP extensions needed for? There are several reasons why extensions are needed. One of them, as stated above, is to add new functionality to PHP. For instance, where would we be today if someone did not add the functionality to work with MySQL? Where will we be tomorrow if someone does not add the functionality to work with tomorrow’s databases or tomorrow’s technologies? As PHP continues to grow, it is likely that new “features” will be required by the ever-growing number of web developers. Some of the new features will be popular enough to be added to the official distribution, while others will not. Either way, those extensions will serve their creators well.

On the other hand, we might use PHP extensions to improve the efficiency and speed of our programs. Some processor intensive functions might be better coded as an extension rather than straight PHP code. Since extensions are written in C (more on the actual coding later), they will work much faster than straight PHP code too.

Another possible reason to employ extensions is to reuse frequently utilized code. Instead of moving the same old functions from project to project, you could place them all in one extension and allow all your projects to utilize that extension.
Types of PHP Extensions..

Before this question can be answered, we must look at the different “types” of extensions available. Extensions come in three different flavors: Zend engine extensions, built-in extensions and external extensions.

Zend Engine extensions are extensions that are implemented right into the engine itself. For those of you who do not know, the Zend engine is what PHP is built on. It is the engine that parses, interprets and executes your PHP scripts. Changing the engine itself will change the way PHP works. Anything that will affect the language itself or its features is added to the Zend engine; this includes if statement evaluation, object orientation, mathematical expressions evaluation, etc.

Although extending the engine is possible, it’s not recommenced for reasons such as incompatibility with servers that run the officially distributed engine. In other words, not too many server administrators will agree to use an unofficial version of the Zend engine.

Built-in extensions are extensions that are compiled right into PHP and are loaded with the PHP processes. The advantages of this method are: programmers aren’t required to load extensions manually, and no extension files are required (since it is compiled right into the PHP binary itself). The disadvantages, on the other hand, are: any changes to the extension will require a complete re-compilation of the PHP binary itself, and the size of the binary will grow with each new extension (as will the amount of memory it will consume).

External extensions are extensions that are manually added during run time. All the functionality of the extension will be available to the script that loaded it. When the script ends, the extension is released and the memory is freed. As you might guess, the advantages are: only the extension itself needs to be re-compiled after any changes and a small PHP binary. Also, you don’t provide the functionality of your extension to scripts that do not require it. And, as always, where advantages go, disadvantages follow: extensions are loaded during run time, a process that takes time, and the programmer must remember to load the extension since it is not automatically available.

Although loading external extensions each time the script is executed takes time, it is fairly quick. I personally do not feel any speed differences when I load my external extensions. Of course, if the site receives heavy traffic, a speed difference might be apparent and built-in extensions might be the most appropriate solution. Nevertheless, in these articles we will develop an external extension. Note that the difference between built-in extensions and external extensions – code wise – is virtually nonexistent.

Published in: on October 29, 2010 at 12:44 pm  Comments Off on What is a PHP extension?  

plesk details

http://www.parallels.com/products/plesk/resources/#customatization-lin

Published in: on October 27, 2010 at 6:49 pm  Comments Off on plesk details  

How to create MD5 Checksums and validate a file in Linux

how to generate a MD5 Checksum on a file or list of filesa and also how to validate a file against a known MD5 Checksum. For those of you that are not familiar with MD5 Checksums, the purpose is to validate the integrity of a file that may have been corrupted or tampered with. For example, it is possible for file to be corrupted in the process of downloading it from a website or FTP server. In order to verify if it has been corrupted or not, the publisher of the file you downloaded can include a MD5 Checksum (a string of numbers of letters) which is compared to the file you just downloaded. If the two checksums match, that means the files are identical – no corruption has occurred

 

Generate MD5 Checksum on a single file

md5sum filename

Generate MD5 Checksum on multiple files

md5sum filename1 filename2 filename3

Generate MD5 Checksum and ouptut to file

md5sum filename > md5.txt

Compare MD5 Checkum output file to current file in directory

md5sum -c md5.txt

Example of what a MD5 Checksum looks like

d4fdb933151cad1eb58e798d2874f8f6 send_file-1.0.0.7-0.i386.rpm

 

 

 

Published in: on October 27, 2010 at 1:33 pm  Comments Off on How to create MD5 Checksums and validate a file in Linux  

Install DomainKeys on a C-Panel

How to install DomainKeys on a specific domain.

1. First check that you are running the latest version on RELEASE or CURRENT of cPanel 11.
2. Run the script

/usr/local/cpanel/bin/domain_keys_installer username

Where username is the cPanel user.

If you get an error similar to “Domain keys are not installed on this machine.” you either are not running the latest release or current version of cPanel or you have not converted yet to maildir. Maildir conversion is required before you install DomainKeys.
You will find an article about converting to maildir on this site !

Ok, we just installed DomainKeys for a domain, but how about if we want to install it for all the domains (users)?
Well I found the solution just a few days ago on a public forum. Someone wrote a nice bash script that will parse all the cpanel users and then run the installation for each of them.

for i in `ls /var/cpanel/users` ;do /usr/local/cpanel/bin/domain_keys_installer $i ;done

Ok, but what about if we want that every new created account to have DomainKeys installed. Well this is a bit harder to do.
I recommend editing /scripts/postwwwacct and adding:

my %OPTS = @ARGV;
my $user = $OPTS{’user’};
/usr/local/cpanel/bin/domain_keys_installer $user

Now test this by creating a new account.

Published in: on October 13, 2010 at 12:12 pm  Comments Off on Install DomainKeys on a C-Panel  

WordPress 2.5.1: How to reset password manually

This bug has been fixed and will be included in WordPress 2.5.2. However, if you’ve upgraded to 2.5.1 and having issues with password reset,  you can do password reset, with any of following ways:

    1. Login to your PhpMyAdmin account, and select your WordPress database.
    2. Select & browse wp_users table, look for the username, you want to reset the password and click on the edit icon next to your username.
    3. Once the edit page is open, select MD5 from the Function dropdown next to the user_pass row. Change the value on the user_pass row to your new password and then hit Go.
    4. Now fireup your WordPress admin panel, and login with your new password and it will upgrade your password to the new phpass hashing.
  1. Or, if you’ve only single user on your WordPress installation, and the login name is admin. You can reset password with just simple SQL query, which once executed will replace password with whatever you enter as your new password to be. UPDATE `wordpress`.`wp_users` SET `user_pass` = MD5('PASSWORD') WHERE `wp_users`.`user_login` =`admin` LIMIT 1; WordPress, Brecker, Password, MySQL, Database, SQL Query, PHP, Tips, Tricks, Tips and Tricks, SQL, Passwords, Bug
  2. If you’re not comfortable with PhpMyAdmin or you don’t to do it manually, as an alternate, you can download files which contain the patch, here.
Published in: on October 11, 2010 at 12:21 pm  Comments Off on WordPress 2.5.1: How to reset password manually  

Find Command Utilities

There are couple of things you can try. The find command has a number of options to look for a file based on time. The ‘amin’, ‘cmin’, and ‘mmin’ options will look for files based on the last access time, change time (ie file permissions), and modification time respectively. Use a ‘-‘ to catch things after the specified time. So

Code:
find / -mmin -60
Published in: on October 11, 2010 at 12:09 pm  Comments Off on Find Command Utilities  

Delete Files Older Than x Days on Linux

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.

Command Syntax

find /path/to/files* -mtime +5 -exec rm {} \;

Note that there are spaces between rm, {}, and \;

Explanation

  • The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
  • The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
  • The third argument, -exec, allows you to pass in a command such as rm. The {} \; at the end is required to end the command.

This should work on Ubuntu, Suse, Redhat, or pretty much any version of linux.

 

http://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

Published in: on October 11, 2010 at 12:03 pm  Comments Off on Delete Files Older Than x Days on Linux