Sohaib's Tech Blog

Something for every one

Magento Apc and Memcached Speed up Magento — 2015

Magento Apc and Memcached Speed up Magento

I hear a lot of time that people complaints about “Magento is very slow”. In my opinion Magento is not a good solution if you are hosting it in a Shared environment, If you’ve a dedicated server then YES, use it otherwise just use baby e-commerce software available online.

This article will focus on configuring and using APC and/or Memcached.

I am sharing my local.xml file.

Look for <cache>, But before you even do any of that, you need to make sure you’ve Memcached & Apc installed and configure.

Revision Feb-15-2016

The (last) version 5.1.2 of APCu don’t support PHP5 (only PHP7) so you need to set a specific version instead of beta tag :

sudo apt-get install php-pear php5-dev make libpcre3-dev php5 memcache memcached php-pear

pecl install apcu-4.0.10 
&& echo > /usr/local/etc/php/conf.d/apcu.ini
<?xml version="1.0"?> <!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to for more information. * * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2015 X.commerce, Inc. ( * @license Academic Free License (AFL 3.0) */ --> <config> <global> <install> <date><![CDATA[Fri, 10 Jul 2015 02:58:56 +0000]]></date> </install> <crypt> <key><![CDATA[321654]]></key> </crypt> <disable_local_modules>false</disable_local_modules> <resources> <db> <table_prefix><![CDATA[]]></table_prefix> </db> <span style="color: #ff0000;"><cache> <backend>memcached</backend> <memcached> <servers> <server> <host><![CDATA[]]></host> <port><![CDATA[11211]]></port> <persistent><![CDATA[1]]></persistent> </server> </servers> <compression><![CDATA[0]]></compression> <cache_dir><![CDATA[]]></cache_dir> <hashed_directory_level><![CDATA[]]></hashed_directory_level> <hashed_directory_umask><![CDATA[]]></hashed_directory_umask> <file_name_prefix><![CDATA[]]></file_name_prefix> </memcached> </cache></span> <default_setup> <connection> <host><![CDATA[localhost]]></host> <username><![CDATA[root]]></username> <password><![CDATA[LLKDIWWW221#]]></password> <dbname><![CDATA[store]]></dbname> <initStatements><![CDATA[SET NAMES utf8]]></initStatements> <model><![CDATA[mysql4]]></model> <type><![CDATA[pdo_mysql]]></type> <pdoType><![CDATA[]]></pdoType> <active>1</active> </connection> </default_setup> </resources> <session_save><![CDATA[db]]></session_save> <span style="color: #ff0000;"><cache> <backend>memcached</backend><!-- apc / memcached / empty=file --> <memcached><!-- memcached cache backend related config --> <servers><!-- any number of server nodes can be included --> <server> <host><![CDATA[]]></host> <port><![CDATA[11211]]></port> <persistent><![CDATA[1]]></persistent> </server> </servers> <compression><![CDATA[0]]></compression> <cache_dir><![CDATA[]]></cache_dir> <hashed_directory_level><![CDATA[]]></hashed_directory_level> <hashed_directory_umask><![CDATA[]]></hashed_directory_umask> <file_name_prefix><![CDATA[]]></file_name_prefix> </memcached> </cache> <cache> <backend>apc</backend> <slow_backend>database</slow_backend> <slow_backend_store_data>0</slow_backend_store_data> <auto_refresh_fast_cache>0</auto_refresh_fast_cache> <prefix>TTDINC_</prefix> </cache></span> </global> <admin> <routers> <adminhtml> <args> <frontName><![CDATA[admin]]></frontName> </args> </adminhtml> </routers> </admin> </config>

In my ubuntu environment my apcu.ini is located at

Nginx Deny From IP — 2015

Nginx Deny From IP

Nginx is a very unique Web Server, today I will show how to deny IP using Nginx, Please note you must have this module installed in your Nginx web server , If you don’t have it installed – Simply download my pre-compile Nginx which comes with all the necessary modules known to NGINX.


Will create a file under our conf directory lets called that block.conf, My conf directory is located at /etc/nginx/conf.d/.

We are going to assume YOUR IP Address i.e. &

nano /etc/nginx/conf.d/block.conf


Once done restart your Nginx server

service nginx restart OR
service nginx reload

Great source to obtain fresh IP addresses is from Ip2location

You pick and choose any country from the above link and wont allow them access to your server.

Nginx Ubuntu Server 15.04 Precompile Pagespeed Module — 2015

Nginx Ubuntu Server 15.04 Precompile Pagespeed Module

Great news, I was able to compile Nginx with the following modules for all Ubuntu flavors listed below

nginx version: nginx/1.6.2
built by gcc 4.9.2 (Ubuntu 4.9.2-10ubuntu13)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/ --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=root --group=root --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_stub_status_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --add-module=/work/nginx-1.6.2/src/modules/ngx_pagespeed-release- --add-module=/work/nginx-1.6.2/src/modules/ModSecurity-2.8.0/nginx/modsecurity --with-ipv6

14.04 & 15.04 all flavors x64bit

Before you install run

apt-get update
apt-get install libaprutil1

Then download the following and install unzip the package.

Look for your flavor Ubuntu version and go inside the directory to install using

dpkg -i filename.deb

Click here to download Nginx

Nginx Pagespeed Modsecurity Pre-compile — 2015

Nginx Pagespeed Modsecurity Pre-compile

I’ve pre-compile nginx 1.6.2, with the following modules.

You will get Google Pagespeed, Mod_Security and all your Gzip compression modules, I’ve compile this for the Ubuntu 12.04 x64 & Ubuntu 14.04 x64.

Let’s get started.

Download precompile Nginx 1.6.2 from here

I am assuming you’ve already installed your Ubuntu OS, once that’s installed simply run the following command

apt-get update

apt-get install libaprutil1

Finally , its time to install nginx deb package.

Once you unzip the file you will see two folders one is for Ubuntu 12.04 and another one is for 14.04 both are for x64 bit system.

Now install the the package, based on your Ubuntu Os version, Please pay proper attention below in order have a perfect

nginx server.

dpkg – i filename.deb

“” That’s all folks “”

You are all set & done, verify nginx by typing

nginx -V

nginx version: nginx/1.6.2 built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) TLS SNI support enabled configure arguments: –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/ –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=root –group=root –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_secure_link_module –with-http_stub_status_module –with-http_secure_link_module –with-http_stub_status_module –with-http_auth_request_module –with-mail –with-mail_ssl_module –with-file-aio –with-http_spdy_module –with-cc-opt=’-g -O2 -fstack-protector –param=ssp-buffer-size=4 -Wformat -Wformat-security’ –with-ld-opt=’-Wl,-Bsymbolic-functions -Wl,-z,relro’ –add-module=/work/nginx/nginx-1.6.2/src/modules/ngx_pagespeed-release- –add-module=/work/nginx/nginx-1.6.2/src/modules/ModSecurity-2.8.0/nginx/modsecurity –with-ipv6