Web Apps

Optimizing Magento

by , , revisited on


We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish and lots of useful modules for them, this is your one stop repository to get all performance related software.
You have to maintain an active subscription in order to be able to use the repository!

mkdir -p /var/cpanel/easy/apache/custom_opt_mods/Cpanel/
cd /var/cpanel/easy/apache/custom_opt_mods/Cpanel/
svn co https://github.com/pagespeed/cpanel/trunk/Easy Easy
cd /var/cpanel/easy/apache/custom_opt_mods/Cpanel/Easy && tar -zcvf Speed.pm.tar.gz pagespeed

nano /usr/local/apache/conf/pagespeed.conf

add before :

ModPagespeedEnableFilters remove_comments,defer_javascript,prioritize_critical_css,trim_urls,collapse_whitespace

yum -y install git (for cpanel-pagespeed)
yum -y install svn (for the same)

Pagespeed order received action:
check centos: cat /etc/redhat-release
check cpanel using ps faux
cpanel pass at :2087 is root same as SSH

 

pecl install zendopcache-7.0.3

Build process completed successfully
Installing ‘/usr/local/lib/php/extensions/no-debug-non-zts-20100525/opcache.so’
install ok: channel://pecl.php.net/zendopcache-7.0.3
Extension zendopcache enabled in php.ini

but it’s not there, so try to find it:
find / -name opcache.so

http://fideloper.com/install-zend-opcache

1. mod_pagespeed: takes care of optimizing images, minifying css and js, expiration rules, etc, etc.!
2. Zend OpCache – as I initially said this brings the most improvement. I have installed latest 7.0.3 version. You can check how it works (stats on number of files cached, etc.) athttp://www.kuriouskitty.com/pinfo.php then searching “Opcache” on the page
3. MySQL query caching 
4. In Magento, I have enabled concatenating css and js into single files. If there are any leftovers, pagespeed will pick those up.
5. Added Magento log cleaning via system cron. It will check daily, whether there logs older than 14 days and truncate to that time.
6. Also, enabled cache for all items under: System > Cache Management
7. And finally, I did take care about having nonexistent images return just the 404 status (previously they were loading THE FULL magento instance just to show a 404 page that nobody would even see).

We should go further and disable unused Magento modules at System->Configuration->Advanced (Magento admin interface). If in doubt, let me know and I’ll provide suggestions. – I wouldn’t want to disable something you actually need).

Regarding DNS. I have updated / registered nameservers in WHM. Now, assuming you did everything right at Godaddy, things should be working after a few hours (currently I don’t see it working 🙂

I don’t understand the HG’s want to have private name servers by each VPS customer. It’s only nice to have when you want to be a huge reseller of hosting plans under HG. Having private name servers requires running an additional service on VPS, one that takes a lot of RAM, most precious resource. It’s better use RAM for things like upping mysql query cache. Just my suggestion – use name servers by Godaddy and change A record to point to VPS IP. If in doubt, you can give me go daddy’s credentials and I’ll do the change. Then we can shutdown the DNS service at VPS.

 

Change List for yesterday and today:

* I Had to switch to mod_fastcgi in Apache (vs mod_suphp) because mod_suphp doesn’t support PHP Opcode caches. That required recompiling it using EasyApache (EA) in WHM. Once you learn it, you will realize EasyApache is a good way to update Apache or change configuration. But don’t really use it unless you have read about it. BTW, since opcache is not Cpanel packaged app, it’s a requirement to reinstall opcache using SSH after EA build.

* I considered installing mod_spdy as well, but since Apache version requirement is not fulfilled, and we need to keep control panel running, it’s better to leave that beta software not installed

* I have configured usage of just single file for virtual host configuration. This is good because you keep the configuration in one file, but what’s more important, Apache doesn’t scan .htaccess in each subdirectory. This is the more beneficial since you have a deep directory structure. 

Ran:
nano /usr/local/apache/conf/httpd.conf and took note of suggested conf location for domain
mkdir -p /usr/local/apache/conf/userdata/std/2_2/kitty/kuriouskitty.com/
nano /usr/local/apache/conf/userdata/std/2_2/kitty/kuriouskitty.com/vhost.conf

I have copied each and every .htaccess from www directory and wrapped in respective <Directory> wrapper. Added “AllowOverride None” for it to never read subdirectory .htaccess files

/scripts/ensure_vhost_includes –all-users (uncomments vhost.conf usage)
/scripts/verify_vhost_includes (verify syntax)

Then restarted Apache


* copied missing file under www, i.e. ran: cp ./skin/frontend/default/default/images/i_rss.gif ./skin/frontend/default/MAG090152/images/

* Added log cleaning via system cron:

/usr/local/bin/php -f /home/kitty/public_html/shell/log.php -days 14 clean

* Enabled cache for all items under: System > Cache Management. 

* Added additional filters for mod_pagespeed (/usr/local/apache/conf/pagespeed.conf): 
ModPagespeedEnableFilters remove_comments,defer_javascript,prioritize_critical_css,trim_urls,collapse_whitespace
* In Magento, installed Letsi Full Page Cache (http://www.magentocommerce.com/magento-connect/…). That removed the major slowdown by Magento. From what I’ve read this is the best FPC plugin for Magento that is freeware. All others are paid ($100 and up).
* Installed image optimization tools under SSH: jpegoptim and optipng (the sources are under /usr/local/src. This is the same place I put opcache source files)
* Ran command for optimization of some priority images, i.e.
– optipng -force -clobber -preserve ./media/wysiwyg/megnor/default/rsz_untitled-1-high-res.png (the options replace image with optimized version, keeping chown rights)
Then I have actually come up with idea of doing recursively for the whole skin dir

find . -type f -iname '*.png' -exec optipng -o7 -clobber -preserve {} \;

 



find . -type f -iname ‘*.jpg’ -exec jpegoptim {} ;
or
find . -type f -iname ‘*.jpg’ -exec jpegoptim -m90 {} ;

90% image quality for jpeg is not noticeable

* there is also a script to fix permissions, that I’ve addded and run against www directory at: /root/danila/fixkitty.sh If you happen to edit files as root, you need to change owner of files to kitty username. That’s what the script does. It also sets correct chmod for Magento directories. Internally it uses script from here:http://boomshadow.net/tech/fixes/fixperms-scrip…;

* Added directive for deflate (gzip compression) of files and enabling expiration to the single vhost configuration file – mod_pagespeed didn’t do that automatically for some files)

 

 

Regarding untrusted vs. untrusted secure connection to VPS. this is normal case with VPS.
The VPS hostname is web.kuriouskitty.com and it automatically uses self signed SSL certificate for the same DNS. Cpanel docs say “It is important to choose a hostname that you will not be using for any account”.
So ideally, you should be always accessing it via https://web.kuriouskitty.com:2087 and, if your browser allows for that, make it trust the certificate.
Another option is creating an SSL certificate just for “web” subdomain. But I don’t think it’s worth it – you know it can be trusted, so why purchasing it?
Just in case – I’m attaching exported certificate. If on Mac, you can simply double click and confirm adding. Then there will be no security prompt when accessing site in Safari.

Magento modules:

Cm_RedisSession is what I’ve disabled. (Since we don’t have Redis).

Note about the correct process of disabling module: you have to disable output first (Magento admin), then go to CPanel of kitty account (from WHM you can go to additional panel which is user specific, yes – complicated) and proceeed to File Manager.
Under /public_html/app/etc/modules find corresponding .xml file and set “active” to false.
Then use “Flush Magento Cache” button from Cache Management screen

You should decide on disabling modules yourself (since it’s you have clear understanding of what you want or not from the store). I’m just giving you example: see attached pic. You don’t use that functionality of product tags (judging on that you have no tags data anywhere). So it can be disabled unless you have plans to use tags. Since it’s core extension, in addition to instruction I gave for disabling module, note that the core extensions can be activated/disabled using Mage_All.xml

Think of what you don’t need, i.e. whishlist, etc. Maybe you want to keep everything now that’s it isn’t slow anyway.

Varnish

https://github.com/nexcess/magento-turpentine/wiki/Configuration

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.