{"id":953,"date":"2016-12-26T23:59:36","date_gmt":"2016-12-26T18:29:36","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=953"},"modified":"2017-03-23T13:57:26","modified_gmt":"2017-03-23T08:27:26","slug":"install-nginx-php-mariadb-ubuntu-16-04-1","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-nginx-php-mariadb-ubuntu-16-04-1\/","title":{"rendered":"Install Nginx, Php, MariaDB on Ubuntu 16.04.1"},"content":{"rendered":"<p>In this post, we are gonna explain on how to install nginx, Php, Mariadb on Ubuntu 16.04.1. We have used AWS ubuntu server on this article.<\/p>\n<p><code>\u00a0apt-get install nginx<\/code><\/p>\n<p>Start the nginx service.<\/p>\n<p><code>systemctl start nginx<\/code><\/p>\n<p>Enable the service on startup so that it will get automatically started whenever the server reboots.<\/p>\n<p><code>systemctl enable nginx<\/code><\/p>\n<p>Install MariaDB server on the host<\/p>\n<p><code>apt-get install mariadb-server<\/code><\/p>\n<p>Start mysql service.<\/p>\n<p><code>systemctl start \u00a0mysql<\/code><\/p>\n<p>Secure mysql service<\/p>\n<p><code>mysql_secure_installation<\/code><\/p>\n<blockquote><p>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB<br \/>\nSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!<\/p>\n<p>In order to log into MariaDB to secure it, we&#8217;ll need the current<br \/>\npassword for the root user. If you&#8217;ve just installed MariaDB, and<br \/>\nyou haven&#8217;t set the root password yet, the password will be blank,<br \/>\nso you should just press enter here.<\/p>\n<p>Enter current password for root (enter for none):<br \/>\nOK, successfully used password, moving on&#8230;<\/p>\n<p>Setting the root password ensures that nobody can log into the MariaDB<br \/>\nroot user without the proper authorisation.<\/p>\n<p>Set root password? [Y\/n]<strong> y<\/strong><br \/>\nNew password:<br \/>\nRe-enter new password:<br \/>\nPassword updated successfully!<br \/>\nReloading privilege tables..<br \/>\n&#8230; Success!<br \/>\nBy default, a MariaDB installation has an anonymous user, allowing anyone<br \/>\nto log into MariaDB without having to have a user account created for<br \/>\nthem. This is intended only for testing, and to make the installation<br \/>\ngo a bit smoother. You should remove them before moving into a<br \/>\nproduction environment.<\/p>\n<p>Remove anonymous users? [Y\/n]<strong> y<\/strong><br \/>\n&#8230; Success!<\/p>\n<p>Normally, root should only be allowed to connect from &#8216;localhost&#8217;. This<br \/>\nensures that someone cannot guess at the root password from the network.<\/p>\n<p>Disallow root login remotely? [Y\/n] <strong>y<\/strong><br \/>\n&#8230; skipping.<\/p>\n<p>By default, MariaDB comes with a database named &#8216;test&#8217; that anyone can<br \/>\naccess. This is also intended only for testing, and should be removed<br \/>\nbefore moving into a production environment.<\/p>\n<p>Remove test database and access to it? [Y\/n] <strong>y<\/strong><br \/>\n&#8211; Dropping test database&#8230;<br \/>\n&#8230; Success!<br \/>\n&#8211; Removing privileges on test database&#8230;<br \/>\n&#8230; Success!<\/p>\n<p>Reloading the privilege tables will ensure that all changes made so far<br \/>\nwill take effect immediately.<\/p>\n<p>Reload privilege tables now? [Y\/n]<strong> y<\/strong><br \/>\n&#8230; Success!<\/p>\n<p>Cleaning up&#8230;<\/p>\n<p>All done! If you&#8217;ve completed all of the above steps, your MariaDB<br \/>\ninstallation should now be secure.<\/p>\n<p>Thanks for using MariaDB!<\/p><\/blockquote>\n<p>Enable the service on startup.<\/p>\n<p><code>systemctl enable mysql<\/code><\/p>\n<p>Install php, php-fpm and basic required modules.<\/p>\n<p><code>apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache \u00a0php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mbstring php-gettext php7.0-zip php7.0-fpm php7.0 php7.0-dev<\/code><\/p>\n<p>Edit\u00a0cgi.fix_pathinfo to 0 on php.ini.<\/p>\n<p><code>vi \/etc\/php\/7.0\/fpm\/php.ini<\/code><\/p>\n<blockquote><p>cgi.fix_pathinfo=0<\/p><\/blockquote>\n<p>Start &amp; add \u00a0php7.0-fpm service in reboot safe.<\/p>\n<p><code>systemctl enable php7.0-fpm<\/code><\/p>\n<p><code>systemctl start \u00a0php7.0-fpm<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>Enable php on nginx configuration. Uncomment the following lines on \/etc\/nginx\/site-available\/default<\/p>\n<p><code>vi <\/code><code>\/etc\/nginx\/sites-available\/default<\/code><\/p>\n<blockquote><p>location ~ \\.php$ {<br \/>\ninclude snippets\/fastcgi-php.conf;<br \/>\nfastcgi_pass unix:\/run\/php\/php7.0-fpm.sock;<br \/>\n}<\/p><\/blockquote>\n<p>Restart nginx to changes come into effect.<\/p>\n<p><code>\u00a0systemctl restart nginx<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>Create a phpinfo page on \/var\/www\/html\/info.php<\/p>\n<p><code>cat &gt;\u00a0\/var\/www\/html\/info.php<\/code><\/p>\n<p><code>&lt;?php<\/code><\/p>\n<p><code>phpinfo();<\/code><\/p>\n<p><code>?&gt;<\/code><\/p>\n<p>Press\u00a0<strong>Ctrl + D\u00a0<\/strong>to save the file.<\/p>\n<p>Access the IP address on the browser &#8220;<em>http:\/\/lPADDRESS\/info.php&#8221;<\/em><\/p>\n<h4>Enable Rewrite module:<\/h4>\n<p>Some application requires rewrite module to be enabled. Enabling such settings in nginx is pretty simple. Open \/etc\/nginx\/sites-available\/default and modify the below line.<\/p>\n<p>From,<\/p>\n<blockquote><p>try_files $uri $uri\/ =404;<\/p><\/blockquote>\n<p>To,<\/p>\n<blockquote><p>try_files $uri $uri\/ \/index.php?$args;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>Restart nginx to take changes comes into effect.<\/p>\n<p><code>\u00a0systemctl restart nginx<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we are gonna explain on how to install nginx, Php, Mariadb on Ubuntu 16.04.1. We have used [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[272,271,273,274],"class_list":["post-953","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-mariadb","tag-nginx","tag-php","tag-ubuntu","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-fn","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/953","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=953"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/953\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=953"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}