enable gzip compression on apache server

How to enable GZip compression on Apache Server?

How to enable GZip compression on Apache Server

How to enable GZip compression on Apache Server

GZip compression is used to increase speed of web page in your site. Your browser send request to server and get all the images, javascript and css files from server. When your web page have lots of images, javascript and css files than its take time to load. GZip compression gives boost to your website speed and save bandwidth as well.
In a very simple language, GZip compress all the data and send to browser. All the latest browser understands and accept compressed files.
There are two major ways to enable the GZip Compression on the Apache Server web-sites.

1) Using httpd

You need to install mod_deflate module, if it is not installed than you can download it from Apache httpd Modules and add it to httpd modules directory on your server.

Once you add mod_deflate module in your httpd modules directory, you completed half work. Now open your “httpd.conf” file and search for “mod_deflate”. You will find the following line

 
LoadModule deflate_module modules/mod_deflate.so

If it is commented than uncomment it, so it will LoadModule directive for mod_deflate.

Now we need to create a Deflate Rule Set which tells your apache server that compress which types of file.

Create “httpd-deflate.conf” file and copy following code in that file

 
#Set GZip for all output
SetOutputFilter DEFLATE
 
#Not Include the below file types
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|iso|tar|bz2|sit|rar|png|jpg|gif|jpeg|flv|swf|mp3)$ no-gzip 
 
#Use compression Level
DeflateCompressionLevel 9
 
#You can Handle browser specific compression using following rules
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

Now, open “httpd.conf” file and add following code

 
# Deflate configuration
include <path of file>/httpd-deflate.conf

Now restart your Apache Server and its working GZip Compression. Your website will load 60% faster than before.

2) Using .htaccess file

You can add following code in your htaccess file

 
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

If above code is not working than you can try another code which is as below

 
<ifModule mod_gzip.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</ifModule>

Dynamically add ckeditor textarea using javascript

CKEditor textarea add dynamic using javascript

CKEditor textarea add dynamic using javascript

Are you looking for the solution of the following questions than here is the solution to add dynamic CKEditor textarea.

How to add CKEditor Textarea runtime using javascript?
How to add CKEditor Textarea Dynamically using javascript?
How to add CKEditor Textarea runtime using jQuery?
How to add CKEditor Textarea Dynamically using jQuery?
CKEditor textarea add dynamic using javascript.

When you are working with CMS or webpage where you need the functionality to do “Add More” which will add new textbox, checkbox, radio button or select dropdown than you can do it easily. Even you can add simple textarea as well with normal code but when you need to insert CKEditor at runtime than may be you stuck.

I am here to help you, Simple code to add CKEditor textarea dynamically at runtime without refresh the page. You can use this code to add CKEditor textarea at runtime.

 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 <script type="text/javascript" src="../includes/ckeditor/ckeditor.js"></script>
 <script src="../includes/ckeditor/adapters/jquery.js"></script>
 
 var counter = 1;
 
 function AddMoreTextEditor()
 {
   var newtxtname = 'txtNew' + counter;
   var newTextArea = '<textarea rows="10" cols="50" class="ckeditor" name="' + newtxtname + '" id="' + newtxtname + '"></textarea>';
   $("#divid").html(newTextArea);
   $('textarea#' + newtxtname).ckeditor();
   counter++;
 }

please set “#divid” which is the placeholder here. You need to set the path of “ckeditor.js” and “jquery.js” as per your project. In above javascript code there is a function named “AddMoreTextEditor” to add new CKEditor textarea. Call this function from your “Add More” Link.

Please let me know if you need more help.

Cakephp hasMany and belongsTo with example

CakePHP offers excellent way for associations for linking models. There are 4 types of relationship in CakePHP which are as below.

1) hasone is used for One to one relationship.
2) hasMany is used for one to many relationships.
3) belongsTo is used for many to one relationship.
4) hasAndBelongsToMany is used for many to many relationship.

Cakephp Associations Linking Models  Relationship Types with example

Cakephp Associations Linking Models Relationship Types with example

Have a look on the example and explanation of hasMany and belongsTo relationship.

Example

This example is useful to understand Category and Product relationship in cakephp.

Category table have two fields “id” and “CategoryName”.

Product table have three fields “id”, “category_id” and “ProductName”. You can add as many fields as you want in product table but I took only 3 to explain the relationship with category.

 
class Category extends AppModel {
    public $order = "CategoryName";
 
    public $hasMany = array(
        'Product' => array(
            'className' => 'Product',
            'foreignKey' => 'category _id',
            'dependent' => true
        )
    );
}

In the Category model class, each category have either one or more than one products. when you are doing association like this than you have to use “hadMany” relationship in CakePHP. I define that “category_id” is a foreignkey in product table. Example of CakePHP “hasMany” relationship type.

 
class Product extends AppModel {
    public $order = "ProductName";        
 
    public $belongsTo = array(
            'Category' => array(
                'className' => ' Category ',
                'foreignKey' => 'category_id'
            )
        );
}

In the Product model class, each product belongs to any one category. I define that “category_id” is a foreignkey in product table. Example of CakePHP “belongsTo” relationship type.

Many developer confuse here and try to use CakePHP “hasOne” relationship type in product model class which will not work at all. I hope that, this example is useful to clear your confusion about the CakePHP relationship types.

SSL Server Supports Weak Encryption for SSLv3, TLSv1 in PCI scans results

SSL Server Supports Weak Encryption for SSLv3, TLSv1 in PCI scans results

SSL Server Supports Weak Encryption for SSLv3, TLSv1 in PCI scans results

Recently, one of my clients ran PCI Scan for his web-site which is hosted on the LAMP environment. He find the below issues in the scans result page.

1) SSL Server Supports Weak Encryption for SSLv3, TLSv1
2) SSL Server Supports CBC Ciphers for SSLv3, TLSv1
3) SSL Server Supports Weak MAC Algorithm for SSLv3, TLSv1

[Resolved]: You need to do some configuration in https.conf file. Please add below rule in your https.conf file and restart apache will fix SSL Server Supports Weak Encryption for SSLv3, TLSv1 issue.

[Resolved]: You need to disable cipher suites using CBC ciphers to fix SSL Server Supports CBC Ciphers for SSLv3, TLSv1 issue.

[Resolved]: You need to disable cipher suites using MD5 based MAC algorithms to fix SSL Server Supports Weak MAC Algorithm for SSLv3, TLSv1 issue.

How to configure DNS to point to a static or dynamic IP address

configure DNS to point to a static or dynamic IP address

configure DNS to point to a static or dynamic IP address

Now, everything is available on internet and you can grow your business using internet marketing. To grow your business, you have to develop your own web-site and apps which will be helpful in internet marketing. You need domain and web server to host your web-site. I am working as a freelance web developer because of that I have knowledge of domain and hosting. Many times my clients ask me that they have their own static IP address. can my computer become a server for my own web-site?

Question

What is my name server if I use my pc as a server using static IP address?
How to configure DNS to point to a dynamic IP address?

Answer

You can use your IP address in place of Name servers. Nameservers are hosted service, if you know than you can install a DNS server in your computer. IIS or Apache server doesn’t have anything to do with DNS.

It is not required that you have a static IP address to act your computer as a web-server. You can create web server even your IP address is not static but dynamic. You can use ddclient services which will update the DDNS server when your IP is dynamic IP address.

My domain points to two different IP addresses after DNS nameserves change

Domain points to two different IP addresses after DNS  change

Domain points to two different IP addresses after DNS change

One of my friends faces the issue where his domain name (testing .com) pointing to two different IP addresses once he changed his DNS nameserves.
He told me that his domain (testing.com) points to IP address xxx-xxx-xxx-xxx before he changed his DNS nameservers
Then he changed his domain (testing.com) DNS nameserves and the new IP address is xxx-xxx-xxx-xxx.

After some time he use ping command to check the reply and he was wondering because he got reply from Both IP addresses. When he visit web-site url from browser than facing issue in data loading. Sometimes its loads web-page and sometimes doesn’t load web-page.

If you are facing the same issue than no need to worry, this issue resolved automatically. Let me explain why these issues arise?

DNS resolvers receive lots of requests daily and because of that they DNS resolver cache requests. Your domain points to first IP address before you change the DNS which is in cache. When you change your DNS nameservers than its points to new IP address but it doesn’t clear cache immediately. Existing cache points to old IP address, this is the reason why its points to both IP addresses.

Once the cache has been cleared than its will points to new IP address only.

How the domain name and domain DNS servers work and not working

How the domain name and DNS nameservers work

How the domain name and DNS nameservers work

I know many people who are not technical have lots of question about domain name and DNS name servers.

How the domains work?

How to park my domain?

What is nameservers?

What is DNS?

You are registering your domain on godaddy or any web-site which allowed you to purchase domain name. Once you purchase domain, you need to park your domain. To park domain you need to setup the DNS nameservers.

You get your DNS nameserves from your hosting provider where you host your web-site. This is the way to linkup your domain with your web-site pages.

Now, let’s see how it works when user type domain name in browser.

  • Computer send request to the ISP (Internet service provider) resolver to find out the IP Address of your domain name.
  • ISP (Internet service provider) resolver send request to the “.” Name server.
  • Once “.” Name server receive request than response back to ISP (Internet service provider) resolver to try using the com. Nameserver.
  • Now, after getting response ISP (Internet service provider) resolver send request to com. Nameserver.
  • The com. Nameserver look in to glue records for your domain and send the DNS nameservers information to your ISP (Internet service provider) resolver.
  • Now, ISP (Internet service provider) resolvers have the DNS nameserver for your domain, so send request for the web-page of your domain.
  • ISP (Internet service provider) resolvers send web-page to your computer browser to display.

 

 

As you change your DNS nameservers record in your domain account, that domain points to the hosting server. You need to understand domain name and web hosting before you plan to start your own web-site.

Google launch driverless cars to California State in USA

Google will launch driverless cars in California State. First driverless cars will be shown on the street of California City. Google confirm that this car are self-driving cars and drive comfortably on the freeways. In the city there are lots of big challenges for Google’s driverless car, because there are lots of pedestrian, bicyclists and most challenging is blind zone.

Google launch driverless cars to California State in USA

Google launch driverless cars to California State in USA

Google says that new self-driving smart car can handle lots of urban situation but they are working to make car’s computer more batter to handle the walker, motorist which includes bikes and bicyclists and blind zone of the car.

Google X lab’s project director Chris Urmson said “We are growing more optimistic that we are heading toward an achievable goal a vehicle that operates fully without human intervention”.

Google will launch this driverless car for public in 2017. On initial stage google prefer that human drivers would be ready to take control of the driveless car when car computer is not able to control the situation. This driverless car will be awesome for long drive on freeways where you can read, eat, play a game on computer, watch movies or TV shows and sleep as well. Google says that one day car computer will work safer than human driver. Once this driverless smart car will launched that may be its reduce the accident made by human’s mistake.

Google and car makers working on this smart project for driverless car, where sensors fitted in this car give the 3D maps surrounding the car to the google software. Google software use this 3D map and detect the pedestrians, motorist including bikes and bicycles, moving vehicles and other objects like curbs, parked car, walk way and signs. Google software is also read signals, stop sign and school crossing guards.

Source: The Hindu
Image Source: The Hindu