{"id":6304,"date":"2021-05-09T19:58:05","date_gmt":"2021-05-09T19:58:05","guid":{"rendered":"https:\/\/linuxways.net\/?p=6304"},"modified":"2021-05-09T19:58:05","modified_gmt":"2021-05-09T19:58:05","slug":"how-to-install-wordpress-with-nginx-on-ubuntu","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-wordpress-with-nginx-on-ubuntu\/","title":{"rendered":"How to Install WordPress with Nginx on Ubuntu"},"content":{"rendered":"<p>WordPress is used to create, modify, publish, and manage a blog or a website with minimum coding knowledge. It is the most extensively used free and open-source CMS. The reasons behind its popularity are its ease of use, a thousand free and customizable website templates to choose from, thousands of free and paid plugins to add advanced functionalities to a website, and its support of various media types.<\/p>\n<p>In today\u2019s guide, you will learn to install WordPress CMS in <strong>Ubuntu 20.04 LTS <\/strong>with NGINX (web server). If you want to set up WordPress with Apache web server, visit our guide on <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-setup-wordpress-on-ubuntu-server-with-apache\/\">How to Setup WordPress on Ubuntu Server with Apache<\/a>.<\/p>\n<p><strong>Note<\/strong>: You must have a user with the <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-add-a-user-to-sudoers-on-ubuntu\/\">sudo privileges<\/a> for installing WordPress on your machine.<\/p>\n<h2>Step 1: Install Nginx<\/h2>\n<p>The default repositories of Ubuntu contain the <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-nginx-on-ubuntu-20-04\/\">Nginx<\/a> package. You can install it through this command in the Terminal:<\/p>\n<pre>$ sudo apt-get install nginx<\/pre>\n<p>Enter sudo password. If prompted with the <strong>y\/n<\/strong> choice, hit <strong>y<\/strong> to continue. After that, it will begin installing Nginx on the system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"853\" height=\"497\" class=\"wp-image-6305\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-27.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-27.png 853w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-27-300x175.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-27-768x447.png 768w\" sizes=\"auto, (max-width: 853px) 100vw, 853px\" \/><\/p>\n<p>Once the installation is finished, start Nginx service as follows:<\/p>\n<pre>$ sudo systemctl start nginx<\/pre>\n<p>Also, enable the service at boot:<\/p>\n<pre>$ sudo systemctl enable nginx<\/pre>\n<p>Then to confirm if the service is fully functional, run this command:<\/p>\n<pre>$ sudo systemctl status nginx<\/pre>\n<p>If the service is functional, you will be seeing <strong>active (running)<\/strong> in the output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"951\" height=\"286\" class=\"wp-image-6306\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-28.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-28.png 951w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-28-300x90.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-28-768x231.png 768w\" sizes=\"auto, (max-width: 951px) 100vw, 951px\" \/><\/p>\n<h2>Step 2: Install MariaDB and PHP<\/h2>\n<p>Now install <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-install-mariadb-on-ubuntu-20-04-lts\/\">MariaDB<\/a> and PHP for WordPress to function. Execute the below command to do so:<\/p>\n<pre>$ sudo apt-get install php php-mysql php-fpm php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip mariadb-server mariadb-client<\/pre>\n<p>When you are prompted with the <strong>y\/n<\/strong> option, hit <strong>y<\/strong> to continue. After that, it will start installing the packages on the system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"134\" class=\"wp-image-6307\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-29.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-29.png 993w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-29-300x40.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-29-768x104.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/p>\n<p>When the installation is finished, start MariaDB service:<\/p>\n<pre><strong>$ sudo systemctl start mariadb<\/strong><\/pre>\n<p>Also, enable the MariaDB service through this command:<\/p>\n<pre>$ sudo systemctl enable mariadb<\/pre>\n<p>Then to confirm if the service is fully functional, use this command:<\/p>\n<pre>$ sudo systemctl status mariadb<\/pre>\n<p>If the service is functional, you will be seeing <strong>active (running)<\/strong> in the output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"970\" height=\"106\" class=\"wp-image-6308\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-30.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-30.png 970w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-30-300x33.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-30-768x84.png 768w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/p>\n<p>Now start the PHP-FPM service:<\/p>\n<pre>$ sudo systemctl start php7.4-fpm<\/pre>\n<p>Then enable the service at boot:<\/p>\n<pre>$ sudo systemctl enable php7.4-fpm<\/pre>\n<p>Then to confirm if the service is fully functional, use this command:<\/p>\n<pre>$ sudo systemctl status php7.4-fpm<\/pre>\n<p>If the service is functional, you will be seeing <strong>active (running)<\/strong> status.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"826\" height=\"264\" class=\"wp-image-6309\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-31.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-31.png 826w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-31-300x96.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-31-768x245.png 768w\" sizes=\"auto, (max-width: 826px) 100vw, 826px\" \/><\/p>\n<p>Now to secure the MariaDB installation, execute this command:<\/p>\n<pre>$ sudo mysql_secure_installation<\/pre>\n<p>Hit <strong>Enter<\/strong> when asked for the current root password. When asked to set a root password, press <strong>y<\/strong> and then set a password. <img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"525\" class=\"wp-image-6310\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-32.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-32.png 843w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-32-300x187.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-32-768x478.png 768w\" sizes=\"auto, (max-width: 843px) 100vw, 843px\" \/><\/p>\n<p>For all the later questions, hit <strong>y<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"877\" height=\"638\" class=\"wp-image-6311\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-33.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-33.png 877w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-33-300x218.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-33-768x559.png 768w\" sizes=\"auto, (max-width: 877px) 100vw, 877px\" \/><\/p>\n<h2>Step 3: Create Database for WordPress<\/h2>\n<p>WordPress requires the MySQL database for storing and managing data on the servers. Here, we will create a MySQL database and then a user for WordPress.<\/p>\n<p>First, log in to MySQL shell using this command:<\/p>\n<pre>$ sudo mysql -u root -p<\/pre>\n<p>Now from the MySQL shell, run the below command to create a database named \u201cwpress\u201d:<\/p>\n<pre>$ CREATE DATABASE wpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;<\/pre>\n<p>Create a user named \u201cwpressuser\u201d with the password \u201ctintin\u201d:<\/p>\n<pre>$ CREATE USER 'wpressuser'@'localhost' IDENTIFIED BY 'tintin';<\/pre>\n<p>Now give the new user \u201cwpressuser\u201d access to the database \u201cwpress\u201d:<\/p>\n<pre>$ GRANT ALL ON wpress.* TO 'wpressuser'@'localhost'<\/pre>\n<p>Now execute the below commands for the changes to take effect:<\/p>\n<pre>$ FLUSH PRIVILEGES;<\/pre>\n<p>Now exit the MySQL shell:<\/p>\n<pre>$ EXIT;<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"959\" height=\"653\" class=\"wp-image-6312\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-34.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-34.png 959w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-34-300x204.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-34-768x523.png 768w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/p>\n<h2>Step 4: Download and Install WordPress<\/h2>\n<p>Now in this step, we will download and install WordPress. Before downloading WordPress, create a root directory for a WordPress installation. Execute the below command in Terminal to do so:<\/p>\n<pre>$ sudo mkdir -p \/var\/www\/html\/wpress<\/pre>\n<p>Download WordPress using the below command:<\/p>\n<pre>$ wget <a href=\"http:\/\/wordpress.org\/latest.tar.gz\">http:\/\/wordpress.org\/latest.tar.gz<\/a><\/pre>\n<p>Extract the downloaded WordPress package:<\/p>\n<pre>$ tar xfvz latest.tar.gz<\/pre>\n<p>After the archive is extracted, copy the WordPress folder into the \/var\/www\/html\/wpress directory:<\/p>\n<pre>$ sudo cp -r wordpress\/* \/var\/www\/html\/wpress<\/pre>\n<p>Now change the ownership and assign permission to the WordPress root directory. We are doing this step to avoid errors during installation.<\/p>\n<pre>$ sudo chown -R www-data \/var\/www\/html\/wpress<\/pre>\n<pre>$ sudo chmod -R 755 \/var\/www\/html\/wpress<\/pre>\n<p>After installation, we will revert permissions.<\/p>\n<h2>Step 5: Create NGINX Virtual Host for WordPress<\/h2>\n<p>Create Nginx virtual host file for WordPress. Run the below command in Terminal to do this:<\/p>\n<pre>$ sudo nano \/etc\/nginx\/conf.d\/wpress.conf<\/pre>\n<p>Copy-paste the below content in the file:<\/p>\n<pre>server {\r\n\r\nlisten 80;\r\n\r\nlisten [::]:80;\r\n\r\nroot \/var\/www\/html\/wpress; index index.php index.html index.htm;\r\n\r\nserver_name wpress.conf www.wpress.conf;\r\n\r\nerror_log \/var\/log\/nginx\/wpress.conf_error.log;\r\n\r\naccess_log \/var\/log\/nginx\/wpress.conf_access.log;\r\n\r\nclient_max_body_size 100M;\r\n\r\nlocation \/ {\r\n\r\ntry_files $uri $uri\/ \/index.php?$args;\r\n\r\n}\r\n\r\nlocation ~ \\.php$ {\r\n\r\ninclude snippets\/fastcgi-php.conf;\r\n\r\n<strong> fastcgi_pass unix:\/run\/php\/php7.4-fpm.sock<\/strong>;\r\n\r\n}\r\n\r\n}\r\n<\/pre>\n<p>Save and close the file.<br \/>\nThen remove the default Nginx server blocks using the command below in the Terminal:<\/p>\n<pre>$ sudo rm \/etc\/nginx\/sites-enabled\/default<\/pre>\n<p>Now check for any errors in the Nginx configuration file using the command below in the Terminal:<\/p>\n<pre>$ sudo systemctl config nginx<\/pre>\n<p>The output below shows configuration is okay.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"815\" height=\"77\" class=\"wp-image-6313\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-35.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-35.png 815w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-35-300x28.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-35-768x73.png 768w\" sizes=\"auto, (max-width: 815px) 100vw, 815px\" \/><\/p>\n<p>Now restart the Nginx server to apply changes.<\/p>\n<pre>$ sudo systemctl restart nginx<\/pre>\n<h2>Step 6: Launch the WordPress Web Installer<\/h2>\n<p>Now to complete the WordPress installation, open the web browser and point it to your server\u2019s IP address.<\/p>\n<pre>http:\/\/ip-address<\/pre>\n<p>By doing so, the following installation wizard will appear. Choose the preferred language and then hit <strong>Continue<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"619\" class=\"wp-image-6314\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-36.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-36.png 820w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-36-300x226.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-36-768x580.png 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/p>\n<p>Enter a title for your WordPress site, then user name, and password which will be used to login to the WordPress site. Also, provide your email address and then click <strong>Install WordPress<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"705\" class=\"wp-image-6315\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-37.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-37.png 868w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-37-300x244.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-37-768x624.png 768w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\" \/><\/p>\n<p>Once WordPress is installed, you will be seeing the following view. Click <strong>Log In<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"869\" height=\"490\" class=\"wp-image-6316\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-38.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-38.png 869w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-38-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-38-768x433.png 768w\" sizes=\"auto, (max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>You will see the WordPress Admin panel once you\u2019re logged in. <img loading=\"lazy\" decoding=\"async\" width=\"1043\" height=\"627\" class=\"wp-image-6317\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39.png 1043w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39-300x180.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39-1024x616.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39-768x462.png 768w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/05\/word-image-39-501x300.png 501w\" sizes=\"auto, (max-width: 1043px) 100vw, 1043px\" \/><\/p>\n<p>Now revert the ownership back to root user:<\/p>\n<pre>$ sudo chown -R root \/var\/www\/html\/wpress<\/pre>\n<p>That is all there is to it! In this guide, you have learned the installation of WordPress with Nginx on Ubuntu. Visit official <a href=\"https:\/\/wordpress.org\/support\/\">documentation<\/a> to get started with the basic usage of WordPress.<\/p>","protected":false},"excerpt":{"rendered":"<p>WordPress is used to create, modify, publish, and manage a blog or a website with minimum coding knowledge. It is the most extensively used free and open-source CMS.&hellip;<\/p>","protected":false},"author":1,"featured_media":6343,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[149,100,177],"class_list":["post-6304","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-nginx","tag-ubuntu-20-04","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6304"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6304\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/6343"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}