{"id":169702,"date":"2021-02-03T17:00:26","date_gmt":"2021-02-03T14:00:26","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/"},"modified":"2021-02-03T17:00:26","modified_gmt":"2021-02-03T14:00:26","slug":"how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/","title":{"rendered":"#How To Set Up A WordPress Site On Your Own Servers (With Ubuntu &#038; NGINX) \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a3a0e56dfc5e\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a3a0e56dfc5e\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/#Installing_Dependencies\" >Installing Dependencies<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/#Installing_WordPress\" >Installing WordPress<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/#Configuring_NGINX\" >Configuring NGINX<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx-cloudsavvy-it\/#Setting_Up_Your_Site\" >Setting Up Your Site<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How To Set Up A WordPress Site On Your Own Servers (With Ubuntu &amp; NGINX) \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure style=\"width: 1000px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4044 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/bcc25d63f6d868090b4f6b7e1d1b3b67\/p\/uploads\/2017\/08\/94f2fdd6-e1583348245450.png\" alt=\"WordPress Logo Dark Mode\" width=\"1000\" height=\"465\" data-crediturl=\"https:\/\/wordpress.org\/about\/logos\/\" data-credittext=\"WordPress\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/wordpress.org\/about\/logos\/\">WordPress<\/a><\/span><\/figcaption><\/figure>\n<p>While you can always pay someone else a monthly fee to manage your WordPress instance, self hosting makes a lot of sense for many people who have existing hardware to take advantage of, or just want a fun project setting up their blog. We\u2019ll show how to set up and configure a basic WordPress site on Ubuntu Linux using NGINX.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_Dependencies\"><\/span>Installing Dependencies<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>First, we\u2019ll need to install NGINX. Update <code>apt<\/code>\u00a0and install it:<\/p>\n<pre>sudo apt update&#13;\nsudo apt install nginx<\/pre>\n<p>If you have a firewall enabled, like UFW, you\u2019ll need to open it up:<\/p>\n<pre>sudo ufw allow 'Nginx HTTP'<\/pre>\n<p>We\u2019ll configure NGINX once WordPress is installed. In the meantime, we\u2019ll need to create a MySQL database for WordPress to use.<\/p>\n<p>If you don\u2019t have MySQL installed, you can get it from <code>apt<\/code>. Make sure to run <code>mysql_secure_installation<\/code>\u00a0once it\u2019s installed to lock it down. You can read our guide on <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a> database security for more info, but as long as MySQL is running on <code>localhost<\/code>, you should be fine.<\/p>\n<pre>sudo apt install mysql-server&#13;\nsudo mysql_secure_installation<\/pre>\n<p>Create a database for WordPress to use. You don\u2019t need to set up tables or anything, just a blank database will do:<\/p>\n<pre>CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;<\/pre>\n<p>Then create a user, called <code>wordpressuser<\/code>, and give it access to the database. <strong>Make sure to change the password<\/strong>.<\/p>\n<pre>CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';&#13;\nGRANT ALL PRIVILEGES ON * . * TO 'wordpressuser'@'localhost';&#13;\nFLUSH PRIVILEGES;<\/pre>\n<p>WordPress runs on PHP, so it\u2019ll need PHP installed to function. Install it alongside the following extensions:<\/p>\n<pre>sudo apt install php-fpm php-mysql&#13;\nsudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip<\/pre>\n<p>And restart the PHP service to make sure it\u2019s up to date with the new extensions. Note that you may need to change the version number here.<\/p>\n<pre>sudo systemctl restart php7.4-fpm.service<\/pre>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_WordPress\"><\/span>Installing WordPress<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">Download<\/a> the latest build of WordPress from their site:<\/p>\n<pre>cd \/tmp&#13;\ncurl -LO https:\/\/wordpress.org\/latest.tar.gz&#13;\ntar xzvf latest.tar.gz<\/pre>\n<p>Then copy the sample configuration to the location WordPress actually reads from:<\/p>\n<pre>cp \/tmp\/wordpress\/wp-config-sample.php \/tmp\/wordpress\/wp-config.php<\/pre>\n<p>Move the temp directory to the proper install location, and <code>chown<\/code>\u00a0the data:<\/p>\n<pre>sudo cp -a \/tmp\/wordpress\/. \/var\/www\/wordpress&#13;\nsudo chown -R www-data:www-data \/var\/www\/wordpress<\/pre>\n<p>You\u2019ll need to set the salts that are used for security and password management. You can fetch a new set of salts from WordPress\u2019s API:<\/p>\n<pre>curl -s https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/<\/pre>\n<p>Then, open up WordPress\u2019s config file, and paste the values in:<\/p>\n<pre>sudo nano \/var\/www\/wordpress\/wp-config.php<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9249\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/131a46391553edf73f115b3ee867b74d\/p\/uploads\/2021\/01\/2a99a469.png\" alt=\"\" width=\"564\" height=\"253\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>While you\u2019re in this file, you\u2019ll need to configure the database settings.<\/p>\n<pre>define('DB_NAME', 'wordpress');&#13;\n&#13;\n\/** MySQL database username *\/&#13;\ndefine('DB_USER', 'wordpressuser');&#13;\n&#13;\n\/** MySQL database password *\/&#13;\ndefine('DB_PASSWORD', 'password');&#13;\n&#13;\ndefine('FS_METHOD', 'direct');<\/pre>\n<p>Once that\u2019s done, WordPress should be configured, and we\u2019ll need to configure NGINX to serve the content.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Configuring_NGINX\"><\/span>Configuring NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>NGINX uses config files in <code>\/etc\/nginx\/sites-available\/<\/code>\u00a0to configure different endpoints. Create a new one for your site in this folder, and paste in the following:<\/p>\n<pre># Upstream to abstract backend connection(s) for php&#13;\nupstream php {&#13;\n        server unix:\/var\/run\/php\/php7.4-fpm.sock;&#13;\n        server 127.0.0.1:9000;&#13;\n}&#13;\n&#13;\nserver {&#13;\n        ## Your website name goes here.&#13;\n        server_name domain.tld;&#13;\n        ## Your only path reference.&#13;\n        root \/var\/www\/wordpress;&#13;\n        ## This should be in your http block and if it is, it's not needed here.&#13;\n        index index.php;&#13;\n&#13;\n        location = \/favicon.ico {&#13;\n                log_not_found off;&#13;\n                access_log off;&#13;\n        }&#13;\n&#13;\n        location = \/robots.txt {&#13;\n                allow all;&#13;\n                log_not_found off;&#13;\n                access_log off;&#13;\n        }&#13;\n&#13;\n        location \/ {&#13;\n                # This is cool because no php is touched for static content.&#13;\n                # include the \"?$args\" part so non-default permalinks doesn't break when using query string&#13;\n                try_files $uri $uri\/ \/index.php?$args;&#13;\n        }&#13;\n&#13;\n        location ~ .php$ {&#13;\n                #NOTE: You should have \"cgi.fix_pathinfo = 0;\" in php.ini&#13;\n                include fastcgi_params;&#13;\n                fastcgi_intercept_errors on;&#13;\n                fastcgi_pass php;&#13;\n                #The following parameter can be also included in fastcgi_params file&#13;\n                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;&#13;\n        }&#13;\n&#13;\n        location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {&#13;\n                expires max;&#13;\n                log_not_found off;&#13;\n        }&#13;\n}<\/pre>\n<p>Note that you will need to put in your info for the hostname and other settings, as well as updating the PHP version if you are using a newer one. You will need to save this in <code>sites-available<\/code>, then symlink it to <code>sites-enabled<\/code>\u00a0to turn it on.<\/p>\n<pre>sudo ln -s \/etc\/nginx\/sites-available\/example.com \/etc\/nginx\/sites-enabled\/<\/pre>\n<p>Once it\u2019s enabled, restart NGINX, and you\u2019ll see WordPress if you visit the site in your browser. You\u2019ll need to do the first time setup walkthrough.<\/p>\n<pre>sudo service nginx restart<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9405\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/34405ace501ff440078254f33baa1549\/p\/uploads\/2021\/02\/0b116c53-1.png\" alt=\"\" width=\"700\" height=\"702\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You\u2019ll now be able to view your dashboard at any time at <code>https:\/\/example.com\/wp-admin\/<\/code>.<\/p>\n<p>Next, you\u2019ll need to configure SSL to secure connections on your site. You can do this for free using <code>certbot<\/code>, a CLI frontend to LetsEncrypt\u2019s free certificates.<\/p>\n<pre>sudo apt-get install certbot&#13;\n&#13;\nsudo apt install python3-certbot-nginx<\/pre>\n<p>Then, run certbot:<\/p>\n<pre>sudo certbot nginx -certonly<\/pre>\n<p>After that, you will need to restart NGINX.<\/p>\n<p>sudo service nginx restart<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Setting_Up_Your_Site\"><\/span>Setting Up Your Site<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Congratulations! You have a running WordPress site. It probably looks terrible with the default theme. The first thing you\u2019ll want to do is change the theme, which you can do from the dashboard:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9402\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/54728b3e1582864a2f725f3e8da56c30\/p\/uploads\/2021\/02\/59823d5a.png\" alt=\"\" width=\"700\" height=\"391\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Whatever theme you choose, you\u2019ll need to activate it from the appearance tab.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9403\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/bbc24abb5af09aa8f34e38912dd1f0c4\/p\/uploads\/2021\/02\/a35c7dea.png\" alt=\"\" width=\"700\" height=\"297\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Then, you can configure the settings and style by visiting the site and clicking \u201cCustomize\u201d in the header. One of the best things you can do is add completely custom CSS to the site, which can change any element on the page.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9408\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/95ff8cd176e242302cc5604958efed88\/p\/uploads\/2021\/02\/aa7a7111.png\" alt=\"\" width=\"508\" height=\"531\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>If you want to edit something in the theme, and you don\u2019t mind messing around in PHP, you can edit your theme files directly. For example, I edited my theme file to layout a grid with two posts side, rather than just a list of posts.<\/p>\n<pre>cd \/var\/www\/wordpress\/wp-content\/themes\/dark-press\/&#13;\nsudo nano index.php<\/pre>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/9246\/how-to-set-up-a-wordpress-site-on-your-own-servers-with-ubuntu-nginx\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How To Set Up A WordPress Site On Your Own Servers (With Ubuntu &amp; NGINX) \u2013 CloudSavvy IT&#8221; WordPress While you can always pay someone else a monthly fee to manage your WordPress instance, self hosting makes a lot of sense for many people who have existing hardware to take advantage of, or just want&#8230;<\/p>\n","protected":false},"author":1,"featured_media":169703,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/08\/94f2fdd6-e1583348245450.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-169702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/169702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=169702"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/169702\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/169703"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=169702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=169702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=169702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}