WordPress on WDMyCloud V4 Firmwares

WordPress V4
WordPress V4

 

Disclaimer: As I’m frequently updating the original guides and installers here on TeaNazaR.com, I will not be responsible for any brick issues if you were to follow my obsolete guides copied elsewhere. Thus subscribe to this post to get latest updates. Modifying any part of a device may void its warranty.

 

Just over last weekend, I remotely assisted one of my donor (who donated very, I mean really very generously, thanks again John Wilkins from U.K.) for his request to install OwnCloud on to both his WDMyCloud 3TB NAS and also WordPress on to one of the NAS. So I’m taking this opportunity to list down the necessary steps since it’s still fresh in mind.

Still similar to my OwnCloud installation guide here, there’s two method of running WordPress, first with a secondary domain (http://secondary-domain.primary-domain.com) or sub-path (http://primary-domain.com/sub-path).

Sub-path method is fairly easy to install so I’ll skip it and proceed to secondary domain (a.k.a. subdomain). You can also use this method if you own a full qualified domain (http://www.domain.com). For your info, WordPress also supports multisite which you can have multiple sites/domains running under one WordPress installation. But I will not cover the multisite topics here.

1) Prepare your WDMyCloud
I’ve separated the Web Server perquisites and installations in another guide. Please follow the guide WebHosting on WDMyCloud V4 Firmwares then comeback to this post to complete your WordPress installations on the WDMyCloud.


2) Prepare WordPress
WordPress doesn’t have any online installer so we’ll need to get it manually. This is version 4.3.1 at the time of published. Issue the commands below on your SSH shell session:

WordPress requires some security keys to be generated the first time your install. Go to this link on your browser https://api.wordpress.org/secret-key/1.1/salt/ and leave the it open for now as you’ll need the results on the next step.

Then edit the WordPress config file nano wp-config.php . Edit as below:
define(‘DB_NAME’, ‘wordpress‘);
define(‘DB_USER’, ‘root‘);
define(‘DB_PASSWORD’, ”); # (leave blank unless you’ve changed MySQL root password)
define(‘DB_HOST’, ‘localhost:/var/run/mysqld/mysqld.sock‘);
define(‘DB_CHARSET’, ‘utf8‘);
define(‘DB_COLLATE’, ”); # (leave blank unless you know what you’re doing)

Right after the ‘DB_COLLATE‘ variable above, you’ll see similar variable entries as the one from your browser opened earlier. These are the security keys. Replace all the eight lines with the ones from your browser e.g.:

When done, “CTRL+x” to exit and “y” to save changes to the file.

Next we have to create a new database. Enter the MySQL console mysql -u root (add -p switch if you have changed MySQL root password). Then in the MySQL console, issue the following commands:


3) Prepare Nginx WebServer
Edit a new config file:
nano /etc/nginx/sites-available/wordpress

Paste and edit below as needed. Take note of the server_name parameter and replace it with your acquired earlier DDNS subdomain or your full qualified domain if you own it:

When done, “CTRL+x” to exit and “y” to save changes to the file.


4) Enable the new configs
Activate the new wordpress config file:

Check if the new wordpress config is good:
service nginx configtest

If failed, find out why in the log and fix it:
more /var/log/nginx/error.log

Reload Nginx:
service nginx reload

Or if you have changed the listening ports:
service nginx restart

Note that you’ll also need to reload the PHP-FPM Daemon every time you make manual edits to the PHP scripts content or settings else you won’t see the changes. They are commonly files with “*.php” extension. This is perfectly normal for performance, due to precompiled scripts memory caching by PHP Opcache. The easiest way to clear the cache:
service php5-fpm reload


5) Setup WordPress
Browse to your domain or the free DNS forwarder you got earlier to start the setup:
http://my-freedns-subdomain-wordpress.mooo.com/

Or if you know what you’re doing and have set Nginx’s default server differently, just browse the WDMyCloud internal host/IP:
http://wdmycloud:5080/

a. On the first page, choose your language, click “Continue“.

b. On the second page, it’s pretty self explanatory i.e. fill up the “Site Title“, “Username“, “Password “, check “Confirm Password“, provide a valid “E-mail“, choose your “Privacy” and finally click “Install WordPress“.

c. Wait patiently for your database tables to be created, after which you can now log in to your WordPress admin page.

Note that WordPress runs quite fast on a clean install of the WDMyCloud, ranging from 2ms to 2sec response time from a single request. But it will slow down tremendously if you kept installing bloated WordPress plugins. Or if there’s other apps currently using your CPU/IO resources such as Transmission if you have it installed and it’s active torrenting. Or if you have more than one sites using PHP5-FPM concurrently. Prefer to use HTML cache such as “W3 Total Cache” or “WP Super Cache” WP plugins rather than direct PHP request which indirectly advising to disable new user registrations because logged in users needs complete PHP interactions (you can’t feed them with caches). You can allow public comments or better by using “Facebook Comments” WP plugin using AJAX (I have not tried this though but it should help to decrease your load) or even better, code some of the simple snippets yourself according to your needs (I have done it on this site). If you’re uploading lots of images, resize them before uploading and avoid using PHP post processing the images. You can use this Adobe Flash based WP plugin “Resize images before upload“. Use commands like top and free -h to monitor your WDMyCloud usage. So keep all these in mind, be patient and keep it simple. For help and details or WordPress related errors, please refer to https://wordpress.org/.

Checkout my other related guides for WordPress, Speedup WordPress (Nginx’s Gzip_static + Minify + W3 Total Cache).

Enjoy (-:

30 thoughts on “WordPress on WDMyCloud V4 Firmwares”

  1. Hi Nazar,
    You don’t appear to have a ‘general blog’ so will have to post this here .
    Spent many happy hours in Singapore in 1963 and 1964 and again in 1968 and 1969.
    Particularly remember eating nasi goring at the stalls at Sambawang village just out side the dockyard gates,
    Was there for 23 hours last Dec (in transit) but missed out on the city coach tour layed on by the city and Singapore Airways . Hoping for better luck next December.

    1. Hi John,

      Great to hear you’ve been to my country may times, it has changed tremendously over the years. I too would love to revisit London again 🙂

      1. Hi Nazar,
        Don’t know where you got ‘ I live in London’ from , I live in Oldham , a metropolitan borough of just over 250,000 people on the north side of Manchester

        1. Hi John,

          Just merely guessing from your ISP’s location 😛

  2. Hey Nazar,

    Hope you’re ok, I made a small donation yesterday! but will make more when I get paid. I think what you are doing is great!

    Also, I know the WD Cloud isn’t a power house, but would it be possible to
    build the Plex server for it? just so I could use this as a fall over if my server was
    to fail.

    Obviously we could only stream no transcode but might be useful.

    Anyway, Thanks for everything you are doing!

    Chris

    1. Hi Chris,

      I’m good! Hope you’re too 🙂 And thanks a lot for the donation!

      As for Plex, unfortunately it’s not possible because it’s a “closed source” proprietary software where the codes not published to the public. Thus we can’t compile it patched with 64K page size memory requirements for MyCloud’s kernel. Otherwise I’ll be happy to built it for you.

  3. Mathieu Vanier says:

    Hi nazar,

    thx for all your How to.

    But i have a problem with wordpress. I have followed all your tutorials and everything goes good except the last step.

    when i try to setup wordpress with the adress 192.168.1.200:5080 i obtain this :

    Welcome to nginx on Debian!

    If you see this page, the nginx web server is successfully installed and working on Debian. Further configuration is required.

    For online documentation and support please refer to nginx.org

    Please use the reportbug tool to report bugs in the nginx package with Debian. However, check existing bug reports before reporting a new bug.

    Thank you for using debian and nginx.

    I can’t choose the language for wordpress and going the the next step.

    What can i do to solve this problem? did i miss something?

    i have done everything
    [ ok ] Testing nginx configuration:.
    [ ok ] Reloading PHP5 FastCGI Process Manager: php5-fpm.
    [ ok ] Restarting nginx: nginx.

    Thx a lot for helping.

    Miistral

    1. Hello Mathieu,

      The key point to take note is the server_name variable in the Nginx’s config. This is a vhost (virtual host) setting so we can host more than one domain/host in one server. The page you’re seeing is from the default config file /etc/nginx/sites-available/default because you tried accessing using an IP address and Nginx doesn’t know which domain/host you want to visit so it points to the default.

      So you need to point your browser to the DDNS which you had setup earlier in the new Nginx’s wordpress config file e.g.: server_name my-freedns-subdomain-wordpress.mooo.com;. If you do not have any existing DDNS ready to use, temporarily set the server_name to wdmycloud or whatever your MyCloud’s internal hostname is then access it using http://wdmycloud:5080. Don’t forget to reload Nginx everytime you make changes to its configurations.

      1. Ok, i’ll try it, but at the moment i can see my wordpress website if i user neighbor connection but not in my home network.

        If i go to classe mathieu.ddns.net:5080 from outside of my network it’s ok.

        But if i go from inside my home network i can’t go anywhere…

        what can i do to solve this?

        1. It’s your router’s limitation, some consumer-end routers don’t support this, it doesn’t know how to handle an internal NAT request a.k.a. loopback. You could however do away temporarily with editing your current PC’s host file pointing the host mathieu.ddns.net to your MyCloud’s internal IP i.e. 192.168.1.2. Some routers might allow you to specify static hostnames which you can point to your MyCloud’s internal IP.

  4. Mathieu Vanier says:

    do you know what can i do for this error :

    2017/03/29 11:31:33 [emerg] 9805#0: no port in upstream “php5-fpm.sock” in /etc/
    nginx/sites-enabled/wordpress:25

    thx

    1. Did you remove or modify the default server file? It contains the upstream codes for both perl and php.

      1. Mathieu Vanier says:

        not supposed to, because of this error, i have redo all the web hosting installation, and the problem still there…

        1. You don’t have to redo, it’s a matter of slight mis-configuration. Confirm that the default config file is loaded (it should because you saw the Nginx’s default page) together with the wordpress config file and that the wordpress config is exactly stated as the guide except for the server_name. You can also choose not to use the upstream block and specify the fastcgi_pass directly. If you still can’t get it right, show me both of your default (if modified) and wordpress config file content because I find it’s strange that you see this error but you said that could see your wordpress site earlier.

          1. Mathieu Vanier says:

            can you juste help me to find this file so i can show you the result?

          2. Mathieu Vanier says:

            <?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’, ‘root’);

            /** MySQL database password */
            define(‘DB_PASSWORD’, ”);

            /** MySQL hostname */
            define(‘DB_HOST’, ‘localhost:/var/run/mysqld/mysqld.sock’);

            /** 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’, ”);

            there is the wordpress config file…

            I don’t know how to tell the default config file is loaded.

            But yes i see this :

            Welcome to nginx on Debian!

            If you see this page, the nginx web server is successfully installed and working on Debian. Further configuration is required.

            For online documentation and support please refer to nginx.org

            Please use the reportbug tool to report bugs in the nginx package with Debian. However, check existing bug reports before reporting a new bug.

            Thank you for using debian and nginx.

            but in ssh i got this :

            WDMyCloud:~# service nginx restart;
            [FAIL] Restarting nginx: nginx failed!

            1. No this is not one of the Nginx’s config file but WordPress itself.

              Show me the contents of both Nginx’s config files below:

              1. cat /etc/nginx/sites-enabled/default (this is created when you install my webhosting mod)

              2. cat /etc/nginx/sites-enabled/wordpress (this is the file in one of the steps in the guide)

  5. Mathieu Vanier says:

    1 – /etc/nginx/sites-enabled/default (this is created when you install my webhosting mod)

    I do not have any file named default in this folder ( i have only wordpress)

    2 – /etc/nginx/sites-enabled/wordpress (this is the file in one of the steps in the guide)

    Below should have already been set in /etc/nginx/sites-enabled/default.

    Uncomment if you have removed the default config.

    upstream php5-fpm.sock {

    server unix:/var/run/php5-fpm.sock;

    keepalive 1;

    }

    server {
    listen 5080;
    # Uncomment below if you have a valid SSL certificate (HTTPS).
    #listen 5443 ssl;
    #ssl_certificate /etc/apache2/certs/server.crt;
    #ssl_certificate_key /etc/apache2/certs/server.key;
    # Change server_name to the DNS forwarder domain you have.
    server_name classemathieu.ddns.net;
    # Full path to WordPress.
    root /DataVolume/wordpress;
    index index.php;
    location / {
    try_files $uri $uri/ /index.php?$args;
    }
    location ~ ^(.+?.php)(/.*)?$ {
    include snippets/fastcgi-php.conf;
    include fastcgi_params;
    fastcgi_pass php5-fpm.sock;
    }
    }

    1. Few things I noticed:-

      I do not have any file named default in this folder ( i have only wordpress)

      You do not have the file because it was removed, it should be there during installation.

      And even if the file is still there, there'll be duplicates in the “upstream php5-fpm.sock” block, one from the default file (it should be there) and the other is when you commented out the top part in the wordpress config (which you should have not since it's already in the default config).

      Finally you commented out wrongly on the first two lines, see the wordpress config top part which includes my comments.

      To solve this, since you already removed the Nginx's default config, leave upstream block un-commented in the wordpress config and most importantly comment out the first two lines which are meant to be comments. The wordpress config should look like this:

      1. Mathieu Vanier says:

        Wow, thx a lot,

        no more failed : [ ok ] Restarting nginx: nginx.

        I can now see my page on local network.

        I can now see my page on external network.

        works perfectly.

        Mathieu

        1. Mathieu Vanier says:

          but do you know why on external network i can access to wordpress dashboard and i can’t on my internal network?

          1. I’m not sure how you setup is and whether it’s final or not but that’s up to you. I don’t see WordPress running on your port 5080 but there’s Joomla on port 80. If you’re accessing WordPress directly using the port 5080 and not using any PAT (port address translation), go to your WordPress Dashboard -> Settings -> General and edit both “WordPress Address” and “Site Address” appending port “:5080” to it i.e. http://yourddns.com:5080/.

            1. Mathieu Vanier says:

              I think the problem is wordpress always make attempt to connect to : http://classemathieu.ddns.net:5080/wp-login.php

              If i write my local ip adress :192.168.1.200:5080/wp-login.php i can go to login screen. But when i press the connect button, it try to connect to my ddne.net adress.

              is that a router problem or wordpress settings?

              1. This is just how WordPress works, might be standard for other CMS too. It will always redirect you to your hostname in the setup. I think because primarily WordPress is able to run on multi-site so it needs to redirect correctly according to the hostname in the setup.

                BTW why are you trying to access using IP? Have you setup the hosts file I mentioned earlier since your router have NAT loopback limitations? In Windows: “C:\Windows\System32\drivers\etc\hosts” or Mac: /etc/hosts.

                1. Mathieu Vanier says:

                  i do not know how to set this nat loopback… can you explain more?

                  1. Your router doesn’t support NAT loopback. This means you can’t access any port forwarding setup while you’re within your local network but the connection works when you’re outside the network.

                    So for this temporary workaround you’ll need to modify your PC’s hosts file to tell that you want to connect to an internal IP via the full qualified domain. You can use LMHOSTS too but HOSTS file is probably easier. Now on your current PC, edit this file “C:\Windows\System32\drivers\etc\hosts” or if you’re using Mac, “/etc/hosts”. You’ll definitely need admin access and/or take ownership of the file’s privileges. Add a new line 192.168.1.2 classemathieu.ddns.net where 192.168.1.2 is your MyCloud’s internal IP. After saving it, you can now browse using http://classemathieu.ddns.net:5080/ which your PC will resolve the DDNS to your MyCloud’s internal IP instead of your ISP’s IP.

                    This is not a standard implementation but it’s just a workaround for your case. You will also need to modify the hosts file on all internal device as necessary. If your router has the ability to specify static hostnames (I used to have one), you can just do this on your router to avoid modifying hosts file on all internal devices.

                    1. Mathieu Vanier says:

                      Worked #1,

                      Thx again for all your work. 🙂

                      Mathieu

  6. Hello,

    I have a MyCloud 1 bay 2TB, with serial num. WDBCTL******-00. And I have the firmware versión V4

    I have a wordpress blog, and I would like to move the host to my MyCloud.

    Is this method valid for me?

    Thanks

Leave a Reply

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

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax