{"id":2561,"date":"2016-08-24T11:38:27","date_gmt":"2016-08-24T15:38:27","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2561"},"modified":"2017-04-19T15:58:29","modified_gmt":"2017-04-19T19:58:29","slug":"setup-lemp-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/","title":{"rendered":"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14"},"content":{"rendered":"<p>The LEMP stack is a variant on the well-known LAMP stack, which stands for Linux, Apache, MySQL and PHP. With LEMP, Nginx (pronounced Engine-X) replaces Apache as the server component. Nginx is a lightweight, minimalist proxy server that routinely beats Apache in speed tests.<\/p>\n<p>Nginx has some advantages, but also some disadvantages when compared with Apache. Be sure to do your research into both to understand if Nginx is right for your particular situation.<\/p>\n<h2>Getting started<\/h2>\n<p>Confirm that you have the following before you follow this guide:<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 Ubuntu 14.<br \/>\n\u2022 Root access to the node.<\/p>\n<h2>Tutorial<\/h2>\n<p>These instructions will serve as a useful guide on how to setup a LEMP server. We&#8217;ll be installing Nginx, PHP-FPM and MySQL on Ubuntu 14.04.<\/p>\n<p>First, make sure that your server is fully up to date and reboot at the end of the update.<\/p>\n<p><code>apt-get update &amp;&amp; apt-get upgrade -y<br \/>\nreboot<\/code><\/p>\n<p>Now, we&#8217;ll install MySQL as the first component of our LEMP stack.<\/p>\n<p><code>apt-get -y install mysql-server mysql-client<\/code><\/p>\n<p>During the installation, you will be asked to setup your MySQL root password. Make sure to remember this for later.<\/p>\n<p>After the installation is complete, the next step is to start and secure the database server.<\/p>\n<p><code>service mysql start<br \/>\nmysql_secure_installation<\/code><\/p>\n<p>Be sure to enable the daemon to autostart on server boot.<\/p>\n<p><code>update-rc.d mysql default<\/code><\/p>\n<p>The Nginx installation will follow. To install Nginx, type the following command:<\/p>\n<p><code>apt-get install nginx -y<\/code><\/p>\n<p>After that&#8217;s done, you can start the nginx daemon.<\/p>\n<p><code>service nginx start<br \/>\nupdate-rc.d nginx default<\/code><\/p>\n<p>Finally, we&#8217;ll install the packages for PHP-FPM.<\/p>\n<p><code>apt-get install php5-fpm php5-mysql<\/code><\/p>\n<p>Now to configure Nginx. We need to open the default file of virtualhosts in a text editor. Here&#8217;s the modifications that you should make to this file.<\/p>\n<p><code>nano \/etc\/nginx\/sites-available\/default<\/code><\/p>\n<p><code class=\"gris\">server {<br \/>\nlisten 80 default_server;<br \/>\nlisten [::]:80 default_server ipv6only=on;<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\nindex index.php index.html index.htm; # Make site accessible from http:\/\/localhost\/<br \/>\nserver_name 173.209.44.190;<br \/>\nlocation \/ {<br \/>\ntry_files $uri $uri\/ =404;<br \/>\n}<br \/>\nerror_page 404 \/404.html;<br \/>\nerror_page 500 502 503 504 \/50x.html;<br \/>\nlocation = \/50x.html {<br \/>\nroot \/usr\/share\/nginx\/html;<br \/>\n}<br \/>\nlocation ~ \\.php$ {<br \/>\ntry_files $uri =404;<br \/>\nfastcgi_split_path_info ^(.+\\.php)(\/.+)$;<br \/>\nfastcgi_pass unix:\/var\/run\/php5-fpm.sock;<br \/>\nfastcgi_index index.php;<br \/>\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<br \/>\nlocation ~ \/\\.ht { deny all; }<br \/>\n}<br \/>\n[...]<\/code><\/p>\n<p>Save the file and exit.<\/p>\n<p>Next, reload nginx so that the daemon recognizes the changes that you made.<\/p>\n<p><code>service nginx reload<\/code><\/p>\n<p>Again in your text editor, open the file php.ini. We&#8217;ll only be modifying one line.<\/p>\n<p><code>nano \/etc\/php5\/fpm\/php.ini<\/code><\/p>\n<p>You\u2019ll need to find the following block:<\/p>\n<p><code class=\"gris\">; cgi.fix_pathinfo provides *real* PATH_INFO\/PATH_TRANSLATED support for CGI. PHP's<br \/>\n; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok<br \/>\n; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting<br \/>\n; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting<br \/>\n; of zero causes PHP to behave as before. Default is 1. You should fix your scripts<br \/>\n; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.<br \/>\n; http:\/\/php.net\/cgi.fix-pathinfo<br \/>\n; cgi.fix_pathinfo=1 <\/code><\/p>\n<p>And change the last line to:<\/p>\n<p><code class=\"gris\">; cgi.fix_pathinfo provides *real* PATH_INFO\/PATH_TRANSLATED support for CGI. PHP's<br \/>\n; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok<br \/>\n; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting<br \/>\n; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting<br \/>\n; of zero causes PHP to behave as before. Default is 1. You should fix your scripts<br \/>\n; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.<br \/>\n; http:\/\/php.net\/cgi.fix-pathinfo<br \/>\ncgi.fix_pathinfo=0<\/code><\/p>\n<p>Save and close the file.<\/p>\n<p>Now, we&#8217;ll reload PHP-FPM so that the changes you made to php.ini goes through. As with the nginx daemon, you&#8217;ll need to enable the php daemon to start on boot.<\/p>\n<p><code>service php5-fpm reload<br \/>\nupdate-rc.d php5-fpm default<\/code><\/p>\n<p>The last step of our installation is to create a phpinfo page in the Document root directory.<\/p>\n<p><code>cd \/usr\/share\/nginx\/html\/<br \/>\nnano info.php<\/code><\/p>\n<p><code>&lt;?php<br \/>\nphpinfo();<br \/>\n?&gt;<\/code><\/p>\n<p>Access your phpinfo web page to see how it looks at this URL:<br \/>\nhttp:\/\/your_main_IP<\/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>The LEMP stack is a variant on the well-known LAMP stack, which stands for Linux, Apache, MySQL and PHP. With LEMP, Nginx (pronounced Engine-X) replaces Apache as the server component. Nginx is a lightweight, minimalist proxy server that routinely beats Apache in speed tests. Nginx has some advantages, but also some disadvantages when compared with<!-- 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":[70],"tags":[],"class_list":["post-2561","post","type-post","status-publish","format-standard","hentry","category-web-hosting","operating_system-ubuntu-14-04"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now &amp; Launch your own website !\" \/>\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\/setup-lemp-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 Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now &amp; Launch your own website !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-24T15:38:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-19T19:58:29+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\":\"Article\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/\"},\"author\":{\"name\":\"GloboTech Communications\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"headline\":\"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14\",\"datePublished\":\"2016-08-24T15:38:27+00:00\",\"dateModified\":\"2017-04-19T19:58:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/\"},\"wordCount\":394,\"commentCount\":0,\"articleSection\":[\"Web Hosting\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/\",\"name\":\"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#website\"},\"datePublished\":\"2016-08-24T15:38:27+00:00\",\"dateModified\":\"2017-04-19T19:58:29+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now & Launch your own website !\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/setup-lemp-ubuntu-14\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Setup LEMP (Linux, NGINX, MySQL, PHP) 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 Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech","description":"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now & Launch your own website !","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\/setup-lemp-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now & Launch your own website !","og_url":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-08-24T15:38:27+00:00","article_modified_time":"2017-04-19T19:58:29+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":"Article","@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/#article","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/"},"author":{"name":"GloboTech Communications","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"headline":"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14","datePublished":"2016-08-24T15:38:27+00:00","dateModified":"2017-04-19T19:58:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/"},"wordCount":394,"commentCount":0,"articleSection":["Web Hosting"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/","name":"How to Setup LEMP (Linux, NGINX, MySQL, PHP) on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-08-24T15:38:27+00:00","dateModified":"2017-04-19T19:58:29+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to setup the LEMP (Linux, Nginx, MySQL, PHP) stack on your Ubuntu 14 server. Read now & Launch your own website !","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/setup-lemp-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Setup LEMP (Linux, NGINX, MySQL, PHP) 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\/2561","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=2561"}],"version-history":[{"count":7,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2561\/revisions"}],"predecessor-version":[{"id":3014,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2561\/revisions\/3014"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}