LinuxHelps.com

A blog for Linux Lovers.

Posted by sibu on May 24, 2009

How to change the storage engine to InnoDB?

Edit the /etc/my.cnf file and look for this line:

skip-innodb

and comment it out:

#skip-innodb

Add the following entry in the /etc/my.cnf file

default-storage_engine = InnoDB

Save the file, and restart mysql

/etc/rc.d/init.d/mysqld restart

You can use the following command to check the “storage engine” used in the server.

mysqladmin variables | grep storage_engine

You will see the storage engine as “InnoDB”.

# mysqladmin variables | grep storage_engine
| storage_engine | InnoDB

Posted by sibu on May 24, 2009

Hide Apache, PHP and kernel Version Details.

To hide the information, add the following two apache directives in Apache configuration file                    /etc/httpd/conf/httpd.conf

ServerTokens ProductOnly

ServerSignature Off

Now you need to restart your web server using the following command

#/etc/init.d/httpd restart

The ServerSignature appears on the bottom of pages generated by apache such as 404 pages, directory listings, etc.

The ServerTokens directive is used to determine what Apache will put in the Server HTTP response header. By setting it to Prod it sets the HTTP response header as follows:

Server: Apache

Hide PHP Version Details

If you want to hide the PHP version you need to edit the /etc/php4/apache/php.ini(For php4 users) file and /etc/php5/apache/php.ini (For php5 users)

Change the following option

expose_php On
to
expose_php Off

Now you need to restart your web server using the following command

#/etc/init.d/httpd restart

After making this change PHP will no longer add it’s signature to the web server header.

In order to hide the ‘kernel’ version, you need to compile a customo kernel. That’s the only way , as far as I know. There’s no setting to do this.

Posted by sibu on May 24, 2009

Disable php for a single domain.

To disable PHP for a particular user on a Linux server , Put the following code in a .htaaccess file for that user as :

php_flag engine off

Also you can add following code for that in tag of taht particular domain in server’s httpd.conf .

php_admin_flag engine off

Posted by sibu on May 24, 2009

Error : Maximum file limit has been reached

Many times we get an error called the maximum number of files that can be opened has reach the limit,
In order to resolve this, you will have to login as a root on your server and edit the file called /etc/sysctl.conf

vi /etc/sysctl.conf

Add the line there as

fs.file-max = 22992

Save and exit from the file.

In order to apply these changes run the command called

# sysctl -p

This will increase the maximum number of open files for your system

Posted by sibu on April 16, 2009

Private Nameserver Setup.

1.Register the domain name you would like to use. If you have already a domain name please create an account for this domain on server whm. This domain will be used as your nameservers.                                eg ns1.newdomain.com and ns2.newdomain.com

2. Additional IPs

Have 2 available IP addresses for your server that aren’t in use. currenlty only one ipaddress is configured on the whm that is
66.90.25.49
You might have got a range of ip address with the server. please let us know the range of ipaddress we will add those ipaddress to this server.

3. Registering the Nameservers

Now login to your domain management page for the domain you registered and register ns1.newdomain.com and ns2.newdomain.com as nameservers (registries normally have a special facility for doing that). The registry may also have a facility to propogate these nameservers around the foreign registries - if so, you should use this facility.

It may take upto 24 hours the nameserver propagation. once you done this you can configure this nameservers to your whm.

Go into WHM (Web Host Manager) and select Edit Setup from the Server Setup menu on the left. Enter ns1.newdomain.com in the Primary Nameserver field. Hit ‘Assign IP Address’, then hit ‘Add an A Entry for this nameserver’.
Repeat this process for the Secondary Nameserver field.

Posted by sibu on April 12, 2009

Command to view the previous load in the server.

grep average /var/log/dcpumon/toplog.*

- This command will display the load that has been in the server.

root@server]# grep average /var/log/dcpumon/toplog.*

/var/log/dcpumon/toplog.1232442601:top - 04:10:01 up 1 day, 10:31, 2 users, load average: 3.69, 3.21, 2.34
/var/log/dcpumon/toplog.1232442601:top - 04:10:04 up 1 day, 10:31, 2 users, load average: 4.27, 3.34, 2.39
/var/log/dcpumon/toplog.1232442901:top - 04:15:03 up 1 day, 10:36, 2 users, load average: 4.67, 3.88, 2.86
/var/log/dcpumon/toplog.1232442901:top - 04:15:06 up 1 day, 10:36, 2 users, load average: 4.67, 3.88, 2.86
/var/log/dcpumon/toplog.1232443202:top - 04:20:02 up 1 day, 10:41, 2 users, load average: 3.87, 3.82, 3.11
/var/log/dcpumon/toplog.1232443202:top - 04:20:05 up 1 day, 10:41, 2 users, load average: 3.87, 3.82, 3.11
/var/log/dcpumon/toplog.1232443501:top - 04:25:02 up 1 day, 10:46, 2 users, load average: 7.67, 6.40, 4.36

Posted by sibu on April 12, 2009

How to prevent hotlinking images on Apache server.

Prerequisites

* mod_rewrite must be loaded
* AllowOverride must be enabled
* FollowSymLinks must be enabled

For the sake of this example, we will assume that your website url is www.yourdomain.com, the file that is being hotlinked is widget.png, and the web page where the hotlinking is coming from is ebay.com (very common).
The Solution: using mod_rewrite and .htaccess to forbid hotlinking

Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} ^(www\.)?ebay.com/.*$ [NC]
RewriteRule widget\.png$ - [F]

When placed in your .htaccess file this will prevent hotlinking of widget.png by any ebay auctions.

This rule explained:

1. First the RewriteEngine (the mod_rewrite module apache loaded) is turned on

Note: RewriteEngine only needs to be turned on once before any conditions or rules are defined. You do not need to turn it on, on a per-rule basis. In fact setting RewriteEngine On multiple times will result in a server error.

RewriteEngine On

2. next, for any requests coming in with an http referrer, which does NOT match www.yourdomain.com or yourdomain.com, NOT case sensitive. . .

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]

3. and the referrer IS www.ebay.com, or the referrer IS ebay.com

Code:
RewriteCond %{HTTP_REFERER} ^(www\.)?ebay.com/.*$ [NC]

4. for the file widget.png, send nothing, and forbid access (send a 403 Forbidden response header)

Code:
RewriteRule widget\.png$ - [F]

Alternatively: prevent hotlinking of all images (well, all .gif, .jpg/.jpeg, .png, and .bmp files) from ebay

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} ^(www\.)?ebay.com/.*$ [NC]
RewriteRule \.(gif|jpe?g|png|bmp)$ - [F]

Prevent hotlinking of all images (well, all .gif, .jpg/.jpeg, .png, and .bmp files) from anywhere but your own site

Code:
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpe?g|png|bmp)$ - [F]

Posted by sibu on March 22, 2009

Enable query cache in MySQL.

This query cache in mysql will help to improve my mysql performance.

query_cache_size=SIZE


The amount of memory (SIZE) allocated for caching query results.

Options are:

0 : Don’t cache results in or retrieve results from the query cache.
1 : Cache all query results except for those that begin with SELECT S_NO_CACHE.
2 : Cache results only for queries that begin with SELECT SQL_CACHE

How to Enable.

Login to mysql as root user.

mysql -u root –p

Setup cache size 16Mb:

mysql> SET GLOBAL query_cache_size = 16777216;

To check this

mysql> SHOW VARIABLES LIKE 'query_cache_size'; 

Result:

 +------------------+----------+
| Variable_name    | Value    |
+------------------+----------+
| query_cache_size | 16777216 |
+------------------+----------+

Then open my.cnf file, Append config directives as follows:

query_cache_size = 268435456
query_cache_type=1
query_cache_limit=1048576

In this example maximum size of individual query results that can be cached
set to 1048576 using query_cache_limit system variable
Posted by sibu on March 10, 2009

Upgrading Perl version on Cpanel server

To check to see the current version

perl -V

To upgrade your perl on the Cpanel server

1)

wget http://layer1.cpanel.net/perl587installer.tar.gz
tar -vzxf perl587installer.tar.gz
cd perl587installer
./install

2)
/usr/local/cpanel/bin/checkperlmodules
/scripts/upcp –force

Posted by sibu on March 10, 2009

Difference between soft link and hard link

Hard Links :

1. All Links have same inode number.

2.ls -l command shows all the links with the link column(Second) shows No. of links.

3. Links have actual file contents

4.Removing any link ,just reduces the link count , but doesn’t affect other links.

Soft Links(Symbolic Links) :

1.Links have different inode numbers.

2. ls -l command shows all links with second column value 1 and the link points to original file.

3. Link has the path for original file and not the contents.

4.Removing soft link doesn’t affect anything but removing original file ,the link becomes “dangling” link which points to nonexistant file.

Powered By Wordpress - Theme Provided By Wordpress Themes - Auto Loan Credit