Sohaib's Tech Blog

Something for every one

Odoo9 Community to Odoo9 Enterprise Database Upgrade — 2016

Odoo9 Community to Odoo9 Enterprise Database Upgrade

Today I’ve purchase Odoo9 Enterprise therefore I need to move my database from Odoo9 community to Odoo9 Enterprise at first I was getting Internal server error then after some research I realize that I need to upgrade my database here are the steps I took.

You need to restore your Odoo9 Community Database to Odoo9 Enterprise and then perform the following task.

Step 1

service odoo stop

Step 2

sudo su odoo -s /bin/bash

Step 3

/usr/bin/odoo.py --addons=/usr/lib/python2.7/dist-packages/openerp/addons -u all

Now Odoo9 Enterprise is started, Next step is you need to access Odoo from the web so it can start the upgrade process, It will start and you exit terminal and start odoo manually or simply reboot your server and walla its done.

Advertisements
Magento2 Varnish 503 Backend Fetch Failed Problem **SOLVED — 2016

Magento2 Varnish 503 Backend Fetch Failed Problem **SOLVED

I’ve  M2.10 , Varnish , Redis and Nginx intalled and using Php7.08 with installed after doing a lot of research I wasn’t able to find a solution for this.

I was moving around attributes from groups to un-assigned group in Magento 2.10, I notice I was having issue with Varnish and the error was Varnish 503 Backend Fetch Failed.

The problem was in “clean_cache_by_tags” function in Magento. I think it’s an error clearing the cache in php7 & magento2.

Quick fix is to turn off block_html cache. Everything works in Php 5.6x but in PHP7.08 its causing a lot of problem.

Should I downgrade or stay upgraded is the question ?

After installing php5.6 it appears everything seems to be working fine

 

How to use Gmail or Amazon SES with Magento — 2016

How to use Gmail or Amazon SES with Magento

Let’s configure Gmail or Amazon SES with Magento2 or Magento 1 or any other php application, basically will configure our server in a way so any php application will then use local php mail but email will route with any SMTP provider.

Step 1

apt-get install msmtp -y
apt-get install libxml-xpath-perl  -y
nano ~/.msmtprc

Now will edit or add .msmtprc file

account gmail
tls on
tls_certcheck off
auth on
host smtp.gmail.com
port 587
user yourusername@gmail.com
from youruser@gmail.com
password Yourpasswordhere

Let’s change permission and give proper ownership and copy the file to appropriate location

chmod 600 ~/.msmtprc
cp -p ~/.msmtprc /etc/.msmtp_php
chown www-data:www-data /etc/.msmtp_php

Now will edit php.ini file so we can tell sendmail to use our Gmail SMTP

I am using PHP 7 so my location is different then your’s probably, if you are using Ubuntu or any flavor you can simply use

locate php.ini

 

nano /etc/php/7.0/fpm/php.ini
nano /etc/php/7.0/cli/php.ini

Now will edit sendmail in php.ini

sendmail_path = "/usr/bin/msmtp -C /etc/.msmtp_php --logfile /var/log/msmtp.log -a gmail -t"

Lastly will make sure to have our log file

touch /var/log/msmtp.log
chown www-data:www-data /var/log/msmtp.log

Now goto your Magento2 admin or Magento admin or any PHP Application to try to sendmail email it will use Gmail or Amazon SES to send emails out, you just need to modify your msmtp file

How to Enable Verbose in Ubuntu — 2016
Magento 2.01 Broken CSS and Magento 2.01 Admin Page not found — 2016
Mod_pagespeed with Apache on Ubuntu — 2016

Mod_pagespeed with Apache on Ubuntu

Speed Up the Web with Google Page Speed = Apache2

If you’re on a 64-bit version (likely)…

 

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb

If you’re on a 32-bit version (less likely)…

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
sudo dpkg -i mod-pagespeed-*.deb apt-get -f install

Remove the downloaded package

rm mod-pagespeed-*.deb
service apache2 restart

Setup

The installation package handles a lot of configuration out-of-the-box. In fact, there are conservative defaults that are automatically enabled on Apache. Depending on the Apache version you’re running, you’ll get a different version of the module installed and enabled. If you’re running Apache 2.2,mod_pagespeed.so will be installed; Apache 2.4 users will use mod_pagespeed_ap24.so.

Note: mod_pagespeed only works with Apache 2.2 and greater. There is also a bug with Apache 2.4.1 that prevents it from working with that version. Apache 2.4.2 or greater should be used.

Additionally, configuration files have been added to your Apache installation. The primary configuration file is pagespeed.conf. This file is located at:

/etc/apache2/mods-available/

Configuration

nano /etc/apache2/mods-available/pagespeed.conf

Turn mod_pagespeed On/Off

First off, you can turn the module on or off with the ModPagespeed setting.

ModPagespeed on

or

ModPagespeed off

Rewrite Levels

You can specify different “levels” of settings to simplify any configuration. The default is“CoreFilters.” It contains a set of filters the Google team believes is safe for use. The filters are the individual actions that are applied to a file. In general, you won’t need to change this value. It’s easier to use this default and then enable or disable filters using the ModPagespeedEnableFilters andModPagespeedDisableFilters directives.

The default setting:

ModPagespeedRewriteLevel CoreFilters

To disable CoreFilters use this setting:

ModPagespeedRewriteLevel PassThrough

Note: You’ll have to explicitly enable any filters you want to turn on using the “PassThrough” setting.

Using the default “CoreFilters” rewrite level includes a number of filters by default. As of the time of this writing, it includes:?

add_head
combine_css
convert_jpeg_to_progressive
convert_meta_tags
extend_cache
flatten_css_imports
inline_css
inline_import_to_link
inline_javascript
rewrite_css
rewrite_images
rewrite_javascript
rewrite_style_attributes_with_url

New filters will be added in the future. By using CoreFilters, you’ll automatically have these filters enabled if they become part of the default set whenever you update mod_pagespeed. Using PassThrough will require you to explicitly enable the new filters.

Enable Filters

If you’d like to enable additional filters, you can pass them as a comma-separated list toModPagespeedEnableFilters. You can have multiple ModPagespeedEnableFilters directives throughout your configuration files. So, if you want to enable a filter per site, you could enable it in the virtual host configuration file or in the .htaccess file instead of in the main pagespeed.conf file.

Here’s an example that enables the Pedantic filter (which adds the type attribute to script and style tags) and the Remove Comment filter (which removes all HTML comments):

ModPagespeedEnableFilters pedantic,remove_comments

Disable Filters

You can also disable filters on a per-case basis if you’d like. Specify a list of filters you’d like to disable similar to

ModPagespeedEnableFilters

The following example disables the “Convert JPEG to Progressive” filter even though it’s part of the CoreFilters set:

ModPagespeedDisableFilters convert_jpeg_to_progressive

Specify Which URLs are Rewritten

By default, mod_pagespeed rewrites everything it can. You can disable certain files (for example Javascript libraries) from being rewritten with the following directive:

ModPagespeedDisallow "*/jquery-ui-*.min.js"

This would disable rewriting of any files that match the wildcard pattern specified (jquery UI in this case).

You can also turn off the rewriting of all files by default and only enable files you want to rewrite manually. You can do this with the following settings:

ModPagespeedDisallow "*" 
ModPagespeedAllow "http://*digitalocean.com/*/styles/*.css" 
ModPagespeedAllow "http://*digitalocean.com/*.html" 
ModPagespeedDisallow "*/notrewritten.html"

The order of execution means that all files at digitalocean.com ending in .html would be rewritten. That last Disallow directive means any URLs matching that pattern would not be rewritten because it overrides the previous setting.

Restart Apache

Don’t forget if you’re using the pagespeed.conf or VirtualHost files to alter the settings, you’ll have to restart Apache for the settings to take effect. You can do this with the following commands:

 

service apache2 restart or /etc/init.d/apache2 restart

Thank you to https://www.digitalocean.com/community/tutorials/how-to-get-started-with-mod_pagespeed-with-apache-on-an-ubuntu-and-debian-cloud-server

Apache2 w/Percona 5.6 Installation Ubuntu Willy —

Apache2 w/Percona 5.6 Installation Ubuntu Willy

Its been a long time since my last update, I was busy with family and work. Today I will show how we install Apache2 using Ubuntu latest edition Willy as of Jan-23-2016

apt-get update
apt-get install apache2 apache2-doc apache2-utils libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libruby libapache2-mod-python php5-curl php5-intl php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached php5-apcu libapache2-mod-fastcgi php5-fpm -y
a2enmod actions fastcgi alias
service apache2 restart
a2enmod suexec rewrite ssl actions include cgi
a2enmod dav_fs dav auth_digest
php5enmod mcrypt

Finally we restart Apache2  for the last time

service apache2 restart

Now will install Percona Database Server Instead of MySQL Server

Fetch the repository packages from Percona web:

wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb<span id="mce_marker" data-mce-type="bookmark"></span>

Install the downloaded package with dpkg. To do that, run the following commands as root or with sudo:

Once the following installed you can check Percona repositories should be added. /etc/apt/sources.list.d/percona-release.list file.

dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb
<span id="mce_marker" data-mce-type="bookmark"></span>
apt-get update
apt-get install percona-server-server-5.6 percona-server-client-5.6 -y<span id="mce_marker" data-mce-type="bookmark"></span>

You are Done.

Now you’ve a great rock solid Apache2 Server

You also copy and paste the complete script :-

 

apt-get update

apt-get install apache2 apache2-doc apache2-utils libapache2-mod-php5 php5 php5-common php5-gd php5-mysql php5-imap php5-cli php5-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear php-auth php5-mcrypt mcrypt php5-imagick imagemagick libruby libapache2-mod-python php5-curl php5-intl php5-memcache php5-memcached php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl memcached php5-apcu libapache2-mod-fastcgi php5-fpm -y

a2enmod actions fastcgi alias
service apache2 restart
a2enmod suexec rewrite ssl actions include cgi
a2enmod dav_fs dav auth_digest
php5enmod mcrypt
service apache2 restart

wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb
dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb

apt-get install percona-server-server-5.6 percona-server-client-5.6 -y

Speed the web with Google Page speed – Click here

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 extension=apcu.so > /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: * http://opensource.org/licenses/afl-3.0.php * 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 license@magento.com 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 http://www.magento.com for more information. * * @category Mage * @package Mage_Core * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/afl-3.0.php 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[127.0.0.1]]></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[127.0.0.1]]></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

/etc/php5/mods-available/apcu.ini

xtension=apc.so
extension=apcu.so
apc.enabled=1
apc.shm_size=512M
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
apc.stat=0
apc.optimization=0
apc.shm_segments=1
apc.enable_cli=1
apc.cache_by_default=1
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.

ngx_http_access_module

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. 8.8.8.8 & 8.8.4.4

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

deny 9.9.9.9;
deny 8.8.8.8;
deny 8.8.4.4;

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/nginx.pid --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-1.9.32.1-beta --add-module=/work/nginx-1.6.2/src/modules/ModSecurity-2.8.0/nginx/modsecurity --with-ipv6

12.04
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