wamp server

Add virtual hosts to wamp server on localhost

Pinterest

Often we come across situations where we need  a site to access directly without localhost on local computer. For example if one source code is accessed by more then one domains, achieving this on localhost is not possible without virtual hosts. Here are a few steps to add virtual hosts on windows 7 with wamp server installation.

      1. Go to windows start menu, right click the notepad and click the option “run as administrator”
      2. In notepad go to file menu, open then go Windows -> System32 -> drivers->etc. You will find this folder empty on notepad, on bottom right of the dialog box select “All files” , and then you will see the files in etc folder.  Select the host file and then open.
      3. Add a line in the end of file as
        127.0.0.1    siteA
        127.0.0.1    siteB
        127.0.0.1    siteC
      4. save the host file and go to wamp server’s httpd.conf file. Find the line#Include conf/extra/httpd-vhosts.confRemove the leading # from the line and save the file
      5. Find the apache installation and the file conf/extra/httpd-vhosts.conf
      6. Add the virtual host entries as below
           <VirtualHost *:80>
            ServerAdmin admin@localhost.com
            DocumentRoot "H:\Wamp\www"
            ServerName localhost
            <Directory "H:\Wamp\www">
                        Options Indexes FollowSymLinks
                    Order allow,deny
                    Allow from all
                </Directory>
        </VirtualHost>
        
        <VirtualHost *:80>
            ServerAdmin admin@localhost.com
            DocumentRoot "H:\Wamp\www\multsite"
            ServerName sitA
            <directory "H:\Wamp\www\multsite">
                Options Indexes FollowSymLinks
                Order Allow,Deny
                Allow from all
            </directory>
        </VirtualHost>
        
        <VirtualHost *:80>
            ServerAdmin admin@localhost.com
            DocumentRoot "H:\Wamp\www\multsite"
            ServerName siteB
            <directory "H:\Wamp\www\multsite">
                Options Indexes FollowSymLinks
                Order Allow,Deny
                Allow from all
            </directory>
        </VirtualHost>
        
        <VirtualHost *:80>
            ServerAdmin admin@localhost.com
            DocumentRoot "H:\Wamp\www\site3"
            ServerName siteC
            <directory "H:\Wamp\www\site3">
                Options Indexes FollowSymLinks
                Order Allow,Deny
                Allow from all
            </directory>
        </VirtualHost>
      7. Save the file and restart all services of wampserver.

Now you can access the “multisite” folder via browser as  http://site1/ and http://site2/ . You can access “site3” as http://site3/ and also with localhost as http://localhost/site3

how to make a pull request on github

How to make a pull request on github

Pinterest

In order to make a pull request you need to do the following steps:

  1. Fork a repository (to which you want to make a pull request). Just click the fork button the the repository page and you will have a separate github repository preceded with your github username.
  2. Clone the repository to your local machine. The Github software that you installed on your local machine can do this for you. Click the clone button beside the repository name.
  3. Make local changes/commits to the files
  4. sync the changes
  5. go to your github forked repository and click the “Compare & Review” green button besides the branch button. (The button has icon – no text)
  6. A new page will open showing your changes and then click the pull request link, that will send the request to the original owner of the repository you forked.

It took me a while to figure this, hope this will help someone else.

Cakephp 1.3 compatibility with latest PHP version

PHP 5.3 and Cake PHP 1.3 compatiblilty

Pinterest

Cake PHP 2.x is a whole new structure and if you want to migrate to cake version 2.x from 1.3 you will need many code changes to your application. I have done more then 15 sites with cake 1.3 so it becomes very difficult to do the changes to all the sites. If you want to update from Cake PHP 1.3 to Cake PHP 2.x this answer on stackoverflow can help you out.

The problem with Cake 1.3 older versions is that they work with PHP version < 5.3, however usually you need to update php version on server. There is a simple approach to configure a cake 1.3 (older version) that work with latest version of PHP (>= 5.3).

Step1: Download the latest Cake PHP 1.3 version.

Step2: Extract the cake folder and replace in your existing cake 1.3 project

Step3: Open app/config/core.php file and add the timezone settings at the end of file as

date_default_timezone_set(‘America/New_York’);

You can use the timezone_identifier of your area.

That’s it… your site can now run on the most recent version of PHP. Hope this help someone.

 

 

Match a fulltext search with less then 4 characters using ft_min_word_len

Pinterest

MySQL has support for full-text indexing and searching with the match function against a string value. MySQL find words out of the string and match them in the rows. By default a word is less then 4 characters, mysql ignore it. Also dash (“-“) in the search string is considered as word separator by default.

So a search on a field with string “7RC-R46″ will not find any result even they exist. Its because both the words have less then 4 characters. To fix this issue we have to

1) Change/add MySQL server variable in mysql config files like my.ini or mysql.conf as

ft_min_word_len = 3

2) Restart mysql server

3) Repair the table with the full text search index using repair query as

repair table table_name

This should work!

Hide Related Videos in YouTube using iFrame

Pinterest

When you add YouTube videos using iFrame, and don’t want people to watch related videos that are not from your company or organization after they finish watching your video.

You can remove this feature as follow!

If you embed a YouTube video, it will look something like this:

<iframe title="YouTube video player" width="600" height="400" src="http://www.youtube.com/embed/ABCDEFGHI12" frameborder="0" allowfullscreen></iframe>

All you need to do is add this to the end of the src URL:

?rel=0

So, the final code in this case would be:

<iframe title="YouTube video player" width="600" height="400" src="http://www.youtube.com/embed/ABCDEFGHI12?rel=0" frameborder="0" allowfullscreen></iframe>

Turn off automatic p tags insertion, in CKEditor

Pinterest

Best way to turn off automatic <p> tags insertion in CKEditor is to put the following block of code in ckeditor/config.js file

config.enterMode = CKEDITOR.ENTER_BR; config.shiftEnterMode = CKEDITOR.ENTER_BR; 

So that the file code becomes

CKEDITOR.editorConfig = function( config ) { config.enterMode = CKEDITOR.ENTER_BR; config.shiftEnterMode = CKEDITOR.ENTER_BR; }; 

Installing WordPress blog as a separate directory on a CakePHP application

Pinterest

CakePHP is a powerful Rapid Application Development framework, while WordPress is a great Blog software. Often we need to combine the power of these two frameworks. Today we will see how we can achieve this.

Step 1. Unzip the WordPress files and upload to root folder, rename the wordpress folder to “blog” so the root folder look like Continue reading

How to Keep WordPress From Overwriting .htaccess Rules

Pinterest

Well WordPress has a habit of rewriting the .htaccess file to allow some of the SEO-friendly URLs you regularly see (also known as ‘permalinks’). And each time it does so I lose my rules.

WordPress .htaccess file looks like this:

# BEGIN wordpress
<ifmodule mod_rewrite.c>
rewriteEngine On
rewriteBase /
rewriteCond %{REQUEST_FILENAME}!-f
rewriteCond %{REQUEST_FILENAME}!-d
rewriteRule . /index.php [L]
</ifmodule>
# END wordpress

Now here’s the really important bit: Continue reading