Blog

Rock64: LAMP + WordPress + Let’s Encrypt SSL | part 1

Do you have a Rock64 or another single board (Raspberry Pi clones) getting dust in some corner of your house? Me too, I took the decision of move my tiny blog from a hosting provider to my own web server running on my Rock64 and for free, even the domain and the SSL certificate.

If you don’t know what is “Rock64” let me give you a quick answer: it is another single board computer like Raspberry PI (most popular) but with steroids.


ROCK64 is a credit card size 4K60P HDR Single Board Computer powered by Rockchip RK3328 Quad-Core ARM Cortex A53 64-Bit Processor and support up to 4GB 1600MHz LPDDR3 memory. It provides eMMC module socket, MicroSD Card slot, Pi-2 Bus, Pi-P5+ Bus, USB 3.0 and many others peripheral devices interface for makers to integrate with sensors and devices. Various Operating System (OS) are made available by open source community such Android 7.1, Debian, BSD and many more to come.

https://www.pine64.org/?page_id=7147

Background 

I bought my Rock64 months ago with the intention of make my own retro console, but at that time the OS optimization wasn’t good and I tried different distributions with almost the same result, at the end I did install Android TV on it, I used it for a few days, until I got bored of using it and left it abandoned in a corner of my house. 

A few days ago, I was trying to install an SSL certificate to my blog, but I realized that my hosting provider does not support Let’s Encrypt certificates (free SSL certificates) and those certificates are not cheap, then I saw a light on my mind! 

Everything is built on Linux with open source software and I can install those on my own computer, better on my Rock64. 

Although I did the installation in a Rock64, you can use another single board computer or a regular computer, the process is almost the same. 

Installing the OS: ARMBIAN 

I choose this OS because have full support to my Rock64 and others single boards, is based on Debian or Ubuntu. 

What is Armbian? 

Lightweight Debian or Ubuntu based distribution specialized for ARM developing boards. Compiled from scratch, 

It has powerful build and software development tools, 

A vibrant community. 

https://www.armbian.com/rock64/

The first thing to do is download the OS from the official web site. 

Direct link: 

Once downloaded the OS file, you need unzip the file to get the image “.img” file. 

You are going to need and SD card and a software to burn the “.img” into your SD, I used “Etcher” because is really easy to use (Select image, select destination drive, flash). 

Then insert the SD card to your Rock64, attach a Keyboard, monitor, Ethernet cable and you are ready to go.

The default user and password is: root\1234, you will be prompted to change this password at the first login, also you will be asked to create a normal account with sudo privileges. 

A keyboard or monitor is not required, you can connect to your board via SSH, but you will need to discover your board IP address first, the easy way is find the IP address in your router and also it is a very good idea link that IP address to your board (board mac address), on this way, your board is going to use the same IP address all the time. 

Once everything is running, it is time to install all the tools required to deploy WordPress. 

Installing Apache web server 

Once logged with your account, the first thing to do is update our server: 

apt-get update 
apt-get upgrade

The update process can take a couple of minutes, once everything is up to date, we are going to proced to install Apache with the next command: 

sudo apt-get install apache2 -y 

Installing PHP 

To install PHP in our server we need to run the next command: 

sudo apt-get install php –y 

Installing MySQL Server 

MySQL is a popular database engine, it is very used on combination of web servers and applications to store data on this database server. 

Run the next command to install MySQL: 

sudo apt-get install mysql-server php-mysql -y 

WordPress 

Create the directory structure required 

We need to create the directory structure that will hold our site. 

Before to start that process, we need to define the domain that will be used, you can go https://freenom.com/ and get a free domain, yes a free domain, usually you can select domains ending in “.tk”, “.cf”, “.ga”, “.ml” for free, even for a few dollars you can get a “.com”, “.net”, etc for a decent price. I got “devandadmin.com” for 8 dollars at year (not bad). 

Once you have your domain name ready we can process to create the folder structure, for this example I’m going to use my “devandadmin.com” domain. 

First you we are going to navigate to the folder where Apache use to host the web sites and delete all the example content. 

cd /var/www 
sudo rm –rf html 
  • This command is going to delete the folder “/var/www/html/” and all its content. 
 sudo mkdir –p /var/www/devandadmin.com/public_html  
  • This command is going to create the folder “devandadmin.com” and a subfolder called “public_html” on it. 

Obviously, you need replace “devandadmin.com” with your own domain. 

Downloading WordPress 

We need navigate to the folder created before: 

cd /var/www/devandadmin.com/public_html 

And then use the command wget to download the last version of WordPress: 

sudo wget http://wordpress.org/latest.tar.gz 

Extract the WordPress file 

sudo tar xzf latest.tar.gz

Move the content of the folder called “wordpress” to our current directory “/var/ww/devandadmin.com/public_html 

sudo mv wordpress/* . 

At the end we can now remove all the unnecessary files  

 sudo rm –rf wordpress latest.tar.gz 

Now we need to provide the ownership of these folders/files to the Apache user. 

cd /var/www
sudo chown –R www-data: . 

Creating new Virtual Host File

Virtual host files are the files that specify the actual configuration of our virtual hosts and dictate how the Apache web server will respond to various domain requests. 

sudo touch /etc/apache2/sites-available/devandadmin.com.conf 
  • This command it is going to create an empty file called “devandadmin.com.conf” on the directory specified.You need replace “devandadmin.com.conf” with your domain name. 

Open the new file in your editor with root privileges.

sudo nano /etc/apache2/sites-available/devandadmin.com.conf
  • Paste the next content on it: 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName yourdomain
    ServerAlias yourdomain
    DocumentRoot /var/www/yourdomain/public_html
    <Directory "/var/www/yourdomain/public_html">
      AllowOverride All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =yourdomain [OR]
    RewriteCond %{SERVER_NAME} =www.yourdomain
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}[END,NE,R=permanent]
</VirtualHost>

Now you just need replace all the values with your domain name, example: ServerName devandadmin.com.

Enable the New Virtual Host Files 

Now that we have created our virtual host files, we must enable them. Apache includes some tools that allow us to do this. 

We can use the a2ensite tool to enable each of our sites like this: 

sudo a2ensite devandadmin.com.conf

Disable the default config file

sudo a2dissite 000-default.conf

Enabling the Rewrite Module

Next, we can enable

1
mod_rewrite
so that we can utilize the WordPress permalink feature:

sudo a2enmod rewrite

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

This is all for this post, on the next post, I’m going to show you how to create a new database for our blog in WordPress, how to install and configure Let’s Encrypt and how to publish our blog to the world.

If you have any comments let me know!

Thank you.

2 thoughts on “Rock64: LAMP + WordPress + Let’s Encrypt SSL | part 1

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: