{"id":2288,"date":"2016-07-26T14:56:33","date_gmt":"2016-07-26T18:56:33","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2288"},"modified":"2017-04-19T16:01:18","modified_gmt":"2017-04-19T20:01:18","slug":"prepare-magento-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/","title":{"rendered":"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14"},"content":{"rendered":"<p>Magento is a free, open-source e-commerce platform used by thousands of retailers to power their online stores. The many features of Magento include shopping cart management, conversion tracking and easy catalog customization. There are a wide variety of plugins that can be installed to provide even more features.<\/p>\n<p>This guide will help you get a suitable environment for Magento up and running.<\/p>\n<h2>Getting started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 1 Node (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running a clean installation of Ubuntu 14.<br \/>\n\u2022 All commands should be run as the root user<br \/>\n\u2022 A LAMP stack using Nginx, PHP and MariaDB<\/p>\n<h2>Step-by-step guide<\/h2>\n<p>To start the setup process, make sure your server is fully up to date.<\/p>\n<p><code>apt-get update<br \/>\napt-get dist-upgrade -y<\/code><\/p>\n<p>There are a few required programs that Magento will need. First, install the base applications. At this time, you will also set the root user for MariaDB, which is a common drop-in replacement for MySQL.<\/p>\n<p><code>apt-get install nginx php5-fpm redis-server memcached php5-dev php5-mysql php5-mcrypt mariadb-server php-pecl<\/code><\/p>\n<p>Next, install the two required PHP extensions, php-memcached and php-redis. You should use Redis for managing Magento&#8217;s backend cache.<\/p>\n<p><code>yum -y install php-pecl-memcache php-pecl-memcached<\/code><\/p>\n<p><code>mkdir ~\/redis<br \/>\ncd ~\/redis<br \/>\nwget https:\/\/pecl.php.net\/get\/redis-2.2.8.tgz<br \/>\ntar zxpf redis*<br \/>\ncd redis*<br \/>\nphpize<br \/>\nmake<br \/>\nmake install<\/code><\/p>\n<p>Make sure to add the memcached and redis modules to the PHP extensions list in php.ini.<\/p>\n<p><code>nano \/etc\/php5\/mods-available\/memcached.ini<\/code><\/p>\n<p><code>; Redis Extension<br \/>\nextension=memcached.so<\/code><\/p>\n<p><code>nano \/etc\/php5\/mods-available\/redis.ini<\/code><\/p>\n<p><code>; Redis Extension<br \/>\nextension=redis.so<\/code><\/p>\n<p>Naturally, you will need to enable both of these modules.<\/p>\n<p><code>php5enmod memcached<\/code><\/p>\n<p><code>php5enmod redis<\/code><\/p>\n<p>Now it&#8217;s time to configure PHP sessions to be stored into memcached. First, configure this setting for the PHP command line interface.<\/p>\n<p><code>nano \/etc\/php5\/cli\/php.ini<\/code><\/p>\n<p><code class=\"gris\">COMMENT BOTH FOLLOWING LINES<br \/>\n;session.save_handler = files<br \/>\n;session.save_path = \"\/var\/lib\/php5\"<\/code><\/p>\n<p><code class=\"gris\">ADD BOTH FOLLOWING LINES<br \/>\nsession.save_handler = memcached<br \/>\nsession.save_path=127.0.0.1:11211<\/code><\/p>\n<p>Then you can set it for the PHP-FPM.<\/p>\n<p><code>nano \/etc\/php5\/fpm\/php.ini<\/code><\/p>\n<p><code class=\"gris\">COMMENT BOTH FOLLOWING LINES<br \/>\n;session.save_handler = files<br \/>\n;session.save_path = \"\/var\/lib\/php5\"<\/code><\/p>\n<p><code class=\"gris\">ADD BOTH FOLLOWING LINES<br \/>\nsession.save_handler = memcached<br \/>\nsession.save_path=127.0.0.1:11211<\/code><\/p>\n<p>We need to get Nginx to work with PHP now. Create your web directory first.<\/p>\n<p><code>mkdir \/var\/www<br \/>\nmkdir \/var\/www\/magento<br \/>\nchown www-data:www-data -R \/var\/www\/magento\/<br \/>\ncd \/var\/www\/html\/magento<br \/>\nchmod -R o+w app\/etc\/<br \/>\nchmod -R o+w var\/<br \/>\nchmod -R o+w media\/<\/code><\/p>\n<p>Now add a few tweaks to Nginx&#8217;s configuration. Set Nginx to use PHP-FPM for requests.<\/p>\n<p><code>rm -rf \/etc\/nginx\/sites-enabled\/default<br \/>\ntouch \/etc\/nginx\/sites-enabled\/magento<br \/>\nnano \/etc\/nginx\/sites-enabled\/magento<\/code><\/p>\n<p><code>server {<br \/>\nlisten 80;<br \/>\nroot \/var\/www\/magento;<br \/>\nindex index.php index.html index.htm;<br \/>\nserver_name magento.domain.com;<br \/>\nlocation \/ {<br \/>\ntry_files $uri $uri\/ =404;<br \/>\n}<br \/>\nerror_page 404 \/usr\/share\/nginx\/www\/404.html;<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/www;<br \/>\n}<br \/>\nlocation ~ \\.(php)$ {<br \/>\ntry_files $uri =404;<br \/>\nfastcgi_split_path_info ^(.+\\.php)(\/.+)$;<br \/>\nfastcgi_keep_conn on;<br \/>\ninclude fastcgi_params;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\nfastcgi_param SERVER_NAME $host;<br \/>\nfastcgi_pass unix:\/var\/run\/php5-fpm.sock;<br \/>\n}<br \/>\n}<\/code><\/p>\n<p>Then you can configure Nginx worker processes.<\/p>\n<p><code>\/etc\/nginx\/nginx.conf<\/code><\/p>\n<p><code>worker_processes 4;<br \/>\nevents {<br \/>\nworker_connections 1024;<br \/>\n# multi_accept on;<br \/>\n}<\/code><\/p>\n<p>Configure the PHP-FPM worker as laid out below.<\/p>\n<p><code>nano \/etc\/php5\/fpm\/pool.d\/www.conf<\/code><\/p>\n<p><code class=\"gris\">pm.max_children = 512<br \/>\npm.start_servers = 32<br \/>\npm.min_spare_servers = 32<br \/>\npm.max_spare_servers = 512<\/code><\/p>\n<p>Now, start or restart all services.<\/p>\n<p><code>service nginx start<br \/>\nservice php5-fpm start<br \/>\nservice redis-server start<br \/>\nservice memcached start<br \/>\nservice mysql start<\/code><\/p>\n<p>For ease of startup during boot, configure installed services to be automatically started at boot time.<\/p>\n<p><code>sudo update-rc.d nginx defaults<br \/>\nsudo update-rc.d nginx enable<br \/>\nsudo update-rc.d php5-fpm defaults<br \/>\nsudo update-rc.d php5-fpm enable<br \/>\nsudo update-rc.d redis-server defaults<br \/>\nsudo update-rc.d redis-server enable<br \/>\nsudo update-rc.d memcached defaults<br \/>\nsudo update-rc.d memcached enable<br \/>\nsudo update-rc.d mysql defaults<br \/>\nsudo update-rc.d mysql enable<\/code><\/p>\n<p>Insert the famed phpinfo into your webroot for test purposes. This will help in case of any problems with your PHP configuration.<\/p>\n<p><code>nano \/var\/www\/magento\/index.php<\/code><\/p>\n<p><code>&lt;?php<br \/>\nphpinfo();<br \/>\n?&gt;<\/code><\/p>\n<p><code class=\"gris\">chown www-data. \/var\/www\/magento\/index.php<\/code><\/p>\n<p>Install phpMyAdmin, a useful graphical tool for interacting with the databases on your server.<\/p>\n<p><code>apt-get install phpmyadmin<\/code><\/p>\n<p>Link phpMyAdmin to your webroot path.<\/p>\n<p><code>cd \/var\/www\/magento<br \/>\nln -s \/usr\/share\/phpmyadmin phpmyadmin<\/code><\/p>\n<p>Now, create the initial database for your upcoming Magento deployment. This is where Magento will store the data used during operation.<\/p>\n<p><code>mysql<br \/>\ncreate database magento;<br \/>\nCREATE USER 'magento'@'localhost' IDENTIFIED BY 'randompasshere';<br \/>\nGRANT ALL PRIVILEGES ON magento.* TO 'magento'@'localhost';<br \/>\nFLUSH PRIVILEGES;<br \/>\nexit<\/code><\/p>\n<p>Now that your environment is set up, you can go ahead and install the actual Magento software.<\/p>\n<h2>Conclusion<\/h2>\n<p>Magento is the most popular e-commerce system today for online retailers and businesses. With Magento, you can enjoy reliable operation and incredible extensibility to create a seamless shopping experience for your customers, improving conversion and encouraging repeat business. If this guide was helpful to you, kindly share it with others who may also be interested. <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Magento is a free, open-source e-commerce platform used by thousands of retailers to power their online stores. The many features of Magento include shopping cart management, conversion tracking and easy catalog customization. There are a wide variety of plugins that can be installed to provide even more features. This guide will help you get a<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,70],"tags":[],"class_list":["post-2288","post","type-post","status-publish","format-standard","hentry","category-applications","category-web-hosting","applications-magento"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now &amp; Enjoy your new e-commerce platform !\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now &amp; Enjoy your new e-commerce platform !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-26T18:56:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-19T20:01:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/\",\"name\":\"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-07-26T18:56:33+00:00\",\"dateModified\":\"2017-04-19T20:01:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now & Enjoy your new e-commerce platform !\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech","description":"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now & Enjoy your new e-commerce platform !","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now & Enjoy your new e-commerce platform !","og_url":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-07-26T18:56:33+00:00","article_modified_time":"2017-04-19T20:01:18+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/","name":"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-07-26T18:56:33+00:00","dateModified":"2017-04-19T20:01:18+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to prepare an optimized environment to run Magento on your Ubuntu 14 server. Read now & Enjoy your new e-commerce platform !","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/prepare-magento-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Prepare an Optimized Environment to Run Magento on Ubuntu 14"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2288"}],"version-history":[{"count":5,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2288\/revisions"}],"predecessor-version":[{"id":2931,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2288\/revisions\/2931"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}