{"id":2077,"date":"2013-10-30T13:50:48","date_gmt":"2013-10-30T13:50:48","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=2077"},"modified":"2013-10-30T13:50:48","modified_gmt":"2013-10-30T13:50:48","slug":"install-nginx-php5-mysql-lemp-ubuntu-1310","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2013\/10\/install-nginx-php5-mysql-lemp-ubuntu-1310\/","title":{"rendered":"Install Nginx with PHP5 and MySQL (LEMP) in Ubuntu 13.10 Server"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/ubuntu-logo.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2015\" alt=\"Nginx, php, mysql\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/ubuntu-logo.jpg\" width=\"170\" height=\"170\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/ubuntu-logo.jpg 170w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/ubuntu-logo-150x150.jpg 150w\" sizes=\"auto, (max-width: 170px) 100vw, 170px\" \/><\/a><\/p>\n<p>This tutorial shows you how to install LEMP stack in Ubuntu 13.10. <b>LEMP<\/b> stands for <b>Linux<\/b>, <b>Nginx<\/b> (pronounced &#8220;engine x&#8221;), <b>MySQL<\/b> and <b>PHP<\/b>. The <b>nginx<\/b> project started with a strong focus on high concurrency, high performance and low memory usage. So it&#8217;s a good alternative to <b>Apache<\/b> webserver for building websites on low memory hosts.<\/p>\n<p><b>Tutorial Objectives:<\/b><\/p>\n<ul>\n<li>Install Nginx, Php5, MySQL (LEMP) in Ubuntu 13.10 Server<\/li>\n<li>Enjoy!<\/li>\n<\/ul>\n<p>To get started, first login your Ubuntu Server and follow the steps below:<\/p>\n<p><b>1. Intall MySQL<\/b><\/p>\n<p>MySQL is a database management system which stores and organizes references to the information the webserver needs.<\/p>\n<p>To install it, run command:<\/p>\n<pre>sudo apt-get install mysql-server mysql-client<\/pre>\n<p>While the installing process, you&#8217;ll be asked to type a password for MySQL root user.<\/p>\n<p><b>2. Install Nginx<\/b><\/p>\n<p>Nginx is available in Ubuntu&#8217;s repository, run command below to install it:<\/p>\n<pre>sudo apt-get install nginx<\/pre>\n<p>Or you can install the latest stable version from Nginx PPA:<\/p>\n<pre>sudo apt-get install python-software-properties\n\nsudo add-apt-repository ppa:nginx\/stable\n\nsudo apt-get update\n\nsudo apt-get install nginx<\/pre>\n<p>Once installed, start <b>Nginx<\/b> by:<\/p>\n<pre>sudo service nginx start<\/pre>\n<p>To check out if nginx is working, go to <span style=\"text-decoration: underline;\"><i>http:\/\/serverip<\/i><\/span>:<\/p>\n<div id=\"attachment_2078\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/nginxisrunning.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2078\" class=\"size-full wp-image-2078\" alt=\"nginx is working ubuntu 13.10\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/nginxisrunning.jpg\" width=\"520\" height=\"299\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/nginxisrunning.jpg 520w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/nginxisrunning-300x172.jpg 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/a><p id=\"caption-attachment-2078\" class=\"wp-caption-text\">nginx is working ubuntu 13.10<\/p><\/div>\n<p><b>3. Install PHP5<\/b><\/p>\n<p><b>PHP<\/b> is a reflective programming language, which makes it possible for all these different parts to work together.<\/p>\n<p>We can make PHP5 work in nginx through PHP-FPM, which is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.<\/p>\n<p>Run command below to install php5-fpm:<\/p>\n<pre>sudo apt-get install php5-fpm<\/pre>\n<p><b>4. Setup Nginx<\/b><\/p>\n<p>The nginx configuration is in <i>\/etc\/nginx\/nginx.conf<\/i>, read this <a title=\"Nginx configuration example\" href=\"http:\/\/wiki.nginx.org\/NginxFullExample\" target=\"_blank\">configuration example<\/a>.<\/p>\n<p>Now, let&#8217;s modify the default site example:<\/p>\n<pre>sudo vi \/etc\/nginx\/sites-available\/default<\/pre>\n<p>Here you can define root directory (to put WordPress files there), your site domain, as well as other settings. See the example below:<\/p>\n<pre style=\"background: #FFFFFF;\">server {\n\tlisten 80 default_server;\n\tlisten [::]:80 default_server ipv6only=on;\n\n\troot \/usr\/share\/nginx\/html;\n\tindex index.php index.html index.htm;\n\n\t# Make site accessible from http:\/\/localhost\/\n\tserver_name localhost;\n\n\tlocation \/ {\n\n\t\ttry_files $uri $uri\/ \/index.php;\n\n\t}\n\n\tlocation \/doc\/ {\n\t\talias \/usr\/share\/doc\/;\n\t\tautoindex on;\n\t\tallow 127.0.0.1;\n\t\tallow ::1;\n\t\tdeny all;\n\t}\n\n\t#\n\terror_page 500 502 503 504 \/50x.html;\n\tlocation = \/50x.html {\n\t\troot \/usr\/share\/nginx\/html;\n\t}\n\n\tlocation ~ \\.php$ {\n\n\t\t# With php5-fpm:\n                try_files $uri =404;\n\t\tfastcgi_pass unix:\/var\/run\/php5-fpm.sock;\n\t\tfastcgi_index index.php;\n\t\tinclude fastcgi_params;\n\t}\n\n\t# deny access to .htaccess files, if Apache's document root\n\t# concurs with nginx's one\n\t#\n\tlocation ~ \/\\.ht {\n\t\tdeny all;\n\t}\n}<\/pre>\n<p>After that, reload Nginx:<\/p>\n<pre>sudo service nginx reload<\/pre>\n<p><b>4. Check out if PHP is working<\/b><\/p>\n<p>Create the test file:<\/p>\n<pre>sudo vi \/usr\/share\/nginx\/html\/info.php<\/pre>\n<p>Add following lines and save the file:<\/p>\n<pre style=\"background:#FFFFFF\">&lt;?php\nphpinfo();\n?&gt;<\/pre>\n<p>Go to <u><\/i>http:\/\/serverip\/info.php<\/i><\/u> in client&#8217;s web browser and you&#8217;ll see:<\/p>\n<div id=\"attachment_2079\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/phpisworking.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2079\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/phpisworking.jpg\" alt=\"php is working\" width=\"520\" height=\"299\" class=\"size-full wp-image-2079\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/phpisworking.jpg 520w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/phpisworking-300x172.jpg 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/a><p id=\"caption-attachment-2079\" class=\"wp-caption-text\">php is working<\/p><\/div>\n<p><b>5. Get MySQL working with PHP<\/b><\/p>\n<p>Install Xcache, a free and open PHP opcode cacher for caching and optimizing PHP intermediate code, as well as other PHP modules:<\/p>\n<pre>sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xcache<\/pre>\n<p>Then restart php5:<\/p>\n<pre>sudo service php5-fpm restart<\/pre>\n<p>Now reload <u><\/i>http:\/\/serverip\/info.php<\/i><\/u> page and scroll down to find out if there&#8217;s a section about MySQL:<\/p>\n<div id=\"attachment_2080\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/mysqlisworking.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2080\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/mysqlisworking.jpg\" alt=\"mysql is working with php\" width=\"520\" height=\"299\" class=\"size-full wp-image-2080\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/mysqlisworking.jpg 520w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2013\/10\/mysqlisworking-300x172.jpg 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/a><p id=\"caption-attachment-2080\" class=\"wp-caption-text\">mysql is working with php<\/p><\/div>\n<p>Now your LEMP server is up and running, see <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2013\/10\/install-wordpress-ubuntu-13-10-server\/\" title=\"install wordpress in ubuntu 13.10 server\" target=\"_blank\">how to install wordpress on Ubuntu 13.10<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to install LEMP stack in Ubuntu 13.10. LEMP stands for Linux, Nginx (pronounced &#8220;engine x&#8221;), MySQL and PHP. The nginx project started with a strong focus on high concurrency, high performance and low memory usage. So it&#8217;s a good alternative to Apache webserver for building websites on low memory hosts. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,1],"tags":[747,748,37],"class_list":["post-2077","post","type-post","status-publish","format-standard","hentry","category-howtos","category-ubuntu-server-2","tag-lemp","tag-nginx","tag-ubuntu-13-10"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/2077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=2077"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/2077\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=2077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=2077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=2077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}