Showing posts with label web server. Show all posts
Showing posts with label web server. Show all posts

Tuesday, 28 October 2014

Friday, 20 June 2014

Page caching for Buddypress? Transients, memcached, vs others

Since Buddypress works on having users login, page caches software such W3 Total Cache, BP Super Cache, Nginx microcache, APC, Memcached, etc. won't work.

What would work is a partial page caching software. But there doesn't seem to be any such software now.

http://chrislema.com/high-performance-wordpress-membership-site/

However, by using the wordpress transients API, one can manually code fragment or partial page caching.

http://premium.wpmudev.org/blog/wordpress-transients/

Problems with transients:

http://wpengine.com/2013/02/21/wordpress-transient-api/

Starting with Wordpress 3.7, transients are garbage collected, so the issues mentioned above may be fixed.

Enabling Opcache in PHP

Here are the commands that can be entered in php.ini for configuration of the opcache. There is also an explanation ofthe features.

http://www.php.net//manual/en/opcache.configuration.php


Here are some Opcache GUI reporting tools:

https://rtcamp.com/tutorials/php/zend-opcache/

Some configuration tips:

https://www.activecollab.com/blog/3-zend-opcache-memcached.html

More detailed configuration tips:

https://www.scalingphpbook.com/best-zend-opcache-settings-tuning-config/



Tuesday, 17 June 2014

Wordpress: Disable heartbeat

If wordpress is taking too much server resources, you can disable wordpress heartbeat. If you are using buddypress, disable "Activity auto-refresh" in Buddypress settings.

http://www.inmotionhosting.com/support/website/wordpress/heartbeat-heavy-admin-ajax-php-usage

In the above page, you will find the code to disable heartbeat on all pages except post.php and post-new.php (here it is required for autosave while creating new posts and commenting).

To be added in functions.php

add_action( 'init', 'stop_heartbeat', 1 );

function stop_heartbeat() {
        global $pagenow;

        if ( $pagenow != 'post.php' && $pagenow != 'post-new.php' )
        wp_deregister_script('heartbeat');
}

Nginx with CPanel

http://cpxstack.sysally.net/

Cpxstack is a plugin to cPanel that completely replaces Apache with nginx (other plugins keeps apache and configure nginx as a reverse proxy).

To install cpxstack, you need Incron. For this you need to enable the EPEL repository (see previous article for this).

You also need to install php-devel. Cpanel prevents installing any php related packages through an "exclude" entry in yum.conf. Open yum.conf and remove "php*".

After upgrading to the latest stable PHP version, you should enable the Remi repository and the php55 remi repository. You can now install php-devel.

You can run the cpxstack.sh script as per instructions here: http://cpxstack.sysally.net/documentation.htm

For incron and php-devel you can alternatively directly run the cpxstack.sh script to see if it installs these packages automatically.

After the script has run, you should go to WHM, when you click on the cpxstack icon in the sidebar, it will ask you to change a setting in the Tweak Settings area.
You also need to go to cPanel and manually enable nginx for your site. Also in WHM change the default number of worker processes to a lower number (default is 15).

http://www.nginxtips.com/cpxstack-nginx-php-fpm-cpanel/

Nginx: Allow selected IP addresses only

  server {
    listen 80;
    server_name www.foo.bar;

    location / {

      allow   my.public.ip.here;
      deny    all;
    }
  } 
 
You can have multiple "allow" lines.

http://stackoverflow.com/questions/8438867/how-can-i-allow-access-to-a-single-ip-address-via-nginx-conf