Dipak's Blog http://www.iamdipak.in Freelancing - Blogging Sat, 12 Nov 2016 07:50:36 +0000 en-US hourly 1 https://wordpress.org/?v=4.6.6 99774504 How To Fix Incorrect Post Comment Counts In WordPress http://www.iamdipak.in/fix-incorrect-post-comment-counts-wordpress/ http://www.iamdipak.in/fix-incorrect-post-comment-counts-wordpress/#respond Sat, 12 Nov 2016 07:49:15 +0000 http://www.iamdipak.in/?p=686 If your WordPress comment counts got messed up, whether because of a plugin or you messed with your database manually and did something wrong, then there is always a solution for this 🙂

The post How To Fix Incorrect Post Comment Counts In WordPress appeared first on Dipak's Blog.

]]>
If your WordPress comment counts got messed up, whether because of a plugin or you messed with your database manually and did something wrong, then there is always a solution for this 🙂

Comment Counts In WordPress

Here’s how comment counts work in WP:

  • Posts live in a table called wp_posts and each has an ID.
  • Comments reside in a table called wp_comments, each referring to an ID in wp_posts.
  • However, to make queries faster, the comment count is also cached in the wp_posts table, rather than getting calculated on every page load.

If this count ever gets out of sync with the actual number of comments for some reason, WordPress, while still displaying all comments properly, will simply show the wrong count.

How To Find Out Which Posts Are Out Of Sync

Fire up a MySQL shell or your favorite MySQL software and run this query.

It assumes your database is called wordpress and the prefix is wp_, so adjust those accordingly.

SELECT wpp.id, wpp.post_title, wpp.comment_count, wpc.cnt
FROM wordpress.wp_posts wpp
LEFT JOIN
(SELECT comment_post_id AS c_post_id, count(*) AS cnt FROM wordpress.wp_comments
 WHERE comment_approved = 1 GROUP BY comment_post_id) wpc
ON wpp.id=wpc.c_post_id
WHERE wpp.post_type IN ('post', 'page')
      AND (wpp.comment_count!=wpc.cnt OR (wpp.comment_count != 0 AND wpc.cnt IS NULL));

The result of this query is a list of posts whose comment_counts differ from the actual number of comments associated with each of them.

The left count is the cached number, while the right one is the right one.

How To Fix The Counts Automatically

Please make a backup of your database before performing any altering queries such as the one below.

The following query will recalculate and fix the comment counts for all posts that are out of sync (ones we just queried for above):

UPDATE wordpress.wp_posts wpp
LEFT JOIN
(SELECT comment_post_id AS c_post_id, count(*) AS cnt FROM wordpress.wp_comments
 WHERE comment_approved = 1 GROUP BY comment_post_id) wpc
ON wpp.id=wpc.c_post_id
SET wpp.comment_count=wpc.cnt
WHERE wpp.post_type IN ('post', 'page')
      AND (wpp.comment_count!=wpc.cnt OR (wpp.comment_count != 0 AND wpc.cnt IS NULL));

This will fix all your issues regarding comment count for sure.

Reference beerpla.net

Happy Coding 🙂

The post How To Fix Incorrect Post Comment Counts In WordPress appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/fix-incorrect-post-comment-counts-wordpress/feed/ 0 686
How to Remove Ads in Skype On Windows http://www.iamdipak.in/how-to-remove-ads-in-skype-on-windows/ http://www.iamdipak.in/how-to-remove-ads-in-skype-on-windows/#respond Sun, 04 Oct 2015 08:13:12 +0000 http://iamdipak.in/?p=649 When using Skype the other day I noticed a new ad placement that hadn’t been there before. Of course I found it annoying and wanted to get rid of it. Here’s how to get rid of that top banner ad in Skype by following some simple steps.

The post How to Remove Ads in Skype On Windows appeared first on Dipak's Blog.

]]>
When using Skype the other day I noticed a new ad placement that hadn’t been there before. Of course I found it annoying and wanted to get rid of it. Here’s how to get rid of that top banner ad in Skype by following some simple steps.

For Skype 7.x Only :

Step 1: Head to the Control Panel and click on Internet Options. This settings area may be hidden under Network and Sharing Center if you don’t see a direct shortcut for it.

internet_options

Step 2: Click on the Security tab and select the Restricted Sites icon.

Step 3: Press the Sites button and add the following sites to block the ads.

apps.skype.com

rad.msn.com

g.msn.com

restricted_sites

Step 4: Head to C:\users\[your user name]\App Data\Roaming\Skype\[your Skype username]. You should see a config.xml file in this directory. Right-click it and choose Edit, then find the line that says <AdvertPlaceholder> and delete the entire line. Make sure to save your changes to the file before exiting. You can use Ctrl+F to find the line quickly.

Note: If you do not see the App Data folder, it’s probably because you don’t have Show hidden files enabled. Click the Organize button > Folder and search options > View tab > mark the radio button next to Show hidden files, folders, or drives.

Now your chat window and video conferences will be free of advertisements.

The post How to Remove Ads in Skype On Windows appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/how-to-remove-ads-in-skype-on-windows/feed/ 0 649
Delete Orphaned Meta Data in WordPress http://www.iamdipak.in/delete-orphaned-meta-data-in-wordpress/ http://www.iamdipak.in/delete-orphaned-meta-data-in-wordpress/#respond Sun, 04 Oct 2015 04:35:07 +0000 http://iamdipak.in/?p=647 Delete Post Meta Data

Sometimes while developing a new plugin you have to do lots of database work including creating posts, editing posts, and deleting posts. All of these actions affect the post meta data table and if you aren’t careful with how to manage the post meta data you’ll have thousands and thousands of rows of data. By deleting orphaned post meta data (meta data belonging to posts which no longer exist) you immediately remove thousands of records that weren’t doing anything.
[crayon-594f956d9b5d4878066105/]

The post Delete Orphaned Meta Data in WordPress appeared first on Dipak's Blog.

]]>
Delete Post Meta Data

Sometimes while developing a new plugin you have to do lots of database work including creating posts, editing posts, and deleting posts. All of these actions affect the post meta data table and if you aren’t careful with how to manage the post meta data you’ll have thousands and thousands of rows of data. By deleting orphaned post meta data (meta data belonging to posts which no longer exist) you immediately remove thousands of records that weren’t doing anything.

DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL

Delete User Meta Data

DELETE um
FROM wp_usermeta um
LEFT JOIN wp_users wp ON wp.ID = um.user_id
WHERE wp.ID IS NULL

Source : speakinginbytes.com

Happy Coding 🙂

The post Delete Orphaned Meta Data in WordPress appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/delete-orphaned-meta-data-in-wordpress/feed/ 0 647
How To Add Custom Rewrite Rules In WordPress http://www.iamdipak.in/how-to-add-custom-rewrite-rules-in-wordpress/ http://www.iamdipak.in/how-to-add-custom-rewrite-rules-in-wordpress/#respond Mon, 20 Jul 2015 10:22:41 +0000 http://iamdipak.in/?p=638 WordPress rewrite API used to convert URLs from something programmatically convenient to something user and search engine friendly. This article will give you some background information about WordPress URL rewriting principles and API.

The post How To Add Custom Rewrite Rules In WordPress appeared first on Dipak's Blog.

]]>
WordPress rewrite API used to convert URLs from something programmatically convenient to something user and search engine friendly. This article will give you some background information about WordPress URL rewriting principles and API.

What Is Rewriting?

URL rewriting is when you change what content is displayed by the server, normally when you type in a URL the web server will simply search for any files in that location. But with rewriting you can still show the same URL but in the back-end change where the server will look for the content. Therefore we can have a URL of /website-1 but tell the server to display content that is located in /website-1/content/index.php

How WordPress Uses Rewrite For Custom URLs?

When you go to Settings -> Permalinks, you will need to select how you want your URLs to appear on WordPress. You have many different options to choose from the default WordPress will use is ?p={post_id}, this is the value that is stored in the wp_posts table and what the rewrite API will write to, when it wants to display the post data.

When you select a new permalink structure WordPress will store these rules in the wp_options table so it will know how to search the post table for the correct post. This means that we can have URLs with just the post title in them and WordPress will know that it needs to search on the post_name column to find the correct post to display.

WordPress Rewrite API

Imagine you need to integrate custom page in which you can list your products. How can we do this?..First we need to create a new rewrite rule so wordpress can translate example.com/products/2/edit to example.com/index.php?pagename=products&product_id=2&action=edit. We can use add_rewrite_rule() function which accepts 3 parameters. The first parameter is the URL pattern. The second parameter is the URL replacement and the third parameter is the priority. Let’s explore how to create this rule.

function product_rewrites_init() {

    add_rewrite_rule('^products/([0-9]*)/([a-zA-Z]*)', 'index.php?pagename=products&product_id=$matches[1]&action=$matches[2]', 'top');
}
add_action('init', 'product_rewrites_init');

function product_query_vars($query_vars) {

    $query_vars[] = 'product_id';
    $query_vars[] = 'action';

    return $query_vars;
}
add_filter('query_vars', 'product_query_vars');

Catching the query variables

function products_plugin_display() {
    $product_id = get_query_var('product_id');
    $action = get_query_var('action');
    if ('edit' == $action && '' == $product_id):
	//show all products
        exit;
    elseif ('edit' == $action && '' != $product_id):
	//show product edit page
	exit;
    endif;
}

Using with plugin Activation and Deactivation

//register activation function
register_activation_hook(__FILE__, 'products_plugin_activate');

//register deactivation function
register_deactivation_hook(__FILE__, 'products_plugin_deactivate');

function products_plugin_activate() {
    product_rewrites_init();
    flush_rewrite_rules();
}

function products_plugin_deactivate() {
    flush_rewrite_rules();
}

Copy Blog 🙂

The post How To Add Custom Rewrite Rules In WordPress appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/how-to-add-custom-rewrite-rules-in-wordpress/feed/ 0 638
Disable Update WordPress nags with Plugin’s and Theme’s Update Notifications http://www.iamdipak.in/disable-update-wordpress-nags-with-plugins-and-themes-update-notifications/ http://www.iamdipak.in/disable-update-wordpress-nags-with-plugins-and-themes-update-notifications/#respond Tue, 03 Mar 2015 09:59:35 +0000 http://iamdipak.in/?p=628 1. To Disable Update WordPress nag :

Insert the following code to the functions.php file of your active theme. It will remove the WordPress update nag e.g. WordPress 3.9.1 is available! Please update now, from the all users dashboard, admin dashboard & from Updates page as well.
[crayon-594f956d9beb9175023605/]

The post Disable Update WordPress nags with Plugin’s and Theme’s Update Notifications appeared first on Dipak's Blog.

]]>
1. To Disable Update WordPress nag :

Insert the following code to the functions.php file of your active theme. It will remove the WordPress update nag e.g. WordPress 3.9.1 is available! Please update now, from the all users dashboard, admin dashboard & from Updates page as well.

add_action('after_setup_theme','remove_core_updates');
function remove_core_updates()
{
    if(! current_user_can('update_core')){return;}
    add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
    add_filter('pre_option_update_core','__return_null');
    add_filter('pre_site_transient_update_core','__return_null');
}

2. To Disable Plugin Update Notifications :

Insert the following code to the functions.php file of your active theme. It will remove the update notifications of all the installed plugins.

remove_action('load-update-core.php','wp_update_plugins');
add_filter('pre_site_transient_update_plugins','__return_null');

3. To Disable all the Nags & Notifications :

Insert the following code the functions.php file of your active theme. This code disables all the updates notifications regarding plugins, themes & WordPress completely.

function remove_core_updates(){
    global $wp_version;
    return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');

The post Disable Update WordPress nags with Plugin’s and Theme’s Update Notifications appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/disable-update-wordpress-nags-with-plugins-and-themes-update-notifications/feed/ 0 628
Test Credit Card Account Numbers http://www.iamdipak.in/test-credit-card-account-numbers/ http://www.iamdipak.in/test-credit-card-account-numbers/#respond Tue, 17 Feb 2015 05:23:46 +0000 http://iamdipak.in/?p=619 Credit card numbers are not random. They can be checked by a mathematical formula for validity. Each kind of credit card uses a slightly different rule.

The post Test Credit Card Account Numbers appeared first on Dipak's Blog.

]]>
Credit card numbers are not random. They can be checked by a mathematical formula for validity. Each kind of credit card uses a slightly different rule.

This sample form checks credit cards for validity, so you must enter a valid credit card number. While testing, only use the credit card numbers listed here. Other numbers produce an error.

Expiration Date must be a valid date in the future (use the mmyy format).

Test Credit Card Account Numbers

Credit Card Type

Credit Card Number

American Express

378282246310005

American Express

371449635398431

American Express Corporate

378734493671000

Australian BankCard

5610591081018250

Diners Club

30569309025904

Diners Club

38520000023237

Discover

6011111111111117

Discover

6011000990139424

JCB

3530111333300000

JCB

3566002020360505

MasterCard

5555555555554444

MasterCard

5105105105105100

Visa

4111111111111111

Visa

4012888888881881

Visa

4222222222222

Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.

Processor-specific Cards

Dankort (PBS)

76009244561

Dankort (PBS)

5019717010103742

Switch/Solo (Paymentech)

6331101999990016

The post Test Credit Card Account Numbers appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/test-credit-card-account-numbers/feed/ 0 619
How To Install LAMP on Ubuntu http://www.iamdipak.in/install-lamp-ubuntu/ http://www.iamdipak.in/install-lamp-ubuntu/#respond Thu, 12 Feb 2015 09:06:51 +0000 http://iamdipak.in/?p=608 About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

The post How To Install LAMP on Ubuntu appeared first on Dipak's Blog.

]]>
About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

First things first: update

sudo apt-get update
sudo apt-get upgrade

LAMP Stack (Apache, Mysql, PHP)

This will install the LAMP stack in one command

sudo apt-get install lamp-server^

Apache

sudo apt-get install apache2 libapache2-mod-php5

MySQL

sudo apt-get install mysql-server mysql-client

PHP 5

Want a more recent version of PHP 5 for Ubuntu? Then use the PPA for PHP5 offered by Ondřej Surý. PHP 5.4+

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:<wbr></wbr>ondrej/<wbr></wbr>php5-oldstable
sudo apt-get update
sudo apt-get install php5 php5-gd php5-mysql php5-curl php5-cli php5-cgi php5-dev php5-fpm

PHP 5.5+ note: there are significant differences between PHP 5.4. and PHP 5.5!

sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install php5 php5-gd php5-mysql php5-curl php5-cli php5-cgi php5-dev

PHP 7.0 (prior to Ubuntu 16.04)

sudo apt-get install python-software-properties
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y

NGINX

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server.

sudo apt-get install nginx

NGINX doesn’t start on its own, so:

sudo service nginx start

Learn about configuring NGINX as a front-end proxy with Apache

phpMyAdmin

phpMyAdmin allows you to manage your MySQL Database via web browser.

sudo apt-get install phpmyadmin

Choose Apache and then YES for dbconfig-common. If you ever need to edit phpMyAdmin config:

sudo nano /etc/dbconfig-common/phpmyadmin.conf

Webmin

Webmin is an open-source server management tool much like cPanel.

sudo nano /etc/apt/sources.list

Scroll to the bottom and paste the following lines then save:

deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Import the key

wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc

Update the sources list

sudo apt-get update

Run the install

sudo apt-get install webmin

Start Webmin

sudo /etc/webmin/start

When it’s finished, open Firefox or Chrome and type:

http://localhost:10000/ (or if on a network) http://your-server-ip:10000/

If you’ve installed a fresh copy of Ubuntu (or if you don’t know your password) you can set a new one:

sudo passwd ubuntu

You’ll be prompted to enter your new password twice. Now, you can login to Webmin.

ProFTPd

ProFTPd is a high-performance FTP server.

sudo apt-get install proftpd

(I always select “standalone”) Turn on Passive FTP via Webmin: Servers –> ProFTPD server –> Virtual Servers –> Default Server –> Networking Options

Masquerade as address = your-server-outside-ip

PASV Port Range: 1024-1088

 Sendmail

sudo apt-get install sendmail

PostFix Mail

sudo apt-get install postfix

Select “Internet Site” and then enter the domain name you want the Reverse DNS entry to be. BTW: To avoid your server being blacklisted, get a reverse DNS entry!

Alternative PHP Cache (APC)

APC is a PHP opcode cacher and works by caching PHP objects, functions, and database queries into your server’s RAM. If you run a WordPress website – then it takes full advantage of APC out-of-the-box. See my post on The Perfect APC Configuration Note, APC is no longer available in PHP 5.5+ as it’s now called OPCACHE.

sudo apt-get install php-apc

By default, Ubuntu will install this from a repository which has an outdated version. To install the latest version of APC:

sudo apt-get install make

sudo apt-get install libpcre3-dev

sudo apt-get install php-pear

sudo pecl install apc

sudo /etc/init.d/apache2 restart

Uninstall APC

sudo pecl uninstall apc

Memcached

Memcached is a high-performance, distributed memory object caching system. However, it can work together with multiple servers (unlike APC).

sudo apt-get install memcached
sudo apt-get install php-pear
sudo pecl install memcache

Check to see if Memcached is running

ps aux | grep memcached

Fail2Ban

Fail2Ban scans log files (e.g. /var/log/apache/error_log) and automatically bans IPs that show malicious signs for exploits.

sudo apt-get install fail2ban

RSYNC

RSYNC is a open source utility that provides fast incremental file transfer.

sudo apt-get install rsync

Server-to-server transfers with RSYNC

rsync -zvr /path/to/local/folder user@server.com:path/to/remove/folder

ImageMagick

ImageMagick is a software suite to create, edit, compose, or convert bitmap images.

sudo apt-get install imagemagick

Icecast2

Icecast is a streaming audio server. If you ever wanted to have your own web radio station (like Shoutcast) this is the software.

sudo apt-get install icecast2

Configure Icecast2. Mainly, setting up your passwords and default port.

sudo nano /etc/icecast2/icecast.xml

Enable init.d script. Scroll to the bottom and change enable=true

sudo nano /etc/default/icecast2/

Start icecast2

sudo /etc/init.d/icecast2 start

If you left the default port as 8000 then you can view your Icecast2 Server

http://your-server.com:8000/

Munin

Munin is a networked resource monitoring tool that can help analyze resource trends and “what just happened to kill our performance?” problems.

sudo apt-get install php-cli

Now, this is a single server setup, so let’s install munin and munin-node

sudo apt-get install munin munin-node

Configure Munin:

sudo nano /etc/munin/munin.conf

The first thing you should see is the operating directories. We need to change one of them:

# dbdir   /var/lib/munin
# htmldir /var/cache/munin/www
# logdir /var/log/munin
# rundir  /var/run/munin

to

# dbdir   /var/lib/munin
htmldir /var/www/munin
# logdir /var/log/munin
# rundir  /var/run/munin

Now let’s edit apache.conf

sudo nano /etc/munin/apache.conf

Delete everything inside apache.conf  and just add:

Alias /munin /var/www/munin

Move the web files to /var/www/munin

sudo mv /var/cache/munin/www/ /var/www/munin

Set permissions

sudo chown munin.munin -R /var/www/munin

Restart Munin

sudo /etc/init.d/munin-node restart

Finally, restart Apache

sudo /etc/init.d/apache2 restart

http://your-server.com/munin

Cacti

Cacti graphical server monitor provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box.

sudo apt-get install cacti-spine

Choose YES for dbconfig-common and Apache2. When finished you need to configure:

http://your-server-ip-address/cacti

Default user & pass: admin / admin Remove cacti

sudo apt-get remove cacti

BMON

bmon is a bandwidth monitor capable of retrieving statistics from various input modules.

sudo apt-get install bmon

When it’s finished installing:

bmon

Zip and Unzip

In my experience ZIP is great for creating archives for sharing via email or ftp. It’s a universal format that almost everyone can open. I would NOT use ZIP for file backups. For large backups, see 7ZIP or TAR below.

sudo apt-get install zip

Zip up a folder:

zip uploads-backup.zip /wp-content/uploads

Unzip (extract) an archive:

unzip uploads-backup.zip /wp-content/uploads

7ZIP

7ZIP is a very popular archiving program with excellent compression. Plus, it’s open source and supports multiple operating systems.

sudo apt-get install p7zip

Create an archive

7za a uploads-backup.7z /wp-content/uploads

Extract an archive

7za e uploads-backup.7z /wp-content/uploads

TAR (Tape Archive)

TAR –  is the prefered way to handle file backups. I’ve read, the maximum allowed file size only depends on your hard drive. A disk formatted with FAT32 for example, only allows 2GB. You can also compress TAR using GZIP or BZ2.

tar -cvf uploads-backup.tar /wp-content/uploads

GZIP – good compression, is very fast. Note: .tar.gz and .tgz are the same:

tar -cvzf uploads-backup.tgz /wp-content/uploads

BZ2 – excellent compression, but slower. I find BZ2 works best if you’re archiving a smaller directory. Note: .tar.bz2 and .tbz are the same:

tar -cvfj plugins-backup.tbz /wp-content/plugins

Untar (extract) an archive and if tarball already contains a directory name, strip it:

tar -xvf -backup.tar -C /DESTINATION/FOLDER --strip-components=1

If you want to tarball the directory you’re currently in, with say, gzip:

tar -cvzf backup.tar.gz .

Other handy commands:

View all running services

service --status-all

Restart PHP 7.0

sudo restart php7.0-fpm

Move files from one directory to another

mv -v /source-dir/* /destination-dir/

Copy files from one directory to another

cp -a /source-dir/. /destination-dir/

Set the server timezone

sudo dpkg-reconfigure tzdata

Add a user to the list of sudoers (you have to be logged in as root, or now the sudo password)

sudo adduser  sudo

Download files

wget http://example.com/wp-content/uploads/uploads-backup.tar

Server-to-server transfers with SCP

scp -P 22 -r user@remote-server.com:path/to/remote/folder path/to/local/folder

Server-to-server transfer with SCP into the current directory (Read more about SCP)

scp -P 22 -r user@remote-server.com:path/to/remote/folder .

List size of directories

du -a -h --max-depth=1 | sort -hr

Set a password

sudo passwd ubuntu

Edit PHP.ini

sudo nano /etc/php5/apache2/php.ini

Restart Apache

sudo /etc/init.d/apache2 restart

Set Recursive Permissions for your websites directory

sudo chmod -R 775 /PATH/TO/FOLDER

sudo chown -R www-data:www-data /PATH/TO/FOLDER

Block IP address using IPTABLES

Single IP

sudo iptables -I INPUT -s 192.168.100.1 -j DROP

IP Range

sudo iptables -I INPUT -s 192.168.100.0/24 -j DROP

You can also manage IPTABLES (e.g., the linux firewall) via Webmin under Networking -> Linux Firewall

Manage packages

sudo apt-get update &amp;&amp; sudo apt-get upgrade
sudo apt-get autoremove

Remove LAMP

sudo apt-get purge libapache2-mod-auth-mysql phpmyadmin
sudo apt-get purge mysql-server mysql-server-5.1 mysql-server-core-5.1
sudo apt-get purge apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5
sudo apt-get autoremove

Happy Coding 🙂

The post How To Install LAMP on Ubuntu appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/install-lamp-ubuntu/feed/ 0 608
Valid US Address for Developer Testing. http://www.iamdipak.in/valid-us-address-developer-testing/ http://www.iamdipak.in/valid-us-address-developer-testing/#comments Thu, 12 Feb 2015 09:03:25 +0000 http://iamdipak.in/?p=605 Many street addresses include a direction (e.g. E = EAST):
[crayon-594f956d9d92f516802354/]
An example with the optional latter 4 digits of the zip code:
[crayon-594f956d9d936487191314/]
With an apartment/suite/etc. number (which many addresses don’t have):
[crayon-594f956d9d939090903215/]
If you don’t have room for the apartment/suite/etc. number on the street address line:
[crayon-594f956d9d93d139673264/]
Many different terms for street type, or abbreviations for them, might follow the street name.
[crayon-594f956d9d940994226609/]
“PO Box” and “POB” are two valid ways of saying “Post Office Box.”
[crayon-594f956d9d943613861200/]
Some variants exist. In certain regions, some addresses have a direction after the street name.
[crayon-594f956d9d946618134023/]
If an address has two conflicting lines, such as a post office box line and a street address line, the lower line will normally be used if mail can be delivered to that address. Most often conflicting lines are not used.
[crayon-594f956d9d949764466416/]

The post Valid US Address for Developer Testing. appeared first on Dipak's Blog.

]]>
Many street addresses include a direction (e.g. E = EAST):

CHRIS NISWANDEE
   SMALLSYS INC
   795 E DRAGRAM
   TUCSON AZ 85705
   USA

An example with the optional latter 4 digits of the zip code:

JOHN "GULLIBLE" DOE
   CENTER FOR FINANCIAL ASSISTANCE TO DEPOSED NIGERIAN ROYALTY
   421 E DRACHMAN
   TUCSON AZ 85705-7598
   USA

With an apartment/suite/etc. number (which many addresses don’t have):

MARY ROE
   MEGASYSTEMS INC
   799 E DRAGRAM SUITE 5A
   TUCSON AZ 85705
   USA

If you don’t have room for the apartment/suite/etc. number on the street address line:

MARY ROE
   MEGASYSTEMS INC
   SUITE 5A-1204
   799 E DRAGRAM
   TUCSON AZ 85705
   USA

Many different terms for street type, or abbreviations for them, might follow the street name.

JANE ROE
   200 E MAIN ST
   PHOENIX AZ 85123
   USA

“PO Box” and “POB” are two valid ways of saying “Post Office Box.”

CHRIS NISWANDEE
   BITBOOST
   POB 65502
   TUCSON AZ 85728
   USA

Some variants exist. In certain regions, some addresses have a direction after the street name.

JOHN SMITH
   300 BOYLSTON AVE E
   SEATTLE WA 98102
   USA

If an address has two conflicting lines, such as a post office box line and a street address line, the lower line will normally be used if mail can be delivered to that address. Most often conflicting lines are not used.

JOHN SMITH
   100 MAIN ST
   PO BOX 1022
   SEATTLE WA 98104
   USA

The post Valid US Address for Developer Testing. appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/valid-us-address-developer-testing/feed/ 1 605
How To Set Up Apache Virtual Host on Ubuntu http://www.iamdipak.in/how-to-set-up-apache-virtual-host-on-ubuntu/ http://www.iamdipak.in/how-to-set-up-apache-virtual-host-on-ubuntu/#respond Wed, 11 Feb 2015 13:29:48 +0000 http://iamdipak.in/?p=591 Prerequisites

Before you begin this tutorial, you need to have Apache installed in order to work through these steps. If you haven’t already done so, you can get Apache installed on your server through apt-get:
[crayon-594f956d9de54325120536/]
After these steps are complete, we can get started.

The post How To Set Up Apache Virtual Host on Ubuntu appeared first on Dipak's Blog.

]]>
Prerequisites

Before you begin this tutorial, you need to have Apache installed in order to work through these steps. If you haven’t already done so, you can get Apache installed on your server through apt-get:

sudo apt-get update
sudo apt-get install apache2

After these steps are complete, we can get started.

For the purposes of this guide, my configuration will make a virtual host for example.com. This will be referenced throughout the guide, but you should substitute your own domains or values while following along.

I will show how to edit your local hosts file later on to test the configuration if you are using dummy values. This will allow you to test your configuration from your home computer, even though your content won’t be available through the domain name to other visitors.

Step One — Create the Directory Structure

The first step that we are going to take is to make a directory structure that will hold the site data that we will be serving to visitors.

Our document root (the top-level directory that Apache looks at to find content to serve) will be set to individual directories under the /var/www directory. We will create a directory here for the virtual host we plan on making.

Within this directory, we will create a public_html file that will hold our actual files. This gives us some flexibility in our hosting.

For instance, for our site, we’re going to make our directory like this:

sudo mkdir -p /var/www/example.com/public_html

Step Two — Grant Permissions

Now we have the directory structure for our files, but they are owned by our root user. If we want our regular user to be able to modify files in our web directory, we can change the ownership by doing this:

sudo chown -R $USER:$USER /var/www/example.com/public_html

The $USER variable will take the value of the user you are currently logged in as when you press “ENTER”. By doing this, our regular user now owns the public_html subdirectory where we will be storing our content.
We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

sudo chmod -R 755 /var/www

Your web server should now have the permissions it needs to serve content, and your user should be able to create content within the necessary folders.

Step Three — Create Demo Pages for Each Virtual Host

We have our directory structure in place. Let’s create some content to serve.

We’re just going for a demonstration, so our page will be very simple. We’re just going to make anindex.php page for this site.

Let’s start with example.com. We can open up an index.php file in our editor by typing:

nano /var/www/example.com/public_html/index.php

In this file, we will put a simple statement that indicates the site it is connected to. My file looks like this:

&lt; ?php echo “Success!  The example.com virtual host is working!”;

Save and close the file when you are finished. You now have the page necessary to test the virtual host.

Step Four — Create New Virtual Host Files

Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests.

Apache comes with a default virtual host file called 000-default.conf that we can use as a jumping off point. We are going to copy it over to create a virtual host file for our domain.

The default Ubuntu configuration requires that each virtual host file end in .conf.

Create the First Virtual Host File

Start by copying the file for the domain:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf

Open the new file in your editor with root privileges:

sudo nano /etc/apache2/sites-available/example.com.conf

The file will look something like this (I’ve removed the comments here to make the file more approachable):

ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

As you can see, there’s not much here. We will customize the items here for our first domain and add some additional directives. This virtual host section matches any requests that are made on port 80, the default HTTP port.

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.

ServerAdmin admin@example.com

After this, we need to add two directives. The first, called ServerName, establishes the base domain that should match for this virtual host definition. This will most likely be your domain. The second, calledServerAlias, defines further names that should match as if they were the base name. This is useful for matching hosts you defined, like www:

ServerName example.com
ServerAlias www.example.com

The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRootdirective to reflect the directory we created:

DocumentRoot /var/www/example.com/public_html

In total, our virtualhost file should look like this:

ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Save and close the file.

Step Five — Enable the New Virtual Host Files

Now that we have created our virtual host file, we must enable that. Apache includes some tools that allow us to do this.

We can use the a2ensite tool to enable our site like this:

sudo a2ensite example.com.conf

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

You will most likely receive a message saying something similar to:

* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message

This is a harmless message that does not affect our site.

<h2 “>Step Six — Set Up Local Hosts File (Optional)

If you haven’t been using actual domain names that you own to test this procedure and have been using some example domains instead, you can at least test the functionality of this process by temporarily modifying the hosts file on your local computer.

This will intercept any requests for the domains that you configured and point them to your VPS server, just as the DNS system would do if you were using registered domains. This will only work from your computer though, and is simply useful for testing purposes.

Make sure you are operating on your local computer for these steps and not your VPS server. You will need to know the computer’s administrative password or otherwise be a member of the administrative group.

If you are on a Mac or Linux computer, edit your local file with administrative privileges by typing:

sudo nano /etc/hosts

If you are on a Windows machine, you can find instructions on altering your hosts file here.

The details that you need to add are the public IP address of your VPS server followed by the domain you want to use to reach that VPS.

For the domains that I used in this guide, assuming that my VPS IP address is 111.111.111.111, I could add the following lines to the bottom of my hosts file:

127.0.0.1   localhost
127.0.1.1   guest-desktop
111.111.111.111 example.com

This will direct any requests for example.com on our computer and send them to our server at 111.111.111.111. This is what we want if we are not actually the owners of these domains in order to test our virtual hosts.

Save and close the file.

Step Seven — Test your Results

Now that you have your virtual host configured, you can test your setup easily by going to the domains that you configured in your web browser:

http://example.com

You should see a page that looks like this:

example

 

If this site works well, you’ve successfully configured the virtual host on the same server.

If you adjusted your home computer’s hosts file, you may want to delete the lines you added now that you verified that your configuration works. This will prevent your hosts file from being filled with entries that are not actually necessary.

Conclusion

If you followed along, you should now have a single server handling two separate domain names. You can expand this process by following the steps we outlined above to make additional virtual hosts.

There is no software limit on the number of domain names Apache can handle, so feel free to make as many as your server is capable of handling.

The post How To Set Up Apache Virtual Host on Ubuntu appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/how-to-set-up-apache-virtual-host-on-ubuntu/feed/ 0 591
Remove WordPress SEO columns from post table http://www.iamdipak.in/remove-wordpress-seo-columns-post-table/ http://www.iamdipak.in/remove-wordpress-seo-columns-post-table/#respond Wed, 11 Feb 2015 11:38:34 +0000 http://iamdipak.in/?p=573 The WordPress SEO plugin by Yoast is very popular, and for a good reason. It uses solid methodology, and is easy enough for folks to use who may not have a solid background in SEO.

The post Remove WordPress SEO columns from post table appeared first on Dipak's Blog.

]]>
The WordPress SEO plugin by Yoast is very popular, and for a good reason. It uses solid methodology, and is easy enough for folks to use who may not have a solid background in SEO.

That being said, there is a *lot* of data to be displayed. On the post editor, it’s not a big deal, as it’s contained in a metabox and can be minimized easily. But on the post table, it can crowd out other information, especially if you have other data being displayed in the post column. Below is a function that will remove the columns from the post table.

function rkv_remove_columns( $columns ) {

	// remove the Yoast SEO columns
	unset( $columns['wpseo-score'] );
	unset( $columns['wpseo-title'] );
	unset( $columns['wpseo-metadesc'] );
	unset( $columns['wpseo-focuskw'] );

	return $columns;

}
add_filter ( 'manage_edit-post_columns', 'rkv_remove_columns' );

This same function can be used on any post type, including pages and other custom post types. Simply change the manage_edit-post_columns to manage_edit-YOUR_POST_TYPE_columns

That’s it. The great thing about this function is that you can use it to remove other columns as well, for example the author column (if you’re the only writer on the site).

*UPDATE*  You can also uncheck the boxes on the post table under the ‘screen options’ tab. This will only apply to the current user, however.

The post Remove WordPress SEO columns from post table appeared first on Dipak's Blog.

]]>
http://www.iamdipak.in/remove-wordpress-seo-columns-post-table/feed/ 0 573