Tricks and Tips about Systems/Network

December 21, 2009

Enabling mhash on php

Filed under: PHP, admins — Liju Mathew @ 9:48 am

Question,
How do I enable mhash on PHP ?

Solution.

Follow the steps.

1. wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
# tar -zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9 && make && make install

4. Recompile php with the "--with-mhash" option

How to verify the installation
Place this php file one the web and execute. It will result will be like this.

<?php
$input = "what do ya want for nothing?";
$hash = mhash(MHASH_MD5, $input);
echo "The hash is " . bin2hex($hash) . "
\n”;
$hash = mhash(MHASH_MD5, $input, “Jefe”);
echo “The hmac is ” . bin2hex($hash) . “
\n”;
?>

The hash is d03cb659cbf9192dcd066272249f8412
The hmac is 750c783e6ab0b503eaa86e310a5db738

December 19, 2009

Enable slow log query on MySQL

Filed under: MySQL, admins — Liju Mathew @ 2:21 pm

Question.

I want to Monitor the query which is taking longer execution time and killing server resource badly. Pls note that “set sql_log_off = ‘ON’; will not work on older version of Mysql 5.0.x.

Solution.

1. Create mysql log directory and permit mysql user to write on it
#mkdir /var/log/mysql
#touch /var/log/mysql/log-slow-queries.log
#chown mysql.mysql -R /var/log/mysql
2. Then stop the mysql server
[root@rc-169 ~]# service mysql stop
Shutting down MySQL... [ OK ]
[root@rc-169 ~]#

3. Running mysql with slow log query logging enabled.
# mysqld_safe –log-slow-queries=/var/log/mysql/mysql-slow.log&

The following script will create a slow log query for the testing purpose

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> select BENCHMARK(10000000, MD5(’sysadmin’));
+————————————–+
| BENCHMARK(10000000, MD5(’sysadmin’)) |
+————————————–+
| 0 |
+————————————–+
1 row in set (15.32 sec)
mysql>

We can enable general query log for quick debugging on latest Mysql revision. What we have to do is just execute the command from the terminal. As it is a logging of all queries executed on the mysql, the file size will be increased drastically, So use it wisely. enable and disable for a short period.

mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.00 sec)

This command will start to write sql query executed on a log file under data directory (/var/lib/mysql)

If you want to store the query on a table
you may choose this option
mysql > set global log_output=’table’;

Enabling PDO_MYSQL on PHP, Magento installation

Filed under: Linux, MySQL, PHP, admins — Liju Mathew @ 12:26 pm

Question

My box is cents5.3.1 and I want to install Magento ( a php framework) on users desktop. During the installation I got stucked because php_mycrypt and pdo_mysql was enabled on my existing php compilation.

1. Installation of mycrypt is fairly easy, find the follows

#wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-.5.8.tar.gz?use_mirror=jaist
#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure && make && make install

2. MySQL_PDO installation

#yum install autoconf
#pecl install pdo_mysql

[root@rc-040 php-5.2.9]# vi /etc/php.ini edit php.ini and set the path of extension_dir to identify the module.
extension_dir = “/usr/lib/extensions/no-debug-non-zts-20060613″
extension=”pdo_mysql.so”
[root@rc-040 php-5.2.9]# PHP_PDO_SHARED=1 sudo pecl install pdo_mysql
[root@rc-040 php-5.2.9]# php -r 'phpinfo();' |grep "pdo"
which returns

[root@rc-169 ~]# php -r 'phpinfo();' |grep "pdo"
pdo_mysql
pdo_sqlite
PECL Module version => (bundled) 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.4 2008/12/31 11:17:42 sebastian Exp $
[root@rc-169 ~]#

Then compile the php again. I have created a file which will help to enable maximum modules that we need( it takes long time to sort it out)
I uses con.sh file to add config parameters and added the following lines in to it

./configure --prefix=/usr/local/php --with-apxs2=/usr/sbin/apxs --with-xsl --with-mysql --with-config-file-scan-dir=/etc/php.d --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --with-config-file-path=/etc --with-bz2 --with-curl --with-exec-dir=/usr/bin --with-png --with-zlib --with-pear=/usr/share/pear --with-zml --with-gd --with-libxml=/usr/lib --enable-calendar --with-openssl-dir=/usr/local/ssl --with-bcmath --with-mysqli --enable-soap -with-jpeg --enable-sockets --enable-mbstring --enable-shared --with-jpeg-dir=/usr/local --with-freetype-dir=/usr/local/lib --with-mcrypt=/usr/local/bin/mcrypt

Then
#make && make install

Try http://localhost/phpinfo.php to verify the installation

Magento installation issue

December 18, 2009

How do I change the date format on IIS

Filed under: IIS, Windows, admins — Liju Mathew @ 9:47 am

Problem,

I need to displayed the date format on “dd/mm/yyyy” format. I have done regional setting change, restart IIS and reboot the server. Still it showing the same date format.

I used this aspx page to test whether it is working or not. File content is ” ” still showing the older format

Solution,
1. You can find a script named “AdminAcripts” on “C:/InetPub/AdminAcripts” and edit. Replace the string "IsSecureProperty =True" to ""IsSecureProperty = False".
2. Open the command window and change directory to “C:/InetPub/AdminAcripts”.
3. We need to get the password of IIS user account and change the date settings exclusive for that user.
4. To Retrieve the IUSR Password, enter this command:
>cscript adsutil.vbs get w3svc/anonymoususerpass
Should return something like:
cmd> anonymoususerpass : (STRING) "/FGde5hse7x"!5dI"
5. Copy the IUSR password and Open the control panel, select the Regional settings –> Press Shit key+ Right button while selecting the “Regional menu”. Then choose “Run as” option
6. Provide the IUSR name and password, then change the date format for that user profile.
USR name someting like “IUSR_Servername” ( You can get this from find users directory search or from the users list on Computer Management)

Retrive the IUSR passwords

December 17, 2009

How to reset mysql root password

Filed under: MySQL, admins — Liju Mathew @ 4:27 pm

Here I have two environments. One I am working on Linux (mysql native) and other is WAMP on windows.

For linux,
This command would work simply.

#mysqladmin -u root password NEWPASSWORD -p

For Windows wamp mysql the above wont work because there is no mysqladmin shipped with WAMP mySQL installation. My Steps are listed below,
1, login with root account.
2, execute this command from the terminal
mysql> update user set password=PASSWORD(“rain”) where User=’root’;

That’s it

December 8, 2009

Setting up Caching nameserver on Linux

Filed under: DNS, Linux, admins — Liju Mathew @ 6:58 pm

This are the simple steps configure a caching DNS server which will incresse your dnslookup speed on LAN.

1. I uses Centos5 operating system.
2, Install BIND packages
#yum install bind*
#yum install caching-nameserver ( It’s a sample named.conf file placed on /var/named/chroot/etc/ after the installation)
3. Edit the default file to accept the DNS query from our network. I supposed to be configure caching server on the ip 192.168.0.25 and our network is 192.168.0.0/24

[root@rc-025 ~]# vi /var/named/chroot/etc/named.caching-nameserver.conf

options {
listen-on port 53 { 127.0.0.1;192.168.0.25; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";

// Those options should be used carefully because they disable port
// randomization
// query-source port 53;
// query-source-v6 port 53;

allow-query { "any";};
forwarders { 125.22.47.125;125.224.7.125; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

view localhost_resolver {
match-clients { localhost;192.168.0.0/24; };
match-destinations { localhost;192.168.0.0/24; };
recursion yes;
include "/etc/named.rfc1912.zones";
};

Modified lines are

1. listen-on port 53 { 127.0.0.1;192.168.0.25; };
2. allow-query { “any”;};
3. forwarders { 125.22.47.125;125.224.7.125; }; //my ISP’s DNS servers
4. match-clients { localhost;192.168.0.0/24; };
5. match-destinations { localhost;192.168.0.0/24; };

-Enjoy

November 20, 2009

Task scheduler for calling php file on Windows

Filed under: Windows, admins — Liju Mathew @ 12:38 pm

Hi,

I have spent few hours with troubleshooting the issue of setting up a cron job on Windows. This scheduler will call a php page every 15 minutes. When it called over the web it’s send me a mail but on CLI it won’t.

The issue is that program using a SMTP class to send out the mail which wasn’t execute from terminal as php can’t find it path. So each php call originated from the shell console facing file path issues.

I have created a batch file for calling this php script and configure it on Windows task manager. I uses advanced option in Task manager as it is required to execute every 15 minutes of interval.

>php.exe -f path\to\your\script.php

November 18, 2009

Outlook errors: Your mailbox has been deactivated

Filed under: Windows, admins — Liju Mathew @ 3:39 pm

Today morning one of the user reported that they can’t send the email as they are getting messages from the server which states that “

“We are contacting you in regards to an unusual activity that was identified in your mailbox. As a result, your mailbox has been deactivated. To restore your mailbox, you are required to extract and run the attached mailbox utility.
Best regards, mydomain.com technical support.”

This issue caused the users desktop were affected with some phishing virus. I changed the users email passwords,system password, removed the unwanted startup program and reboot.

Then done a virus definition update and full system scan.

-Enjoy

November 15, 2009

How to import a .CSV to MySQL table

Filed under: Databases, MySQL, admins — Liju Mathew @ 11:14 pm

The following example will shows how to import csv file data which is seperated by a comma between the fields. This will useful for contacting any of the third party who will provide their data either in Xml or csv format.

LOAD DATA LOCAL INFILE ‘/home/produser/eA_performance_usd.csv’
INTO TABLE ea_perfomance_usd
FIELDS TERMINATED BY ‘,’
ENCLOSED BY ‘”‘
lines TERMINATED BY ‘\n’

a. home/produser/eA_performance_usd.csv = path to the csv file
b. table name here ‘ea_perfomance_usd’
c. colum separator = .

Error 1114: A dynamic link library (DLL) initialization routine failed.

Filed under: General, Windows, Windows 2003, admins — Liju Mathew @ 11:08 pm

use command
C:\Inetpub\AdminScripts\adsutil.vbs set /MSFTPSVC/PassivePortRange "5500-5525"

do not use starting port < 5500 this will create the above error

Next Page »

Blog at WordPress.com.