Blog

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

On our last post we installed Apache, PHP, MySQL, downloaded WordPress and we extracted all the files on the right path, also we configured an Apache virtual host for our site.
Today we are going to create our blog database and database user, also we need to set some extra configurations to complete our WordPress installation.

MySQL configuration

MySQL security

Before start creating a user and database for WordPress, we are going to improve the security of your MySQL installation with the command:

sudo mysql_secure_installation 

When executed, mysql_secure_installation prompts you to determine which actions to perform.  

  • You can set a password for root accounts.  
  • You can remove root accounts that are accessible from outside the local host.  
  • You can remove anonymous-user accounts.  
  • You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.

WordPress database

We need to connect to MySQL shell with the next command:

sudo mysql –u root –p 

You are going to need enter the password for the root user (defined previously). 

Create the database for WordPress by typing:

CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  • You can replace the database name with any name, but we will be using “wordpress” in this demo to keep it simple. 
  • Every MySQL statement must end in a semi-colon (;). Check to make sure this is present if you are running into any issues.

The next step will be creating a separate MySQL user account that we will use exclusively to operate our WordPress database. 

In order to keep this demo as simple as possible, my database user will be: bloguser. 

Create the user and assign the permissions required by typing:

GRANT ALL ON wordpress.* TO 'bloguser'@'localhost' IDENTIFIED BY '[email protected]'; 

You are going to need specify and strong password. 

With the previous command, we are specifying to MySQL to grant all the privileges to the “bloguser” on all the objects of the database “wordpress” when the user is connected from “localhost”.

In order to apply the changes that we made, we need to run the next command:

FLUSH PRIVILEGES;

Then type: EXIT; to close our MySQL session.

WordPress configuration

WordPress has a configuration file named “wp-config.php”, this file contains the configuration of our database and also security keys to encrypt the information stored in the user’s cookies.

Security keys

WordPress has a tool to create all the security keys for you really quickly, just run the next command to grab the secure values:

curl -s https://api.wordpress.org/secret-key/1.1/salt/
Output

We need to copy those lines into our clip board, and we are going to open our “wp-config.php” and add those lines. 

Run the next command to open the configuration file:

sudo cp /var/www/devandadmin.com/public-html/wp-config-sample.php /var/www/devandadmin.com/public-html/wp-config.php 
sudo nano /var/www/devandadmin.com/public-html/wp-config.php
  • Replace “devandmin.com” with your own domain name. 

The next step will be find the section that contains the Security Keys, remove that lines and paste the result that you got before.

Database connection settings

On the same file we need find the database configuration settings:

/** MySQL settings - You can get this info from your web host */ 
/** The name of the database for WordPress */ 
 define( 'DB_NAME', 'database_name_here' ); 
/** MySQL database username */
define( 'DB_USER', 'username_here' );
/** MySQL database password */ 
define( 'DB_PASSWORD', 'password_here' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' ); 

Change the values of each record with your own information, example: 

  • DB_NAME = wordpress 
  • DB_USER = bloguser 
  • DB_PASSWORD = [email protected] 
  • DB_HOST = localhost 

Press “CTRL + X” to close the editor, press “Y” to save the changes and then “Enter” to write the changes.

At the end your “wp-config.php” file will looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'bloguser');

/** MySQL database password */
define('DB_PASSWORD', '[email protected]');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secre$ * You can change these at any point in time to invalidate all existing cookies. This will force all users to$ *
 * @since 2.6.0
 */
define('AUTH_KEY',         'f!V:2LqTP|>IXNZ?+u`${~6I&22$wmH|[email protected][email protected])ZyGu%B+6wHf');
define('SECURE_AUTH_KEY',  'RU?n#|{0C1&!QOxE`$ZP/x*[HDr^0=gBs)[email protected]@$z6)>|[email protected]');
define('LOGGED_IN_KEY',    ')t1%}ToyWQSbl;D<XpniTnX]H9 w.;cUpH5[#D @><r43}H9-Twoe<8Tkl^Oj`UB');
define('NONCE_KEY',        ']c_WzuCIJzZ_;&|~}+Y|E0s-H0Y>cEa}fF{#|*oz[%kH+FU,>w|@mf84cfVO,8B4');
define('AUTH_SALT',        'nn+Y{]V0u#&|-i<5ZyZpS%^[email protected]*Nw=y$mGR3Kl8|-|7U67^f][email protected]`');
define('SECURE_AUTH_SALT', '%a|H`Ar-3PdL5(icUM+PyYKQzp2%5TY>)3=NgkT(1cV$(TJ9)<O[c)1En|!4dh6N');
define('LOGGED_IN_SALT',   '-Rji])tGr$mJn0o.)j&#${C_+r^|oh1lW5L|-Y^S?w>yQQ#dnJ,[GE/-3X4([[V7');
define('NONCE_SALT',       'g0+CI^bh|d,*|Mu$.Kqsm{_6Aph<dNkJ 7bw4wKV%OG`zGYf~K!Z86U^aP5+DG{v');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

WordPress installation Wizard

Now we have all the configuration in place to complete the installation of WordPress. 

Open your browser and type the IP address of your “Rock64/own server” and follow the installation wizard. 

Select your language:

The next step will be set your blog Tittle, UserName, Password and an email address for your user.

Don’t forget your password
Success, click on “Log in”.

If everything goes well, you are going to be redirected to your WordPress admin site.

WordPress Admin site

We have almost everything ready to publish our blog to the world.

Meanwhile you can start tuning your blog, creating some test post, adding themes, etc.

On the next post I’m going to show you how to get your free DNS (hosted), domain and SSL certificate also, I’m going to explain you how to create some basics rules in your router for redirect all the http/https request to your external IP address to your Rock64/Raspberry Pi/home.

Don’t forget to share your comments and share this post to your friends and nemesis.

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

  1. Pretty nice post. I simply stumbled upon your weblog and wished to say
    that I’ve really enjoyed searching your site posts.
    In any full case
    I’m going to be subscribing to your feed (hopefully I can think
    it is) and I am hoping
    you write again soon!

Leave a Reply

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

%d bloggers like this: