{"id":953,"date":"2016-12-26T23:59:36","date_gmt":"2016-12-26T18:29:36","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=953"},"modified":"2026-10-12T14:38:52","modified_gmt":"2026-10-12T09:08:52","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":"How to Install Nginx, PHP 7.0, and MariaDB on Ubuntu 16.04.1"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date<\/strong>: December 26, 2016<br><strong>Last Updated<\/strong>: September 30, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This article explains how to install and configure <strong>Nginx, PHP 7.0, and MariaDB on Ubuntu 16.04.1<\/strong>. The setup uses an AWS Ubuntu server and covers the basic configuration required to run PHP-based web applications with Nginx. It also includes securing the MariaDB installation, configuring PHP-FPM, enabling PHP processing in Nginx, and configuring URL rewriting for applications that require it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding with the installation, ensure the following requirements are met:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An AWS EC2 instance running <strong>Ubuntu 16.04.1<\/strong>.<\/li>\n\n\n\n<li>Root or sudo access to the server.<\/li>\n\n\n\n<li>A stable internet connection to download the required packages.<\/li>\n\n\n\n<li>Basic knowledge of Linux commands and package management.<\/li>\n\n\n\n<li>Basic understanding of Nginx, PHP, and MariaDB.<\/li>\n\n\n\n<li>Port <strong>80 (HTTP)<\/strong> should be allowed in the server&#8217;s security group or firewall to access the web application.<\/li>\n\n\n\n<li>Sufficient permissions to modify Nginx and PHP configuration files.<\/li>\n<\/ul>\n\n\n<h2>Implementation<\/h2>\n<p>In this post, we are gonna explain how to install Nginx, PHP, and MariaDB on Ubuntu 16.04.1. We have used an AWS Ubuntu server in 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 start automatically 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 the MySQL service.<\/p>\n<p><code>systemctl start \u00a0mysql<\/code><\/p>\n<p>Secure the MySQL service<\/p>\n<p><code>mysql_secure_installation<\/code><\/p>\n<blockquote>\n<p>NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB<br \/>SERVERS 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 \/>password for the root user. If you&#8217;ve just installed MariaDB, and<br \/>you haven&#8217;t set the root password yet, the password will be blank,<br \/>so you should just press enter here.<\/p>\n<p>Enter current password for root (enter for none):<br \/>OK, successfully used password, moving on&#8230;<\/p>\n<p>Setting the root password ensures that nobody can log into the MariaDB<br \/>root user without the proper authorisation.<\/p>\n<p>Set root password? [Y\/n]<strong> y<\/strong><br \/>New password:<br \/>Re-enter new password:<br \/>Password updated successfully!<br \/>Reloading privilege tables..<br \/>&#8230; Success!<br \/>By default, a MariaDB installation has an anonymous user, allowing anyone<br \/>to log into MariaDB without having to have a user account created for<br \/>them. This is intended only for testing, and to make the installation<br \/>go a bit smoother. You should remove them before moving into a<br \/>production environment.<\/p>\n<p>Remove anonymous users? [Y\/n]<strong> y<\/strong><br \/>&#8230; Success!<\/p>\n<p>Normally, root should only be allowed to connect from &#8216;localhost&#8217;. This<br \/>ensures that someone cannot guess at the root password from the network.<\/p>\n<p>Disallow root login remotely? [Y\/n] <strong>y<\/strong><br \/>&#8230; skipping.<\/p>\n<p>By default, MariaDB comes with a database named &#8216;test&#8217; that anyone can<br \/>access. This is also intended only for testing, and should be removed<br \/>before moving into a production environment.<\/p>\n<p>Remove test database and access to it? [Y\/n] <strong>y<\/strong><br \/>&#8211; Dropping test database&#8230;<br \/>&#8230; Success!<br \/>&#8211; Removing privileges on test database&#8230;<br \/>&#8230; Success!<\/p>\n<p>Reloading the privilege tables will ensure that all changes made so far<br \/>will take effect immediately.<\/p>\n<p>Reload privilege tables now? [Y\/n]<strong> y<\/strong><br \/>&#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 \/>installation should now be secure.<\/p>\n<p>Thanks for using MariaDB!<\/p>\n<\/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 cgi.fix_pathinfo to 0 in php.ini.<\/p>\n<p><code>vi \/etc\/php\/7.0\/fpm\/php.ini<br \/><\/code>cgi.fix_pathinfo=0<\/p>\n<p>Start &amp; add the php7.0-fpm service to the 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>Enable PHP in the 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>\n<p>location ~ \\.php$ {<br \/>include snippets\/fastcgi-php.conf;<br \/>fastcgi_pass unix:\/run\/php\/php7.0-fpm.sock;<br \/>}<\/p>\n<\/blockquote>\n<p>Restart Nginx for the changes to take effect.<\/p>\n<p><code>\u00a0systemctl restart nginx<\/code><\/p>\n<p>Create a phpinfo page at\/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 in the browser: &#8220;<em>http:\/\/lPADDRESS\/info.php&#8221;<\/em><\/p>\n<h4>Enable the rewrite module:<\/h4>\n<p>Some applications require the rewrite module to be enabled. Enabling such settings in nginx is pretty simple. Open \/etc\/nginx\/sites-available\/default and modify the line below.<\/p>\n<p>From,<br \/>try_files $uri $uri\/ =404;<\/p>\n<p>To,<br \/>try_files $uri $uri\/ \/index.php?$args;<\/p>\n<p>Restart Nginx to take the changes into effect.<\/p>\n<p><code>\u00a0systemctl restart nginx<\/code><\/p>\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By following the steps in this article, you can install and configure <strong>Nginx, PHP 7.0, and MariaDB on Ubuntu 16.04.1<\/strong>. The article also demonstrates how to secure the MariaDB installation, configure PHP-FPM with Nginx, verify PHP using a <code>phpinfo()<\/code> page, and enable URL rewriting for PHP applications. This provides a basic web server environment suitable for hosting PHP-based applications on an Ubuntu server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. How do I install Nginx on Ubuntu 16.04.1?<\/strong><br>You can install Nginx using <code>apt-get install nginx<\/code>, then start and enable the service using <code>systemctl start nginx<\/code> and <code>systemctl enable nginx<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. How do I install MariaDB on Ubuntu 16.04.1?<\/strong><br>Install MariaDB using <code>apt-get install mariadb-server<\/code>. After installation, start the MySQL service and run <code>mysql_secure_installation<\/code> to secure the database server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. How do I install PHP and PHP-FPM on Ubuntu 16.04.1?<\/strong><br>You can install PHP 7.0, PHP-FPM, and the required PHP modules using the <code>apt-get install<\/code> command provided in the article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-install-mysql-8-0-on-centos-7\/\">How to install MySQL 8.0 on CentOS 7<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/mysql-installation-windows-server-2012\/\">MySQL Installation on Windows Server 2012<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business?. Our experts can help with\u00a0web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions. Get in touch with our team\u00a0<a href=\"https:\/\/pheonixsolutions.com\/contact\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: December 26, 2016Last Updated: September 30, 2026 Introduction This article explains how to install and configure Nginx, PHP [&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":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/953\/revisions"}],"predecessor-version":[{"id":12028,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/953\/revisions\/12028"}],"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}]}}