How to install WordPress on NearlyFreeSpeech – Part 2 – Installing WordPress

This post will get your WordPress installation working on NFS. The first post walked through setting up the NFS database. And the third post will show you how to turn on HTTPS.

Download WordPress
The next step is to download WordPress to NFS. Some basic knowledge is assumed here so hopefully you know how to SSH into NFS. NFS is probably not the right hosting site for you if you don’t know how to do this as NFS is very bare bones as mentioned above – although it will be a very good but steep learning curve if you are just beginning!

I am planning on putting my WordPress installation in a sub directory of my site so that I can access at www.mc-guinness.co.uk/blog however you could alternatively use a subdomain e.g. blog.mc-guinness.co.uk, either way is up to you. But if you are using an SSL certificate to allow HTTPS access then you may need a second one to use HTTPS on a subdomain.

While NFS is designed to be bare bones, it appears that so many people use it for WordPress hosting that they have included some basic automation to install WordPress. I suspect that this is the case as it means they can keep one copy of the installation files and distribute locally rather than everyone downloading a fresh cop for each installation – indeed once you run the installation command below you can see that it is installing from a local cache.

Log into NFS via SSH and run these commands to make your sub directory, then download and extract WordPress into it.

Note that this is taken from the NFS support site at https://members.nearlyfreespeech.net/[NFS_ACCOUNT_NAME]/support/wordpress (you need to be logged in). You’ll note that almost every step resulted in an error so I have shown you how to actually make it work without using the built in NFS commands, so I’m presenting both methods here.

mkdir /home/public/blog
cd /home/public/blog
wp core download

These commands will result in a wordpress site hosted at www.yourdomain.com/blog/ . If you want it at your domain’s root (i.e. without the /blog/) then just install in /home/public.

Note that I got an error when I ran the last command:

So instead I decided to manually download and extract the latest version of WordPress from https://codex.wordpress.org/Installing_WordPress

cd /home/public
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv wordpress/* blog/
rmdir wordpress
cd /home/public/blog

Have WordPress generate a config file for you using your own DB details and desired login details:

wp core config --dbhost=db_host.db --dbname=wp_blog --dbuser=wp_blog --dbpass=password
chmod 644 wp-config.php
wp core install --url=example.nfshost.com --title="Example Blog Title" --admin_name=exampleadmin --admin_password=adminpassword --admin_email=example@example.com

Again, I got an error at this point:

This is easily solved by taking the sample config file provided with WordPress and using it.

mv wp-config-sample.php wp-config.php

=======================================================================

This section is only needed if you manually create and edit the wp-config.php file, if the commands above worked then no need to do this. Skip down if the commands worked for you…

Open the file and edit it to meet your desired configuration – the commands above would have done this for you. In particular, fill in the following (remember the DB config details from earlier: MySQL process host name = db_host, DB name = wp_blog, username = wp_blog, and password = really strong password you made up or generated):

define('DB_NAME', 'wp_blog'); 
define('DB_USER', 'wp_blog');
define('DB_PASSWORD', ' really strong password you made up or generated');
define('DB_HOST', 'db_host');

 

Now you can go to your WordPress site to finish the set up: https://[YOUR_WEBSITE_ADDRESS]/wp-admin/install.php

Choose a title, admin username, password, and enter your email address. Done!
Now you should be able to go log in and start configuring your site:

https://[YOUR_WEBSITE_ADDRESS]/wp-login.php

That’s the end of the section for manually creating and installing the wp-config.php file.

=======================================================================

If the commands worked for you skip to here!

There may be a section of 8 lines with the heading ‘Authentication Unique Keys and Salts’ – I believe newer WP versions have gotten rid of this and already included the salted lines. You’ll know if they need replaced as they’ll read something like: “define(‘AUTH_KEY’, ‘put your unique phrase here’);”.

They don’t need replaced if they already look like a messy line of gibberish e.g. “define(‘AUTH_KEY’, ‘ha$@2AgW*vm+?U86@>0fui)354y_Iet{cW({Ng7N~xz5Iks=ijV)f^n%Z-%’);

If they need replaced then go here to get new salted lines: https://api.wordpress.org/secret-key/1.1/salt/

Copy and paste them into place. For more details on what these are and how they work to make your site more secure read this: https://blogvault.net/everything-about-wordpress-security-keys/

File permissions, etc
Let’s do some tidy up and basic config to enable WordPress to upload files, update themes, enhance security, etc.

To enable file uploading
In your main WordPress installation folder enter the following SSH commands:

mkdir -p wp-content/uploads
chgrp -R web wp-content/uploads
chmod -R 775 wp-content/uploads

File and group permissions
For WordPress to work well with NFS we need the file permissions to be working correctly. NFS likes files to be owned by ‘web’ which is what the NFS server runs as, rather than your individual user ID which you’ll see if you do a ls -al from the SSH command line. These commands will set the right permissions – run these from the WordPress installation folder after the wp-config.php file is set up.

touch .htaccess
chgrp web .htaccess
chmod 664 .htaccess
chgrp -R web *
find . -type d -exec chmod 775 {} \; 
find . -type f -exec chmod 664 {} \;

This adds an .htaccess file, then assigns all files in the WordPress installation to the group “web”, and sets file permissions so that “web” can read/write to those files.

To allow WordPress to manage plugins and themes, etc we need to add a line (and comments) to the end of the wp-config.php file:

cp wp-config.php wp-config.php.old
echo "">>wp-config.php
echo "// allow WordPress to manage themes, plugins, etc" >> wp-config.php
echo "define( 'FS_METHOD', 'direct' );">>wp-config.php

You should now have a functioning WordPress installation. The next post will get your WordPress site working via HTTPS/SSL assuming you have HTTPS enabled in NFS (this guide will help!).

Leave a Reply

(email optional)


Warning: Undefined array key "rerror" in /home/public/blog/wp-content/plugins/wp-recaptcha/recaptcha.php on line 291