How to optimize hosting for running Magento?
Basic guide on how to optimize a VPS or dedicated server for running Magento.
Use PHP5.4 or newer.
Example of some php.ini settings:
realpath_cache_size = 32k
realpath_cache_ttl = 7200
max_execution_time = 90
max_input_time = 90
memory_limit = 256M
default_socket_timeout = 90
pdo_mysql.cache_size = 2000
output_buffering = 4096
Use the latest stable MySQL version, or alternatively use Percona or MariaDB.
Percona offer a MySQL configuration wizard , use that to get your initial configuration values for MySQL.
Then install MySQLTuner and use it to monitor and adjust the configuration settings over time.
Add APC (PHP accelerator/OpCode Cache).
Step 1. Install APC and enable it in php.ini.
Example php.ini settings:
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
apc.include_once_override=1
Step 2. Use APC as Magentos fast backend.
In your Magento install in the file ./app/etc/local.xml add the following just before the closing tag.
<cache>
<backend>apc</backend>
<prefix>mystore_</prefix>
</cache>
Optional: Use a Content Delivery Network (CDN) for delivering static files like js, css and images.
Sign Up for a CDN account, for instance at Amazon CloudFront and get your cdn url(s).
These can be added in the Magento admin under System > Configuration > General > Web > Unsecure change the urls for Base Skin URL and Base Media Url and optionally also the JavaScript Url.
Optional: Disable Apache AllowOverrides
This will eliminating directory structure scans for .htaccess files and as such the htaccess will not be used anymore, so you will have to add the wanted rules to the configuration for this virtual host instead.
For optimization of your Magento shop read our Magento Speed Optimization Guide.
Using whats described above should give you a clear improvement in speed, but there are possible further advantages to be had using more advanced optimization as well as adding Nginx, Redis, Memcahed, OPcache, Varnish +++.
Leave a Reply