Search


Friday, December 30, 2011

Enable slow query log in Mysql

How to Enable slow query log in Mysql  ?

Check whether the "slow query log" is enabled  in mysql. Access mysql and try to execute the following command.


mysql> show global variables like '%slow%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| log_slow_queries | OFF   |
| slow_launch_time | 2     |
+------------------+-------+


The command result shows slow query log is currently disabled in the server.  You have add the following entries in the "/etc/my.cnf"  file in-order to enable "slow query log".  Place the entries below the  section "mysqld"

[mysqld]
long_query_time=2
log-slow-queries=/var/log/mysql/log-slow-queries.log

You must create the file manually and change owners this way:

mkdir /var/log/mysql
touch /var/log/mysql/log-slow-queries.log
chown mysql.mysql -R /var/log/mysql

 Restart mysql

Check again  whether the "slow query log" is enabled.

mysql> show global variables like '%slow%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| log_slow_queries | ON    |
| slow_launch_time | 2     |
+------------------+-------+
2 rows in set (0.00 sec)

This steps will log all Mysql queries that took more than 2 seconds to complete the execution.  

Wednesday, December 28, 2011

Install SSL manually in Linux

Install  SSL certificate for a doamin/Server manually into Linux Servers



The Entrust SSL Certificate is in the section named "Entrust SSL Certificate".

Example:  

Your certificate will look something like this: (Do not use the code below)
-----BEGIN CERTIFICATE----- 
MIIC4zCCAkygAwIBAgIBAzANBgkqhkiG9w0BAQUFADBFMQs
wCQYDVQQGEwJVUzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW
9uMRwwGgYDVQQDExNHVEUgQ3liZXJUcnVzdCBSb290MB4XD
AxMDgyMTIwMDIwOVoXDTA2MDEwMTIzNTkwMFowgcMxCzAJB
gNVBAYTAlVTMRQwEgYDVQQKEwtFbnRydXN0Lm5ldDE7MDkG
1UECxMyd3d3LmVudHJ1c3QubmV0L0NQUyBpbmNvcnAuIGJ5
HJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAx
Tk5IEVudHJ1c3QubmV0IExpbWl0ZWQxOjA4BgNVBAMTMUVu
J1c3QubmV0IFNlY3VyZSBTZXJ2ZXIgQ2VydGlmaWNhdGlvb
BdXRob3JpdHkwgZ0wDQYJKoZIhvcNAQEBBQADgYsAMIGHAo
M0ogzRUG4nzD683kTH/rzFgyajoshBo7Z/nkzbxCmS7R/UE
jR03FJxmBJgxUcg2ILdkfmhKfvLNx04AZP0dme4w1KNK5Ct
pzWUHmBelrTN/fCStgpkiZk0eSYbDoAivU0m2X47eMQ//24
coN6COWuBsRYZYblUtuZDAgEDo2YwZDAPBgNVHRMECDAGAQ
EDMA4GA1UdDwEB/wQEAwIBBjBBBgNVHR8EOjA4MDagNKAyh
HRwOi8vY2RwLmJhbHRpbW9yZS5jb20vY2dpLWJpbi9DUkwv
Um9vdC5jZ2kwDQYJKoZIhvcNAQEFBQADgYEAgbZwffFU+Fj
SoUFyRAAysIauOknVaLteQPQJxBGLMhXGdfejVBTWLb1UTF
NCiqm8Co+dYikuVB+0/1habRkb+k4vFe6tn5IvQMnfhZbSJ
5IlGVDWQYlfC0/R1wjfv+U6rzTJbJ7WXX0Ka5jKLKuckXNv
OA4=
-----END CERTIFICATE-----
  1. Copy the Entrust SSL Certificate to your clipboard. You must include the "----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" lines.
  2. Paste the certificate into a simple text editor, and ensure that the entire text is flushed to the left with no leading or trailing white space. If there are any extra spaces or missing dashes the server will not recognize the format of the file and you will not be able to install the certificate.
  3. Save the file as /path/to/your/apacheconf/ssl.crt/servername.crt
You have just installed your Entrust SSL Certificate.
It is strongly recommended that the httpd.conf file is backed up before attempting modifications.
In the section of /path/to/your/apacheconf/httpd.conf ensure that the following entries are correct:

Enable / Disbale SSL for this host
SSLEngine on

Certificate Paths:
SSLCertificateFile /path/to/your/apacheconf/ssl.crt/servername.crt
SSLCertificateKeyFile /path/to/your/apacheconf/ssl.key/servername.pem




Locate PHP configration file in Directadmin

Compile and enable soap on php with DirectAdmin Control Panel Custombuild
 
Locate PHP configration file  in Directadmin. When you recompile php, make sure you are editing the correct php configuration files. You have to make sure CustomApache or CustomBuild 
 
 cd /usr/local/directadmin/custombuild

./build used_configs
 
 Results:

Apache configuration file: /usr/local/directadmin/custombuild/custom/ap2/configure.apache

PHP4 configuration file: /usr/local/directadmin/custombuild/custom/ap2/configure.php4

suPHP configuration file: /usr/local/directadmin/custombuild/custom/suphp/configure.suphp

PHP5 configuration file: /usr/local/directadmin/custombuild/custom/suphp/configure.php5
 
Edit your php5 config file: (example)

nano /usr/local/directadmin/custombuild/custom/suphp/configure.php5

Add: (Note that only the last rule has no slash!)

--enable-soap
 
Save the file and rebuild PHP:

./build php all
 
 
For more information, please verify the url:  http://help.directadmin.com/item.php?id=252
    
 

Tuesday, December 27, 2011

How to change Nagious Password


root# touch /usr/local/nagios/sbin/.htaccess

root# vi /usr/local/nagios/share/.htaccess



And I wrote the follwing text in the .htaccess file


AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user


Then, I did the following:


root# touch /usr/local/nagios/share/.htaccess

root# vi /usr/local/nagios/sbin/.htaccess


And I wrote the same text in that file too. Then, I did the following
 (Which is the command for changing the password ):
 
 
root# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

New password:
Re-type new password:
Adding password for user nagiosadmin

root#  ls -l /usr/local/nagios/etc/htpasswd.users
-rwxrwxr--  1 nagios nagios 26 Dec 21 15:54 /usr/local/nagios/etc/htpasswd.usersroot#

root# chmod o+r /usr/local/nagios/etc/htpasswd.users

root# service httpd restart

 
This steps will help you