{"id":12854,"date":"2019-03-28T23:55:14","date_gmt":"2019-03-28T23:55:14","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12854"},"modified":"2019-03-28T23:55:14","modified_gmt":"2019-03-28T23:55:14","slug":"install-wordpress-with-nginx-mariadb-10-and-php-7-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/install-wordpress-with-nginx-mariadb-10-and-php-7-on-ubuntu-18-04\/","title":{"rendered":"Install WordPress with Nginx, MariaDB 10 and PHP 7 on Ubuntu 18.04"},"content":{"rendered":"<p><strong>WordPress 5<\/strong>\u00a0recently released with some core changes, such as the Gutenberg editor. Many of our readers might want to test it on their own server. For those of you, in this tutorial we are going to setup\u00a0<strong>WordPress 5<\/strong>with\u00a0<strong>LEMP<\/strong>\u00a0on\u00a0<strong>Ubuntu 18.04<\/strong>.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/install-wordpress-with-nginx-mariadb-php-on-debian-9\/\" target=\"_blank\" rel=\"noopener\">Install WordPress with Nginx, MariaDB 10 and PHP 7 on Debian 9<\/a><\/p>\n<p>For people who are not aware,\u00a0<strong>LEMP<\/strong>\u00a0is a popular combination of\u00a0<strong>Linux<\/strong>,\u00a0<strong>Nginx<\/strong>,\u00a0<strong>MySQL\/MariaDB<\/strong>\u00a0and\u00a0<strong>PHP<\/strong>.<\/p>\n<h4>Requirements<\/h4>\n<ol>\n<li>A dedicated server or a\u00a0<strong>VPS<\/strong>\u00a0(<strong>Virtual Private Server<\/strong>) with\u00a0<strong>Ubuntu 18.04<\/strong>\u00a0minimal installation.<\/li>\n<\/ol>\n<p>This tutorial will guide you through the installation of all the required packages, creating your own database, preparing vhost and completing the WordPress installation via browser.<\/p>\n<h3>Installing Nginx Web Server on Ubuntu 18.04<\/h3>\n<p>First we will prepare our web server\u00a0<strong>Nginx<\/strong>. To install the package, run the following command:<\/p>\n<pre>$ sudo apt update &amp;&amp; sudo apt upgrade\r\n$ sudo apt install nginx\r\n<\/pre>\n<p>To start the\u00a0<strong>nginx<\/strong>\u00a0service and automatically start it upon system boot, run the following commands:<\/p>\n<pre>$ sudo systemctl start nginx.service\r\n$ sudo systemctl enable nginx.service\r\n<\/pre>\n<h3>Creating Vhost for WordPress Website on Nginx<\/h3>\n<p>Now we will create\u00a0<strong>vhost<\/strong>\u00a0for our WordPress website. Create the following file using your favorite text editor:<\/p>\n<pre>$ sudo vim \/etc\/nginx\/sites-available\/wordpress.conf\r\n<\/pre>\n<p>In the example below, change\u00a0<code>example.com<\/code>\u00a0with the domain you wish to use:<\/p>\n<pre>server {\r\n    listen 80;\r\n    listen [::]:80;\r\n    root \/var\/www\/html\/wordpress;\r\n    index  index.php index.html index.htm;\r\n    server_name <strong>example.com www.example.com<\/strong>;\r\n\r\n     client_max_body_size 100M;\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ \/index.php?$args;        \r\n    }\r\n\r\n    location ~ \\.php$ {\r\n    include snippets\/fastcgi-php.conf;\r\n    fastcgi_pass             unix:\/var\/run\/php\/php7.2-fpm.sock;\r\n    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n    }\r\n}\r\n<\/pre>\n<p>Save the file and exit. Then enable the site with:<\/p>\n<pre>$ sudo ln -s \/etc\/nginx\/sites-available\/wordpress.conf  \/etc\/nginx\/sites-enabled\/\r\n<\/pre>\n<p>Then reload nginx with:<\/p>\n<pre>$ sudo systemctl reload nginx \r\n<\/pre>\n<h3>Installing MariaDB 10 on Ubuntu 18.04<\/h3>\n<p>We will use\u00a0<strong>MariaDB<\/strong>\u00a0for our WordPress database. To install MariaDB run the following command:<\/p>\n<pre>$ sudo apt install mariadb-server mariadb-client\r\n<\/pre>\n<p>Once the installation is complete, we will start it and configure it to start automatically on system boot:<\/p>\n<pre>$ sudo systemctl start mariadb.service\r\n$ sudo systemctl enable mariadb.service\r\n<\/pre>\n<p>Next secure your MariaDB installation by running the following command:<\/p>\n<pre>$ sudo mysql_secure_installation\r\n<\/pre>\n<p>Simply answer the questions in the prompt to complete the task.<\/p>\n<h3>Creating WordPress Database for Website<\/h3>\n<p>After that we will prepare the database, database user and password for that user. They will be used by our WordPress application so it can connect to the MySQL server.<\/p>\n<pre>$ sudo mysql -u root -p\r\n<\/pre>\n<p>With the commands below, we will first create database, then a database user and its password. Then we will grant the user privileges to that database.<\/p>\n<pre>CREATE DATABASE <strong>wordpress<\/strong>;\r\nCREATE USER '<strong>wp_user<\/strong>'@'localhost' IDENTIFIED BY \u2018<strong>secure_password<\/strong>\u2019;\r\nGRANT ALL ON <strong>wordpress<\/strong>.* TO '<strong>wp_user<\/strong>'@'localhost' ;\r\nFLUSH PRIVILEGES;\r\nEXIT;\r\n<\/pre>\n<h3>Installing PHP 7 on Ubuntu 18.04<\/h3>\n<p>Since\u00a0<strong>WordPress<\/strong>\u00a0is application written in\u00a0<strong>PHP<\/strong>, we will install PHP and the required PHP packages to run WordPress, use the command below:<\/p>\n<pre>$ sudo apt install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl\r\n<\/pre>\n<p>Once the install is complete, we will start the\u00a0<strong>php-fpm<\/strong>\u00a0service and enable it:<\/p>\n<pre>$ sudo systemctl start php7.2-fpm\r\n$ systemctl enable php7.2-fpm\r\n<\/pre>\n<h3>Installing WordPress 5 on Ubuntu 18.04<\/h3>\n<p>From this point on, starts the easy part. Download the latest WordPress package with the following\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">wget command<\/a>:<\/p>\n<pre>$ cd \/tmp &amp;&amp; wget http:\/\/wordpress.org\/latest.tar.gz\r\n<\/pre>\n<p>Then extract the archive with:<\/p>\n<pre>$ sudo tar -xvzf latest.tar.gz -C \/var\/www\/html\r\n<\/pre>\n<p>The above will create our document root that we have set in the vhost which is\u00a0<strong>\/var\/www\/html\/wordpress<\/strong>. We will then need to change the ownership of the files and folders within that directory with:<\/p>\n<pre>$ sudo chown www-data: \/var\/www\/html\/wordpress\/ -R\r\n<\/pre>\n<p>Now we are ready to run the installation of our WordPress. If you have used unregistered\/non-existing domain, you can configure your hosts\u00a0<strong>\/etc\/hosts<\/strong>\u00a0file with the following record:<\/p>\n<pre>192.168.1.100 example.com\r\n<\/pre>\n<p>Presuming that your server\u2019s IP address is\u00a0<strong>192.168.1.100<\/strong>\u00a0and that the domain you are using is\u00a0<strong>example.com<\/strong>That way your computer will resolve\u00a0<strong>example.com<\/strong>\u00a0on the given IP address.<\/p>\n<p>Now load your domain into a browser, you should see the WordPress installation page:<\/p>\n<div id=\"attachment_31973\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/Select-WordPress-Install-Language.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31973\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/Select-WordPress-Install-Language.png\" sizes=\"auto, (max-width: 1209px) 100vw, 1209px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/Select-WordPress-Install-Language.png 1209w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/Select-WordPress-Install-Language-768x523.png 768w\" alt=\"Select WordPress Install Language\" width=\"1209\" height=\"823\" aria-describedby=\"caption-attachment-31973\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-31973\" class=\"wp-caption-text\">Select WordPress Install Language<\/p>\n<\/div>\n<p>On the next page input the database credentials that we have setup earlier:<\/p>\n<div id=\"attachment_31974\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Database-Settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31974\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Database-Settings.png\" sizes=\"auto, (max-width: 1172px) 100vw, 1172px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Database-Settings.png 1172w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Database-Settings-768x523.png 768w\" alt=\"WordPress Database Settings\" width=\"1172\" height=\"798\" aria-describedby=\"caption-attachment-31974\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-31974\" class=\"wp-caption-text\">WordPress Database Settings<\/p>\n<\/div>\n<p>Submit the form and on the next screen configure your website title, admin user and email:<\/p>\n<div id=\"attachment_31975\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Website-Setup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31975\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Website-Setup.png\" sizes=\"auto, (max-width: 1209px) 100vw, 1209px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Website-Setup.png 1209w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2019\/02\/WordPress-Website-Setup-768x523.png 768w\" alt=\"WordPress Website Setup\" width=\"1209\" height=\"823\" aria-describedby=\"caption-attachment-31975\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-31975\" class=\"wp-caption-text\">WordPress Website Setup<\/p>\n<\/div>\n<p>Your installation is now complete and you can start managing your WordPress website. You can start by installing some fresh new theme or extending the site functionality via plugins.<\/p>\n<h5>Conclusion<\/h5>\n<p>That was it. The process of setting up your own\u00a0<strong>WordPress<\/strong>\u00a0installation on\u00a0<strong>Ubuntu 18.04<\/strong>. I hope the process was easy and straightforward.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-wordpress-with-nginx-mariadb-php-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress 5\u00a0recently released with some core changes, such as the Gutenberg editor. Many of our readers might want to test it on their own server. For those of you, in this tutorial we are going to setup\u00a0WordPress 5with\u00a0LEMP\u00a0on\u00a0Ubuntu 18.04. Read Also:\u00a0Install WordPress with Nginx, MariaDB 10 and PHP 7 on Debian 9 For people who &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/install-wordpress-with-nginx-mariadb-10-and-php-7-on-ubuntu-18-04\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install WordPress with Nginx, MariaDB 10 and PHP 7 on Ubuntu 18.04&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12854","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12854"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12854\/revisions"}],"predecessor-version":[{"id":12855,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12854\/revisions\/12855"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}