{"id":1755,"date":"2019-09-15T22:53:26","date_gmt":"2019-09-15T14:53:26","guid":{"rendered":"https:\/\/www.techcoil.com\/blog\/?p=1755"},"modified":"2020-09-10T00:26:56","modified_gmt":"2020-09-09T16:26:56","slug":"how-to-host-a-wordpress-website-on-a-raspberry-pi-with-raspbian-buster-lite-and-nginx","status":"publish","type":"post","link":"https:\/\/www.techcoil.com\/blog\/how-to-host-a-wordpress-website-on-a-raspberry-pi-with-raspbian-buster-lite-and-nginx\/","title":{"rendered":"How to host a WordPress website on a Raspberry Pi with Raspbian Buster Lite and Nginx"},"content":{"rendered":"<p>If you are thinking of <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-start-a-blog-about-computer-technology\/\" rel=\"noopener\" target=\"_blank\">starting a blog about computer technology<\/a>, then you can consider hosting a <a href=\"https:\/\/wordpress.org\/\" rel=\"noopener\" target=\"_blank\">WordPress<\/a> website on your Raspberry Pi.<\/p>\n<p>Since Raspberry Pi is a capable machine that does not take up too much space and power, it is a good as a web server. <\/p>\n<p>In addition, if you have an Internet subscription that does not block port 80 and 443, hosting a WordPress at home can be cost effective. <\/p>\n<p>Given these points, let's look at how we can host a WordPress website on a Raspberry Pi with Raspbian Buster and Nginx.<\/p>\n<h2>Why host your WordPress website on a Raspberry Pi?<\/h2>\n<p>In case you are looking for a reason to host you WordPress site on a Raspberry Pi, here are some reasons for you:<\/p>\n<ul>\n<li>You are not sure whether you will enjoy blogging. Since you can <a href=\"https:\/\/www.techcoil.com\/raspberry-pi-server-project-ideas\/\" rel=\"noopener\" target=\"_blank\">use Raspberry Pi for various server projects<\/a>, you can easily scrape your WordPress website if you do not enjoy blogging anymore.<\/li>\n<li>You are make a living from the WordPress ecosystem. In such a situation, your Raspberry Pi can serve as a good development server for you to test the plugins and themes that you had created.<\/li>\n<li>You are trying to learn about WordPress. In addition to the coding aspects of WordPress, hosting a WordPress website on a Raspberry Pi will also provide you with insights to administer WordPress on a Linux server.<\/li>\n<\/ul>\n<h2>Which Raspberry Pi to use for hosting your WordPress website?<\/h2>\n<p>Although WordPress can be hosted on most of Raspberry Pi versions, a Raspberry Pi 2 or later models will be better suited for a Raspberry Pi. In addition, you may want to look for a version with an Ethernet port.<\/p>\n<p>If you do not have a Raspberry Pi that you can use for your WordPress site, then you may want to consider getting the following items:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/CanaKit-Raspberry-4GB-Basic-Kit\/dp\/B07TXKY4Z9\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=ee0bc12c3f4cdcf9d11b2736e813db35&language=en_US\" rel=\"noopener\" target=\"_blank\">CanaKit Raspberry Pi 4 Basic Kit 4GB<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/SanDisk-128GB-Extreme-microSD-Adapter\/dp\/B07FCMKK5X\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=449c21149acf87d69f38abf28778dd6f&language=en_US\" rel=\"noopener\" target=\"_blank\">SanDisk 128GB Extreme microSDXC UHS-I Memory Card with Adapter<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/dp\/B07WV9H1V4\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=2ba999d51cce65ad705ad8f2347cb079&language=en_US\" rel=\"noopener\" target=\"_blank\">ZkeeShop Magnetic Installation Acrylic Case for Raspberry Pi 4 Model B<\/a><\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Ethernet-VANDESAIL-Gigabit-Network-Plated\/dp\/B013W0ARNY\/ref=as_li_ss_tl?ie=UTF8&linkCode=ll1&tag=clivsperswebs-20&linkId=2144de5a3a7469fc8587b1162b13a280&language=en_US\" rel=\"noopener\" target=\"_blank\">Gigabit Ethernet Cable<\/a><\/li>\n<\/ul>\n<p>In addition to the list of recommended hardware, you will need a computer with an <a href=\"https:\/\/www.amazon.com\/s\/ref=as_li_ss_tl?k=SD+card+writer&ref=nb_sb_noss&linkCode=ll2&tag=clivsperswebs-20&linkId=b9cd84bafd28eae586a6dded418d3b10&language=en_US\" rel=\"noopener\" target=\"_blank\">SD card writer<\/a>.<\/p>\n<p>In order to keep things simple, let's assume that your Raspberry Pi will connect to a router via an Ethernet cable. Given that, your Raspberry Pi can access the Internet through your router. In addition to that, your router provides the Raspberry Pi with a private IP address and you are configuring it from a computer in the same network.<\/p>\n<h2>Technology stack for hosting the WordPress website on Raspberry Pi<\/h2>\n<p>Since <a href=\"http:\/\/nginx.org\/\" rel=\"noopener\" target=\"_blank\">Nginx<\/a> is a good <a href=\"https:\/\/www.techcoil.com\/blog\/the-reverse-proxy-server\/\" rel=\"noopener\" target=\"_blank\">reverse proxy server<\/a> for hosting websites, we will cover hosting the WordPress website on a Raspberry Pi <a href=\"https:\/\/www.techcoil.com\/glossary\/lemp\/\" rel=\"noopener\" target=\"_blank\">LEMP<\/a> stack:<\/p>\n<ul>\n<li><strong>L<\/strong>: <a href=\"https:\/\/www.raspbian.org\/\" rel=\"noopener\" target=\"_blank\">Raspbian<\/a> Buster Lite<\/li>\n<li><strong>E<\/strong>: <a href=\"http:\/\/nginx.org\/\" rel=\"noopener\" target=\"_blank\">Nginx<\/a> (because Nginx sounds like \"Engine\")<\/li>\n<li><strong>M<\/strong>: <a href=\"https:\/\/mariadb.org\/\" rel=\"noopener\" target=\"_blank\">MariaDB<\/a><\/li>\n<li><strong>P<\/strong>: <a href=\"https:\/\/www.php.net\/\" rel=\"noopener\" target=\"_blank\">PHP<\/a><\/li>\n<\/ul>\n<h2>Setting up Raspbian Buster Lite on your Raspberry Pi<\/h2>\n<p>First, <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-setup-raspbian-buster-lite-for-raspberry-pi-server-projects\/\" rel=\"noopener\" target=\"_blank\">setup Raspbian Buster Lite for Raspberry Pi server projects<\/a>. After you had completed that tutorial, you will have a Raspberry Pi that you can administer from your computer via SSH.<\/p>\n<p>For the rest of this tutorial, let's assume that your Raspberry Pi is accessible via <strong>192.168.1.114<\/strong>. In addition to that, you are connected to your Pi via SSH. If not, then you will need to open up a terminal program and run the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nssh pi@192.168.1.114\r\n<\/pre>\n<h2>Installing Nginx on Raspbian Buster Lite<\/h2>\n<p>After you had logged into your Raspberry Pi with SSH, run the following commands to install Nginx on Raspbian Buster Lite:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get update\r\nsudo apt install nginx -y\r\n<\/pre>\n<p>Once the commands complete, run the following command to verify that Nginx is installed successfully on your Raspberry Pi:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl status nginx.service\r\n<\/pre>\n<p>When Nginx is installed successfully, you should see output similar to the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\u25cf nginx.service - A high performance web server and a reverse proxy server\r\n   Loaded: loaded (\/lib\/systemd\/system\/nginx.service; enabled; vendor preset: enabled)\r\n   Active: active (running) since Sun 2019-09-15 13:04:28 +08; 3min 23s ago\r\n     Docs: man:nginx(8)\r\n Main PID: 2962 (nginx)\r\n    Tasks: 5 (limit: 4915)\r\n   Memory: 7.6M\r\n   CGroup: \/system.slice\/nginx.service\r\n           \u251c\u25002962 nginx: master process \/usr\/sbin\/nginx -g daemon on; master_process on;\r\n           \u251c\u25002963 nginx: worker process\r\n           \u251c\u25002964 nginx: worker process\r\n           \u251c\u25002965 nginx: worker process\r\n           \u2514\u25002966 nginx: worker process\r\n\r\nSep 15 13:04:28 raspberrypi systemd&#x5B;1]: Starting A high performance web server and a reverse proxy server...\r\nSep 15 13:04:28 raspberrypi systemd&#x5B;1]: Started A high performance web server and a reverse proxy server.\r\n<\/pre>\n<p>In addition to that, you can access http:\/\/&lt;your_raspberry_pi_ip_address&gt;\/ with your browser to test out your <a href=\"https:\/\/www.techcoil.com\/blog\/understanding-the-default-nginx-virtual-host-or-server-configuration\/\" rel=\"noopener\" target=\"_blank\">Nginx default configuration<\/a>. You should see the following screen if everything is fine:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/default-welcome-page-of-Nginx-1.14.2.gif\" alt=\"default welcome page of Nginx 1.14.2\" class=\"aligncenter\" \/><\/p>\n<p>In case you are wondering, this page was returned based on the Nginx configurations from <code>\/etc\/nginx\/sites-available\/default<\/code>. In addition to that, the Nginx server had found that file through the symbolic link at <code>\/etc\/nginx\/sites-enabled\/default<\/code>.<\/p>\n<h2>Installing MariaDB server and command line client on Raspbian Buster Lite<\/h2>\n<p>Next, install the database components that is needed for hosting your WordPress website:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt install mariadb-server mariadb-client -y\r\n<\/pre>\n<p>When the command complete, you will have the database server for your WordPress website to persist data. In addition to that, you will also have the command line client for configuring the MariaDB database server. <\/p>\n<p>At this point in time, you can verify your MariaDB installation by running the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mariadb\r\n<\/pre>\n<p>When the components are installed properly, you should get a command line interface that looks like the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 47\r\nServer version: 10.3.17-MariaDB-0+deb10u1 Raspbian 10\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB &#x5B;(none)]&gt; \r\n\r\n<\/pre>\n<p>Type <strong>exit<\/strong> and then <strong>Enter<\/strong> to quit the command line client.<\/p>\n<h2>Installing PHP 7 on Raspbian Buster Lite<\/h2>\n<p>After you had gotten MariaDB up and running, install PHP 7 and the necessary libraries to host your WordPress website with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt install php php-fpm php-mysql -y\r\n<\/pre>\n<p>Once the command completes, you can check your <a href=\"https:\/\/php-fpm.org\/\" rel=\"noopener\" target=\"_blank\">PHP FPM<\/a> installation with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl status php7*\r\n<\/pre>\n<p>When PHP FPM is installed properly, you should see output similar to the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\u25cf php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager\r\n   Loaded: loaded (\/lib\/systemd\/system\/php7.3-fpm.service; enabled; vendor preset: enabled)\r\n   Active: active (running) since Sun 2019-09-15 13:33:12 +08; 3min 32s ago\r\n     Docs: man:php-fpm7.3(8)\r\n Main PID: 16080 (php-fpm7.3)\r\n   Status: &quot;Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req\/sec&quot;\r\n    Tasks: 3 (limit: 4915)\r\n   Memory: 5.0M\r\n   CGroup: \/system.slice\/php7.3-fpm.service\r\n           \u251c\u250016080 php-fpm: master process (\/etc\/php\/7.3\/fpm\/php-fpm.conf)\r\n           \u251c\u250016081 php-fpm: pool www\r\n           \u2514\u250016082 php-fpm: pool www\r\n\r\nSep 15 13:33:12 raspberrypi systemd&#x5B;1]: Starting The PHP 7.3 FastCGI Process Manager...\r\nSep 15 13:33:12 raspberrypi systemd&#x5B;1]: Started The PHP 7.3 FastCGI Process Manager.\r\n<\/pre>\n<h2>Deciding the domain name for your WordPress website<\/h2>\n<p>Once you had installed the technology stack for your WordPress website, it is time to decide a domain name for your WordPress website.<\/p>\n<p>Although it is possible to configure your WordPress website to be reachable via an IP address, a domain name makes it easier for people to remember your website.<\/p>\n<p>Furthermore, you can <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-host-multiple-websites-from-home\/\" rel=\"noopener\" target=\"_blank\">host multiple websites at home<\/a> with different domain names mapped to a single IP address.<\/p>\n<h3>Mapping a domain name to your Pi's IP address<\/h3>\n<p>If you are keeping your WordPress site to computers in your home network, you can edit the hosts file on your computer to map a name to the private IP address of your Pi.<\/p>\n<p>For example, if you use a mac, you can edit <code>\/etc\/hosts<\/code> and add an entry that looks like the following:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n192.168.1.114 yourwpdomainname.com \r\n<\/pre>\n<p>After saving the file, your browser will know that it should use <strong>192.168.1.114<\/strong> to access <strong>yourwpdomainname.com<\/strong>.<\/p>\n<h3>Buying a domain name for your Raspberry Pi WordPress website<\/h3>\n<p>Another approach will be to buy a domain name from a registrar like <a href=\"https:\/\/namecheap.pxf.io\/3LXmX\" rel=\"noopener\" target=\"_blank\">Namecheap<\/a>. <\/p>\n<p>Since it provides Dynamic DNS service, <a href=\"https:\/\/www.techcoil.com\/blog\/why-namecheap-is-the-best-domain-name-registrar-for-hosting-your-web-server-at-home\/\" rel=\"noopener\" target=\"_blank\">Namecheap is the best domain name registrar for hosting your web server at home<\/a>.<\/p>\n<p>If your public IP address changes often, you can <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-get-your-raspberry-pi-3-to-use-namecheap-dynamic-dns-to-update-your-domain-when-your-homes-public-ip-address-changes\/\" rel=\"noopener\" target=\"_blank\">get your Raspberry Pi to update your domain with Namecheap dynamic DNS<\/a>.<\/p>\n<p>For the sake of this tutorial, we will use <strong>yourwpdomainname.com<\/strong> as the domain name to configure our WordPress website.<\/p>\n<p>To adapt the configurations for your own domain name, simply replace occurrences of <strong>yourwpdomainname.com<\/strong> with your own domain name.<\/p>\n<h2>Forwarding port 80 and 443 of your router's public IP address to your Pi's private IP address<\/h2>\n<p>If you take the approach of buying a domain name from a registrar, you will need to forward port 80 and 443 of your router's public IP address to your Pi's private IP address.<\/p>\n<p>Most routers should have such a feature. For example if you use a Linksys router, you should be able to <a href=\"https:\/\/www.techcoil.com\/blog\/host-web-server-behind-linksys-ea7500-max-stream-ac1900-router\/\" rel=\"noopener\" target=\"_blank\">forward network traffic made to port 80 and 443 to the web server<\/a> running on your Raspberry Pi.<\/p>\n<h2>Downloading a copy of WordPress onto your Raspberry Pi<\/h2>\n<p>Once you have the domain name for your WordPress site, download a copy of WordPress onto your Raspberry Pi:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd \/var\/www\r\nsudo wget https:\/\/wordpress.org\/latest.tar.gz\r\nsudo tar xvfz latest.tar.gz\r\nsudo rm latest.tar.gz\r\nsudo mv wordpress yourwpdomainname.com\r\n<\/pre>\n<p>After the above commands complete, you will find the WordPress codes inside <code>\/var\/www\/yourwpdomainname.com<\/code>. <\/p>\n<p>When HTTP requests are sent to your WordPress site, Nginx and PHP FPM will look into this directory to serve content for your WordPress website.<\/p>\n<h2>Giving ownership of <code>yourwpdomainname.com<\/code> directory to the www-data user<\/h2>\n<p>Since Nginx and PHP FPM are ran with the <code>www-data<\/code> user, you will need to give that user ownership of the  <code>\/var\/www\/yourwpdomainname.com<\/code> directory. This will allow media uploads to your WordPress site.<\/p>\n<p>Given these points, change the ownership of <code>\/var\/www\/yourwpdomainname.com<\/code> directory with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo chown -R www-data:www-data \/var\/www\/yourwpdomainname.com\r\n<\/pre>\n<h2>Creating a MariaDB user and a database instance for your WordPress site<\/h2>\n<p>Next, setup the MariaDB database instance for your WordPress site to interact with. Since it is a good practice to create a separate database user for the WordPress site to interact with the database, let's create a Maria DB user with the privileges to interact with a particular database instance.<\/p>\n<p>In order to do so, get into the MariaDB prompt to interact with the MariaDB server:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mariadb\r\n<\/pre>\n<p>Once the MariaDB prompt appears, run the following command to create a new database instance:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nCREATE DATABASE newWordPressDb;\r\n<\/pre>\n<p>When the database instance is created successfully, create the MariaDB user with the relevant privileges for accessing that database instance:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nCREATE USER 'anewuser'@'localhost' IDENTIFIED BY 'password';\r\nGRANT ALL ON newWordPressDb.* TO 'anewuser'@'localhost';\r\n<\/pre>\n<h2>Configuring Nginx to serve content for your WordPress website<\/h2>\n<p>First define an upstream server that points to your PHP FPM. To do so, use <code>nano<\/code> to open up <code>\/etc\/nginx\/nginx.conf<\/code>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/nginx.conf\r\n<\/pre>\n<p>Once nano loads up <code>\/etc\/nginx\/nginx.conf<\/code>, copy the following content into the <a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_core_module.html#http\" rel=\"noopener\" target=\"_blank\">http block<\/a> before the line <strong>include \/etc\/nginx\/conf.d\/*.conf;<\/strong>:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nupstream local_php {     \r\n    server unix:\/run\/php\/php7.3-fpm.sock;   \r\n}\r\n<\/pre>\n<p>In addition to that, if your domain name is as long as this example, change:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# server_names_hash_bucket_size 64;\r\n<\/pre>\n<p>to:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver_names_hash_bucket_size 64;\r\n<\/pre>\n<p>Once you had done so, press <strong>Ctrl-X<\/strong>, <strong>Y<\/strong> and <strong>Enter<\/strong> to save the changes. This set of configuration will allow us to refer to the PHP FPM instance from future Nginx virtual host configurations.<\/p>\n<p>Next, configure Nginx to serve content for your WordPress site. <\/p>\n<p>First use <code>nano<\/code> to create a Nginx configuration file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/sites-enabled\/yourwpdomainname.com.conf\r\n<\/pre>\n<p>Once <code>nano<\/code> starts, fill in the following content:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n        listen   80;\r\n        ## Your website name goes here.\r\n        server_name yourwpdomainname.com  www.yourwpdomainname.com;\r\n        root \/var\/www\/yourwpdomainname.com;\r\n        ## This should be in your http block and if it is, it's not needed here.\r\n        index index.php;\r\n \r\n        location = \/favicon.ico {\r\n                log_not_found off;\r\n                access_log off;\r\n        }\r\n \r\n        location = \/robots.txt {\r\n                allow all;\r\n                log_not_found off;\r\n                access_log off;\r\n        }\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 fastcgi.conf;\r\n                fastcgi_intercept_errors on;\r\n                fastcgi_pass local_php;\r\n                fastcgi_buffers 16 16k;\r\n                fastcgi_buffer_size 32k;\r\n        }\r\n \r\n        location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {\r\n                expires max;\r\n                log_not_found off;\r\n        }\r\n}\r\n<\/pre>\n<p>Once you had done so, press <strong>Ctrl-X<\/strong>, <strong>Y<\/strong> and <strong>Enter<\/strong> to save the changes. <\/p>\n<p>In addition to that, restart your Nginx server to take the new configurations:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<h2>Creating the WordPress configurations to use the database instance<\/h2>\n<p>Next, create the WordPress configurations for your website.<\/p>\n<p>To do so, rename <code>\/var\/www\/yourwpdomainname.com\/wp-config-sample.php<\/code> to <code>\/var\/www\/yourwpdomainname.com\/wp-config.php<\/code>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mv \/var\/www\/yourwpdomainname.com\/wp-config-sample.php \/var\/www\/yourwpdomainname.com\/wp-config.php\r\n<\/pre>\n<p>Next, use your browser to access <a href=\"https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/\" rel=\"noopener\" target=\"_blank\">https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/<\/a> to generate some key and salt values for your WordPress configurations.<\/p>\n<p>Once you have done so, open <code>\/var\/www\/yourwpdomainname.com\/wp-config.php<\/code> with nano:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/var\/www\/yourwpdomainname.com\/wp-config.php\r\n<\/pre>\n<p>and update some sections of the file to look like the following:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/\/ ** MySQL settings - You can get this info from your web host ** \/\/\r\n\/** The name of the database for WordPress *\/\r\ndefine('DB_NAME', 'newWordPressDb');\r\n \r\n\/** MySQL database username *\/\r\ndefine('DB_USER', 'anewuser');\r\n \r\n\/** MySQL database password *\/\r\ndefine('DB_PASSWORD', 'password');\r\n \r\n\/** MySQL hostname *\/\r\ndefine('DB_HOST', 'localhost');\r\n \r\n\/** Database Charset to use in creating database tables. *\/\r\ndefine('DB_CHARSET', 'utf8');\r\n \r\n\/** The Database Collate type. Don't change this if in doubt. *\/\r\ndefine('DB_COLLATE', '');\r\n \r\n\/**#@+\r\n * Authentication Unique Keys and Salts.\r\n *\r\n * Change these to different unique phrases!\r\n * You can generate these using the {@link https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/ WordPress.org secret-key service}\r\n * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.\r\n *\r\n * @since 2.6.0\r\n *\/\r\ndefine('AUTH_KEY',         '+cSfNRx\/GGIC.w*S!Bm-tHSZ;XG{&amp;KL$Ciah!&amp;U!XpM1_) c{q1+Z5nZ&amp;:n$3|EA');\r\ndefine('SECURE_AUTH_KEY',  'b&amp;YwiG*4|u-GPq ],XfvrK.m&gt;@G]77S_50J3TF@XpsrG.!b}sPjYQliq; EYaHO+');\r\ndefine('LOGGED_IN_KEY',    '!:Z`K-+mxdD{]KuXOxEV _KoPY&#x5B;e r2|0|p|kT-S;Fp4aKat&gt;(k6;{tNM8+&lt;93HU');\r\ndefine('NONCE_KEY',        'Ws9-:a=77-CYQiu-4&amp;5S:&#x5B;&amp;sDo++d(TCm=us|D,Y!ZsG*Q+F\/Q|6QP(dx{{Kz{|3');\r\ndefine('AUTH_SALT',        'AG+J* 6n2%$`,Lsw&lt;2`G&#x5B;;aK-&gt;K_=@C&lt;#gn|@z9t+?|{y-`7F~otjp`0{$&#x5B;d.&amp;C6');\r\ndefine('SECURE_AUTH_SALT', 'S{^tpy:o#sN)+vq#93jv&lt;WD_FX6&#x5B;T 6g*=tAvP+KBj!Wm})v&lt;0)g(?BkUB#vH1YD');\r\ndefine('LOGGED_IN_SALT',   'J~~FNzfG&gt;1B(Xo=B1j4H&lt;eN9bjEg9sZkKCSSB.+~;|,J!MYKDXw4`aHKwI_Uw-N&lt;');\r\ndefine('NONCE_SALT',       '&#x5B;Qj-Qz:5G-RIX*vm&#x5B;?B0Wuej^w|qy !)AOkrC3gHI_tR1B%]$o8\/SsG-;r:CfE@)');\r\n\/**#@-*\/\r\n<\/pre>\n<p>You should also consider changing <code>$table_prefix<\/code> to another value:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n$table_prefix = 'abc123_';\r\n<\/pre>\n<p>When you are done with the changes, press <strong>Ctrl-X<\/strong>, <strong>Y<\/strong> and <strong>Enter<\/strong> to save the file.<\/p>\n<h2>Running the WordPress installation script<\/h2>\n<p>At this point in time, your Raspberry Pi should be able to serve content for your WordPress site.<\/p>\n<p>Therefore, you can proceed with running the WordPress installation script.<\/p>\n<p>In order to trigger the installation script, access <strong>yourwpdomainname.com<\/strong> (or your domain name) with your browser:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/First-access-of-WordPress-5.2.3-installation-page-with-Incognito-Chrome.gif\" alt=\"First access of WordPress 5.2.3 installation page with Incognito Chrome\" class=\"aligncenter\" \/><\/p>\n<p>Fill in the necessary details: <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/WordPress-5.2.3-installation-page-with-some-sample-values.gif\" alt=\"WordPress 5.2.3 installation page with some sample values\" class=\"aligncenter\" \/><\/p>\n<p>and click on <strong>Install WordPress<\/strong>:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Successfully-ran-installation-script-for-WordPress-5.2.3.gif\" alt=\"Successfully ran installation script for WordPress 5.2.3\" class=\"aligncenter\" \/><\/p>\n<p>At this point in time, you should be able to see a default post with a default comment when you access the home page of your WordPress site:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/WordPress-default-home-page-running-Twenty-Nineteen-default-theme.gif\" alt=\"WordPress default home page running Twenty Nineteen default theme\" class=\"aligncenter\" \/><\/p>\n<p>If you are keeping your WordPress website within your own home network, you are done with setting up your WordPress website on your Raspberry Pi. <\/p>\n<p>However, if you are serving your WordPress website on the Internet, you will want to configure Nginx to serve your site with HTTPS.<\/p>\n<h2>Let's Encrypt your Raspberry Pi WordPress site with a browser-trusted SSL\/TLS certificate<\/h2>\n<p>With <a href=\"https:\/\/letsencrypt.org\/\" rel=\"noopener\" target=\"_blank\">Let's Encrypt<\/a>, you can serve your Raspberry Pi WordPress site over HTTPS with a free browser-trusted SSL\/TLS certificate.<\/p>\n<p>Since <a href=\"https:\/\/support.google.com\/webmasters\/answer\/6073543?hl=en\" rel=\"noopener\" target=\"_blank\">Google encourages securing website with HTTPS for better user experience<\/a> and Let's Encrypt gives us free browser-trusted SSL\/TLS certificates, let's proceed with securing your Raspberry Pi WordPress website.<\/p>\n<h3>Installing Certbot on Raspbian Buster Lite for obtaining Let\u2019s Encrypt\u2019s browser-trusted certificates<\/h3>\n<p>In order to use Let's Encrypt facilities, we will need a <a href=\"https:\/\/letsencrypt.org\/docs\/client-options\/\" rel=\"noopener\" target=\"_blank\">ACME client<\/a> to help us get the SSL artefacts from Let's Encrypt. Therefore, <a href=\"https:\/\/www.techcoil.com\/blog\/installing-certbot-on-raspbian-buster-for-obtaining-lets-encrypts-browser-trusted-certificates-for-your-raspberry-pi-server-applications\/\" rel=\"noopener\" target=\"_blank\">install Certbot on Raspbian Buster Lite for obtaining Let\u2019s Encrypt\u2019s browser-trusted certificates<\/a>.<\/p>\n<h3>Configuring Nginx to facilitate Certbot in acquiring the SSL certificate for your domain<\/h3>\n<p>Once you have installed Certbot on Raspbian Buster Lite, configure Nginx to facilitate Certbot in acquiring the SSL certificate for your domain.<\/p>\n<p>Given that, open up <code>yourwpdomainname.com.conf<\/code> again:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo nano \/etc\/nginx\/sites-enabled\/yourwpdomainname.com.conf\r\n<\/pre>\n<p>Once nano loads up your configuration file, add in the following location block:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlocation ~ \/.well-known {\r\n        allow all;\r\n} \r\n<\/pre>\n<p>inside the server block. After you do so, your configuration file should look like this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nserver {\r\n        listen   80;\r\n        ## Your website name goes here.\r\n        server_name yourwpdomainname.com  www.yourwpdomainname.com;\r\n        root \/var\/www\/yourwpdomainname.com;\r\n        ## This should be in your http block and if it is, it's not needed here.\r\n        index index.php;\r\n  \r\n        location = \/favicon.ico {\r\n                log_not_found off;\r\n                access_log off;\r\n        }\r\n  \r\n        location = \/robots.txt {\r\n                allow all;\r\n                log_not_found off;\r\n                access_log off;\r\n        }\r\n\r\n        location ~ \/.well-known {\r\n                allow all;\r\n        }   \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 fastcgi.conf;\r\n                fastcgi_intercept_errors on;\r\n                fastcgi_pass local_php;\r\n                fastcgi_buffers 16 16k;\r\n                fastcgi_buffer_size 32k;\r\n        }\r\n  \r\n        location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {\r\n                expires max;\r\n                log_not_found off;\r\n        }\r\n}\r\n<\/pre>\n<p>Once you are done with the changes, press <strong>Ctrl-X<\/strong>, <strong>Y<\/strong> and <strong>Enter<\/strong> to save the changes. This set of changes allow Nginx to respond to HTTP requests made by Let's Encrypt servers to confirm that your Certbot is running on the server that serves content for your domain. <\/p>\n<p>Restart your Nginx server so that it takes the new configuration changes:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<h3>Using Certbot to get Let's Encrypt to issue browser-trusted SSL certificate for your domain<\/h3>\n<p>After Nginx is ready to facilitate Certbot in acquiring the SSL certificate artefacts, run the following command to acquire them:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo certbot certonly -a webroot --webroot-path=\/var\/www\/yourwpdomainname.com -d yourwpdomainname.com -d www.yourwpdomainname.com\r\n<\/pre>\n<h3>Generating a strong Diffie-Hellman group for your website<\/h3>\n<p>Once Certbot had fetched the SSL certificate artefacts for your domain, generate a Diffie-Hellman group for Nginx to use for exchanging cryptographic keys with its clients:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo openssl dhparam -out \/etc\/ssl\/certs\/dhparam.pem 2048\r\n<\/pre>\n<h3>Updating the Nginx configurations for serving HTTPS for your Raspberry Pi WordPress site<\/h3>\n<p>At this point in time, you will have the necessary artefacts for Nginx to serve your site over HTTPS. Therefore, update the Nginx configurations to use those artefacts for serving your WordPress site over HTTPS.<\/p>\n<p>Given that, open up <code>yourwpdomainname.com.conf<\/code> again:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nserver {\r\n    listen 80;\r\n    server_name  yourwpdomainname.com www.yourwpdomainname.com;\r\n    return 301 https:\/\/$host$request_uri;\r\n}\r\n\r\nserver {\r\n        ssl on;\r\n        ssl_certificate \/etc\/letsencrypt\/live\/yourwpdomainname.com\/fullchain.pem;\r\n        ssl_certificate_key \/etc\/letsencrypt\/live\/yourwpdomainname.com\/privkey.pem;\r\n        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\r\n        ssl_prefer_server_ciphers on;\r\n        ssl_dhparam \/etc\/ssl\/certs\/dhparam.pem;\r\n        ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';\r\n        ssl_session_timeout 1d;\r\n        ssl_session_cache shared:SSL:50m;\r\n        ssl_stapling on;\r\n        ssl_stapling_verify on;\r\n        add_header Strict-Transport-Security max-age=15768000;\r\n\r\n        listen   443;\r\n        \r\n        server_name yourwpdomainname.com  www.yourwpdomainname.com;\r\n        root \/var\/www\/yourwpdomainname.com;\r\n        ## This should be in your http block and if it is, it's not needed here.\r\n        index index.php;\r\n\r\n        location ~ \/.well-known {\r\n                allow all;\r\n        }\r\n  \r\n        location = \/favicon.ico {\r\n                log_not_found off;\r\n                access_log off;\r\n        }\r\n  \r\n        location = \/robots.txt {\r\n                allow all;\r\n                log_not_found off;\r\n                access_log off;\r\n        }\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 fastcgi.conf;\r\n                fastcgi_intercept_errors on;\r\n                fastcgi_pass local_php;\r\n                fastcgi_buffers 16 16k;\r\n                fastcgi_buffer_size 32k;\r\n        }\r\n  \r\n        location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ {\r\n                expires max;\r\n                log_not_found off;\r\n        }\r\n}\r\n<\/pre>\n<p>Once you had done so, press <strong>Ctrl-X<\/strong>, <strong>Y<\/strong> and <strong>Enter<\/strong> to save the changes.<\/p>\n<p>Restart your Nginx server to take the new configurations:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo systemctl restart nginx.service\r\n<\/pre>\n<p>When you visit your WordPress website again, you will notice the lock icon in the address bar:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/WordPress-default-home-page-running-Twenty-Nineteen-default-theme-with-lock-icon.gif\" alt=\"WordPress default home page running Twenty Nineteen default theme with lock icon\" class=\"aligncenter\" \/><\/p>\n<p>This meant that your WordPress website is served over HTTPS with a browser-trusted certificate.<\/p>\n<h2>Increasing file upload limit<\/h2>\n<p>Since the default file upload size limit is slightly less than 1 Megabyte for Nginx and 2 Megabytes for PHP FPM 7, you can only upload slightly less than 1 Megabyte of content to my Raspberry Pi WordPress site.<\/p>\n<p>When you wish to tweak the file upload limit, look at <a href=\"https:\/\/www.techcoil.com\/blog\/configuring-nginx-and-php-7-stack-in-linux-to-increase-or-decrease-file-upload-size-limit\/\" rel=\"noopener\" target=\"_blank\">how to configure Nginx and PHP 7 stack in Linux to increase or decrease file upload size limit<\/a>.<\/p>\n<h2>You are now able to host a WordPress website on your Raspberry Pi with HTTPS<\/h2>\n<p>Congratulations for reaching till the end of the post. It have been quite a ride for you.<\/p>\n<p>At this point in time, as long as you do not switch off your Internet and your Pi, your WordPress website will be accessible from the Internet.<\/p>\n<p>If you find this guide useful, feel free to share it with others.<\/p>\n<p>Wishing you all the best with your WordPress website!<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/How-to-host-WordPress-website-on-Raspberry-Pi-with-Raspbian-Buster-Lite-and-Nginx.jpg\" alt=\"How to host WordPress website on Raspberry Pi with Raspbian Buster Lite and Nginx\" class=\"aligncenter\" \/><\/p>\n\n      <ul id=\"social-sharing-buttons-list\">\n        <li class=\"facebook\">\n          <a href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwp.me%2Fp245TQ-sj\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n            <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Facebook.png\" alt=\"Facebook icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"twitter\">\n          <a href=\"https:\/\/twitter.com\/intent\/tweet?text=&url=https%3A%2F%2Fwp.me%2Fp245TQ-sj&via=Techcoil_com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Twitter.png\" alt=\"Twitter icon\"> Tweet\n          <\/a>\n        <\/li>\n        <li class=\"linkedin\">\n          <a href=\"https:\/\/www.linkedin.com\/shareArticle?mini=1&title=&url=https%3A%2F%2Fwp.me%2Fp245TQ-sj&source=https:\/\/www.techcoil.com\" target=\"_blank\" role=\"button\" rel=\"nofollow\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/linkedin.png\" alt=\"Linkedin icon\"> Share\n          <\/a>\n        <\/li>\n        <li class=\"pinterest\">\n          <a href=\"https:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.techcoil.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F1755&description=\" class=\"pin-it-button\" target=\"_blank\" role=\"button\" rel=\"nofollow\" count-layout=\"horizontal\">\n          <img decoding=\"async\" src=\"\/ph\/img\/3rd-party\/social-icons\/Pinterest.png\" alt=\"Pinterest icon\"> Save\n          <\/a>\n        <\/li>\n      <\/ul>\n    ","protected":false},"excerpt":{"rendered":"<p>If you are thinking of <a href=\"https:\/\/www.techcoil.com\/blog\/how-to-start-a-blog-about-computer-technology\/\" rel=\"noopener\" target=\"_blank\">starting a blog about computer technology<\/a>, then you can consider hosting a <a href=\"https:\/\/wordpress.org\/\" rel=\"noopener\" target=\"_blank\">WordPress<\/a> website on your Raspberry Pi.<\/p>\n<p>Since Raspberry Pi is a capable machine that does not take up too much space and power, it is a good as a web server. <\/p>\n<p>In addition, if you have an Internet subscription that does not block port 80 and 443, hosting a WordPress at home can be cost effective. <\/p>\n<p>Given these points, let&#8217;s look at how we can host a WordPress website on a Raspberry Pi with Raspbian Buster and Nginx.<\/p>\n","protected":false},"author":1,"featured_media":1759,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[446,225,13,444,243,240,412,677,678,423,438,5],"jetpack_featured_media_url":"https:\/\/www.techcoil.com\/blog\/wp-content\/uploads\/Successfully-ran-installation-script-for-WordPress-5.2.3.gif","jetpack_shortlink":"https:\/\/wp.me\/p245TQ-sj","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/1755"}],"collection":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/comments?post=1755"}],"version-history":[{"count":0,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/posts\/1755\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media\/1759"}],"wp:attachment":[{"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/media?parent=1755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/categories?post=1755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcoil.com\/blog\/wp-json\/wp\/v2\/tags?post=1755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}