LNMP or Nginx Can’t Display the URL right in WordPress

If you using Nginx and wWordPress, and found that some of your pages can’t open or got 404 error or no right to manage the page, usually there are some problems with your site’s url.

Please go:


/usr/local/nginx/conf/vhost

Edit your site’s conf.

For example:

I opened my site’s conf

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.dobeweb.com dobeweb.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /h/www.dobeweb.com;

        include wordpress.conf;
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log off;
    }

Add the following code at the end of the config.


rewrite /wp-admin$ $scheme://$host$uri/ permanent;

Save.

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.dobeweb.com dobeweb.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /h/www.dobeweb.com;

        include wordpress.conf;
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log off;
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    }

Click to View All Content .Js – Show More Content on Click

The resource of click to view more content.


HTML code:


<div class="container">
	<div class="row">
		<h2>This is free script from webenlance</h2>
	</div>
    
    <p class="comment">
Dr. Anil Kohli is an Endodontist, Dental Surgeon and Dentist in Lajpat Nagar, Delhi and has an experience of 40 years in these fields. Dr. Anil Kohli practices at Duis nisl nibh, egestas at fermentum at, viverra et purus. Maecenas lobortis odio id sapien facilisis elementum. Curabitur et magna justo, et gravida augue. Sed tristique pellentesque arcu quis tempor. Duisds nisl nibh, egestas at fermentum at, viverra et purus. Maecenas lobortis odio id sapien facilisis elementum. chickenCurabitur et magna justo, et gravida augue. Sed tristique pellentesque arcu quis tempor.  Duisds nisl nibh, egestas at fermentum at, viverra et purus. Maecenas lobortis odio id sapien facilisis elementum. chickenCurabitur et magna justo, et gravida augue. Sed tristique pellentesque arcu quis tempor.  Duisds nisl nibh, egestas at fermentum at, viverra et purus. Maecenas lobortis odio id sapien facilisis elementum. chickenCurabitur et magna justo, et gravida augue. Sed tristique pellentesque arcu quis tempor.  
</p>

    
    
    
    
    <script language="javascript">
$(document).ready(function() {
    
	$(".comment").shorten();
	
	$(".comment-small").shorten({showChars: 10});

 });
</script>
</div>

JS Code:

(function($) {
    $.fn.shorten = function(settings) {
        "use strict";

        var config = {
            showChars: 0,
            minHideChars: 10,
            ellipsesText: "...",
            moreText: "Read More",
            lessText: "less",
            onLess: function() {},
            onMore: function() {},
            errMsg: null,
            force: false
        };

        if (settings) {
            $.extend(config, settings);
        }

        if ($(this).data('jquery.shorten') && !config.force) {
            return false;
        }
        $(this).data('jquery.shorten', true);

        $(document).off("click", '.morelink');

        $(document).on({
            click: function() {

                var $this = $(this);
                if ($this.hasClass('less')) {
                    $this.removeClass('less');
                    $this.html(config.moreText);
                    $this.parent().prev().animate({'height':'0'+'%'}, function () { $this.parent().prev().prev().show(); }).hide('fast', function() {
                        config.onLess();
                      });

                } else {
                    $this.addClass('less');
                    $this.html(config.lessText);
                    $this.parent().prev().animate({'height':'100'+'%'}, function () { $this.parent().prev().prev().hide(); }).show('fast', function() {
                        config.onMore();
                      });
                }
                return false;
            }
        }, '.morelink');

        return this.each(function() {
            var $this = $(this);

            var content = $this.html();
            var contentlen = $this.text().length;
            if (contentlen > config.showChars + config.minHideChars) {
                var c = content.substr(0, config.showChars);
                if (c.indexOf('<') >= 0) // If there's HTML don't want to cut it
                {
                    var inTag = false; // I'm in a tag?
                    var bag = ''; // Put the characters to be shown here
                    var countChars = 0; // Current bag size
                    var openTags = []; // Stack for opened tags, so I can close them later
                    var tagName = null;

                    for (var i = 0, r = 0; r <= config.showChars; i++) {
                        if (content[i] == '<' && !inTag) {
                            inTag = true;

                            // This could be "tag" or "/tag"
                            tagName = content.substring(i + 1, content.indexOf('>', i));

                            // If its a closing tag
                            if (tagName[0] == '/') {


                                if (tagName != '/' + openTags[0]) {
                                    config.errMsg = 'ERROR en HTML: the top of the stack should be the tag that closes';
                                } else {
                                    openTags.shift(); // Pops the last tag from the open tag stack (the tag is closed in the retult HTML!)
                                }

                            } else {
                                // There are some nasty tags that don't have a close tag like <br/>
                                if (tagName.toLowerCase() != 'br') {
                                    openTags.unshift(tagName); // Add to start the name of the tag that opens
                                }
                            }
                        }
                        if (inTag && content[i] == '>') {
                            inTag = false;
                        }

                        if (inTag) { bag += content.charAt(i); } // Add tag name chars to the result
                        else {
                            r++;
                            if (countChars <= config.showChars) {
                                bag += content.charAt(i); // Fix to ie 7 not allowing you to reference string characters using the []
                                countChars++;
                            } else // Now I have the characters needed
                            {
                                if (openTags.length > 0) // I have unclosed tags
                                {
                                    //console.log('They were open tags');
                                    //console.log(openTags);
                                    for (j = 0; j < openTags.length; j++) {
                                        //console.log('Cierro tag ' + openTags[j]);
                                        bag += '</' + openTags[j] + '>'; // Close all tags that were opened

                                        // You could shift the tag from the stack to check if you end with an empty stack, that means you have closed all open tags
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    c = $('<div/>').html(bag + '<span class="ellip">' + config.ellipsesText + '</span>').html();
                }else{
                    c+=config.ellipsesText;
                }

                var html = '<div class="shortcontent">' + c +
                    '</div><div class="allcontent">' + content +
                    '</div><span><a href="javascript://nop/" class="morelink">' + config.moreText + '</a></span>';

                $this.html(html);
                $this.find(".allcontent").hide(); // Hide all text
                $('.shortcontent p:last', $this).css('margin-bottom', 0); //Remove bottom margin on last paragraph as it's likely shortened
            }
        });

    };

})(jQuery);

Click here to download the code: show-more

Display the Featured Image Only on the First Page

Remove the featured image from the rest of the next page which post using the code <!–NextPage–>

 

<!--NextPage-->

I have the featured image in the single page. In my site I split the posts into multiple pages using

<!--NextPage-->

in editor. Also I have a

<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>

in my single.php file.

What happen now is that the featured image will show to all multiple pages. All I want is that the featured image will only show in the first page.

Here is the solution:

Add the following code to replace your featured image code:

<?php
global $page;
if ($page == 1) {
  the_post_thumbnail( 'single-post-thumbnail' );
} ?>

Install Postfix to Send Email Instead of Sendmail in Centos LNMP

If your email can’t work in LNMP or in centos, why not change it to Postfix? Which is simple and faster than sendmail!

What is Postfix? It is Wietse Venema’s mail server that started life at IBM research as an alternative to the widely-used Sendmail program. Now at Google, Wietse continues to support Postfix.

Here we go!
Continue reading “Install Postfix to Send Email Instead of Sendmail in Centos LNMP”

How to Solve “xz compression not available” Error in Centos

If you want to install or update use the yum command and got this error in Centos server:

error xz compression not available
error xz compression not available

Error: xz compression not available

Here is the solution.

This problem comes if you installed a wrong epel release on your machine. If so, then you need to remove the epel release by

yum remove epel-release

Sometimes that is not enough, you need to remove the cache as well by:

rm -rf /var/cache/yum/x86_64/6/epel

Then you can install the epel-release again

yum -y install epel-release

Hope this help you, I have solved this problem on my server.

Name.com Promo Code: $6.99 for .COM Domains – 46% Off!

Here is a new great big discount from name.com! You can use the new name.com promo code to get 46% off on any .com and .net domains!

Use this discount code to save.

699comnet

.COM And .NET Domains Are $6.99

Expires 06/30/16

Details: Sale! Get .COM and .NET domains are $6.99. Limit one per customer.

Here is the proof. I just registered a new domain for just $6.99

name.com promo code
name.com promo code

Most Searched Words on Pinterest

Thanks to some recent search improvements of the Pinterest team made, we’re seeing some interesting differences in what people are looking for around the globe these days.

Most Searched Words on Pinterest
Most Searched Words on Pinterest

Here I listed the top 10 ideas people are searching for around the world in 2015. Continue reading “Most Searched Words on Pinterest”