WebHosting on WDMyCloud V4 Firmwares

Need help to host your simple private website or save future cost by migrating your simple SME company’s website to your personal NAS such as WDMyCloud? For a generous donation you can make it work! Professional freelance web coding design services are also available for your needs. Do send in your enquiries.

Nginx on WDMyCloud

Nginx on WDMyCloud

This guide has been separated for generic implementation of WebHosting on the WDMyCloud V4 Firmwares. Purpose of this guide is mainly for those who’s new to personal web hosting (maybe Linux itself) and interested in running sites like OwnCloud or WordPress on their WDMyCloud firmware v4 NAS. If you’re not familiar with HTTP Servers and CGIs, then maybe this is not for you.

Why Nginx not Apache2? Apache2 is great but when there’s multiple or concurrent connections, the WD’s Apache2 MPM_PREFORK and MOD_PHP5 configs may cause lots of swapping as they have high memory print thus slowing down everything with high I/O Wait. At some point you’ll need to unplug the power as even SSH not responding.

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.

WDMyCloud is a pretty small server, dual-core ARM Cortex-A9 650MHz CPU with 256MB DDR3 RAM running on Debian Wheezy OS. But with some mods, tweaks and caches, it should be able to host a small personal site (not those thousands daily hits). The idea here is to switch Apache2 to a lower memory consumption threaded MPM_EVENT process which is compatible with PHP5-FPM and together with a light-weight Nginx, hopefully there’ll be lesser swapping. We can’t totally remove Apache2 because lots of WD’s stuffs depends on it like WebDav remote login for example will require revamp of the PHP scripts.

1) Get free DNS forwarder if not done so [Optional]
To easily access your WDMyCloud without needing to remember your external ISP IP address especially if it’s dynamic, get those easy to setup and free Dynamic DNS forwarder such as http://freedns.afraid.org/signup/moreinfo/. They provide free DDNS forwarding up to 5 subdomains. Your router many already have such DDNS service but I find it rather limited. I’m using GoDaddy’s DNS service which bundled with my paid domain (www.TeaNazaR.com). Tips: If your owned domain provider doesn’t provide an easy method of updating your dynamic ISP IP, you can also make use of this freedns service by pointing your owned domain CName (Alias) to the freedns subdomain. Cool huh? (-:

Updated: If you’re using GoDaddy’s DNS service, do refer to my latest GoDaddy DDNS Updater post.

After reading the FAQ and signing up with email confirmation, login and click on the left “Registry” menu to find a nice suitable DNS for yourself like “mooo.com”, click on it. On the next page, all you need to submit is your “Subdomain” e.g. my-freedns-subdomain.mooo.com. Note this down if you’re setting up OwnCloud or WordPress from my other guides as we’ll need it later to setup Nginx’s “server_name“. Leave the rest as default. Next we’ll need to ensure the DNS is always up-to-date with your ISP IP address. Click on the left “Dynamic DNS” menu where you’ll see your new DNS list, right-click and copy the link “Direct URL“. The URL should point to something like http://freedns.afraid.org/dynamic/update.php?RllWcksfRUY5afdyUGNgdVcwQs43ejROhjEyNTfxgjQw. Then schedule a 5mins repeating cronjob on your WDMyCloud to automatically update the DNS incase your ISP IP address changes. SSH into your WDMyCloud, issue crontab -e and add a new line:

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

Note that if you have several subdomains, obviously you’ll need one cronjob for each to auto update the DDNS unless if you have enabled the “Link updates of the same IP together” option. This option allows you to update the subdomains of the same IP all at once. Useful if you have several subdomains all pointing to your current ISP IP address so you can just trigger one update. I’m not using this option because sometimes I need some of the subdomains to be pointed elsewhere.

Test out once if it’s working, issue the same command and you should get ERROR: Address 123.123.123.123 has not changed where “123.123.123.123” is your external ISP IP address which you can find out by Googling “what is my IP“:


2) Prepare your router if not done so
This is usually unnecessary for standard Nginx install which you could just forward the same ports 80/443 between externally and internally. But since we’re integrating with Apache2, you’ll need to perform some changes else there’ll be port conflicts between Nginx and Apache2 as both are by default using ports 80/443.

Forward TCP external port 80 on your router to the WDMyCloud internal IP/HOST address PORT:5080. If port 80 is already taken on your router or port 80 is blocked by your ISP, you can choose other ports like 5080 itself but you’ll then need to specify the port manually when accessing from the internet e.g. http://my-freedns-subdomain.mooo.com:5080/ or http://your-ISP-IP-address:5080/. Also if your forwarded external port is other than 80 due to these two reasons, you’ll need to change all occurrences of Nginx’s fastcgi_param SERVER_PORT $server_port variable to whatever external port you’ve chosen. One example of the occurrences is in /etc/nginx/fastcgi_params.

If you have a valid SSL certificate (HTTPS), forward port 443 to wdmycloud:5443 as well. With the port routing below, you can have multiple websites running on single port 80/443 of your router thanks to Nginx’s “server_name” which is similar to Apache2’s VHOST:
Router TCP port(80) -> WDMyCloud TCP port(5080)
Router TCP port(443) -> WDMyCloud TCP port(5443)

Note however that some routers (especially those ISP bundled) have limited or restricted capabilities i.e.:

a. Lack of PAT. Meaning if you specify a rule to forward external port 80, it can only be forwarded to internal port 80. And since WDMyCloud is already using port 80 for Apache2, you’re left with no choice but to use port 5080 as both external and internal port for Nginx.

b. Unable to route back external port to internal port if the request is being made within LAN. Meaning if you try to browse your ISP IP via LAN, your router will return error. So you’re accessing Nginx from LAN, you’ll need to use internal IP instead of ISP IP.

c. You have more than one router i.e. one for the gateway and the other is set to bridge/AP (Access Point) mode.

These could be overcome but requires much more complex options and changes . Do send in your enquiries if you need personalized support.


3) Prepare your WDMyCloud
You’ll first need to install all the necessary apps (Nginx/PHP5-FPM/Perl/MySQL/ESMTP) tweaked for the WDMyCloud firmware v4, available on my post at the WD Forum. Get them installed at this post here, [APP] WebHosting for firmware V4+. Even though the WDMyCloud is already equipped with Apache2/MOD-PHP5/SQLITE, it’s still very sluggish as mentioned earlier maybe due to high I/O Wait and swap trashing. Sometimes it freezes the WDMyCloud for hours when there’s lots of concurrent PHP request and the only solution is to unplug the power cord. I’ve been trying to tweak it out but I finally gave up and switched to Nginx/PHP-FPM.


4) Prepare sendmail if not done so [Optional]
Some Web Apps uses local sendmail to send out email notifications. With ESMTP, you can simulate Postfix’s sendmail MTA by relaying emails to a SMTP server.

Edit ESMTP config:
nano /etc/esmtprc

You can use your ISP email if you know its settings or example here, Gmail. Edit below as needed:

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

Test out once if it’s working, you should see no output but still receive the email in your inbox:


5) Done
Now your should be able to host simple websites on the WDMyCloud with Nginx/PHP5-FPM/Perl/MySQL/ESMTP e.g. http://my-freedns-subdomain.mooo.com/ or http://your-ISP-IP-address/ and still able to access your WDMyCloud Dashboard from Apache2 http://wdmycloud/ (or whatever internal IP or hostname you have set it to).

And if at anytime you have issues with any of these web apps like very long response time (especially PHP5-FPM after too much concurrent request will result in swap file trashing), a restart is the best way to resolve it:

Checkout my other related guides for WebHosting:

For installing OwnCloud or WordPress on this new setup, refer to my guides below:

Enjoy (-:

58 thoughts on “WebHosting on WDMyCloud V4 Firmwares”

  1. Fixed mod_fastcgi issues on firmware v04.04.00-308 which caused WD DashBoard not loading.

    For those who already installed my WebHosting Mods prior this fix, do not reinstall, just fix it as below:

     

    1. HI,Nazar.
      thanks for your install guid .
      i want to install this – [APP] WebHosting for firmware V4+.
      http://seo.teanazar.com/11332537/webhosting-mods
      but there is errors: could not download the package succeed.
      i tried too many times
      but could not installed it yet
      is there a nother method to install it?
      thanks

      1. You’re behind a proxy, use my alternate port 8245 instead.

        1. hi,Nazar
          yes, i used 8245 port instead
          but failed yet
          is there anything i can do it?
          thanks

          1. Your request response ping is about 14-22seconds, usually more than 5secs it will fail. And your actual ping is almost 400ms even you’re in Asia. Strange I got better pings between Singapore and the EU/US. Is your MyCloud connected to a mobile network or something? I’ve added your IP 222.182.xxx.xx to my whitelist, try again. If it’s still not successful, then I have to look into your MyCloud to see what’s the issue.

            1. Thank you ,Nazar
              i try it again
              but still failed
              this time
              it said that “could not resolve host”

              thanks again

              1. Strange that you can post this comment but your MyCloud fail to resolve the same host. What’s in your cat /etc/resolv.conf; ? I suggest you contact me via the feedback form and I’ll look into your MyCloud.

                1. Thanks very much,,Nazar
                  it installed and worked
                  thanks again

                2. hi,Nazar
                  i want to reinstall it – [APP] WebHosting for firmware V4+.
                  http://seo.teanazar.com/11332537/webhosting-mods,
                  but failed.
                  i tried again and again,but it show me “Warning! More than 5secs lag! Check your internet/DNS.” and then failed to reinstall it.
                  i think that the reason is “Temporarily switching from a probably slow ISP DNS to GoogleDNS…DNS: 8.8.8.8/8.8.4.4
                  because in china, google was be blocked, i can’t ping 8.8.8.8 and 8.8.4.4, can’t open google.com\google.hk\gmail.google.com etc.
                  can you add my IP 222.182.xxx.xx and 106.92.xxx.xx to you whitelist, let me try again?(sometime my ip is 222.182.xxx.xx , but now, my ip is 106.92.xxx.xx )
                  or don’t switching from a probably slow ISP DNS to GoogleDNS…DNS: 8.8.8.8/8.8.4.4?
                  thanks very much

                  1. Are you able to ping OpenDNS 208.67.222.222 and 208.67.220.220? I’ve added your IPs to the whitelist.

                    1. yes, i can
                      but my request response ping is about 141-201seconds

                    2. That’s too long, you might need to check with your ISP of your bad pings. I’ve cleared your bans, also whitelisted a new IP of yours, seems it changed too frequent. I’m not able to constantly update the whitelist for anonymous credentials.

                    3. thank you ,Nazar.
                      yesterday, i tried many times , but could not download files ,beause my request response ping more than 5secs.
                      please kindly remain my ip in you whitelist a few days?
                      i will try next.
                      thanks

                    4. Hi, Nazar
                      these days, i changed too many many DNS;
                      and changed a router also,
                      tried and tried,
                      but failed yet.
                      i used a tool to check dns,
                      it showes as image

                      maybe chinese users is hard to install it
                      so i want to reset mycloud
                      if i do so ,these WebHosting for firmware V4+ would be reset too?
                      just like never been intalled?
                      thanks

                    5. I don’t understand why you need to reinstall the WebHosting mod, wasn’t it already installed? You just need to focus on what you need to run, in this case OwnCloud. If you always have issues with the installer, I suggest you getting the permanent donation credentials which has more priorities/timeouts than anonymous credentials, no captcha, no adverts and no limits. I could also consider adding OpenDNS to the installer and personally help to install them for you.

                    6. maybe i del mysql database user wrong
                      now, mycloud responding is very slow even via SSH
                      and dashboard is not normal.
                      so ,i want to reinstall to correcet it.
                      i used BTsync instead owcloud

  2. Fixed perl-fcgi permission issues from unix:/var/run/perl-fcgi.sock to unix:/tmp/perl-fcgi.sock.

    For those who already installed my WebHosting Mods prior this fix, do not reinstall, just fix it as below:

  3. Hi.
    Im getting this error on reinstall:
    Installing (76)-> mysql-server-core-5.5_5.5.42-1 3.3MBytes…OK!
    Installing (77)-> mysql-server-5.5_5.5.42-1 1.6MBytes…
    Error-1: Unable to install required file! ‘mysql-server-5.5_5.5.42-1’
    WDMyCloud:~#

    1. Hi pix,

      I noticed you’ve tried installing a few times. Is there already database/tables created on your MySQL? Did the error happens on the very 1st clean install? I could not replicate this on a clean latest firmware. Let me know when you’re free, contact me via the Feedback form and I’ll look into your system to fix the issue.

      1. Hi.
        Yes there are databse from kodi created.
        I factory reset the NAS because i thought I could start from scratch, but the truth is it did not delete all that i installed on rootfs.
        But it broke mysql.
        So I went on reinstalling webmods and now im getting this error.

        1. I found your issue. What happened was you already have an existing MySQL installed but the MySQL database directory is missing probably removed intentionally ‘/DataVolume/mysql’.

          I’ve already fixed it for you, you may now revert back the port forwarding and root password changes temporarily done earlier.

            1. Hi J.K.,

              Have you tried removing the path including its contents “/DataVolume/mysql” then retry installing? If you still have issues, I’ll be glad to assist you remotely, let me know. I assumed you’re ahead of me by one hour so we can do this anytime tonight.

  4. Hi Nazar,

    thx for your work!
    After updating my WDmC to v04.04.04.101 I have to reinstall your WebhostingMod.
    Mostly it stops by “Checking resources…”, so I have to try really often.
    If it goes further with the installation, it stops with the following lines:

    Installing (76)-> mysql-server-core-5.5_5.5.42-1 3.3MBytes…OK!
    Installing (77)-> mysql-server-5.5_5.5.42-1 1.6MBytes…
    Error-1: Unable to install required file! ‘mysql-server-5.5_5.5.42-1’
    Do you have an idea whats wrong?

    I hope you can help me.

    thanks
    Mike

    1. Hello Mike,

      I’ve moved your comment to the appropriate post, WebHosting on WDMyCloud V4 Firmwares.

      The logs in /var/log/mysql* and /var/log/daemon.log might have the reason why it failed. Else you could try removing the path rm -rf /DataVolume/mysql including its contents then try reinstalling? NOTE If you have important data, please backup your MySQL data first i.e. mysqldump -u USER -p PASS --all-databases --events>/DataVolume/MySQLBackup.sql which then you can restore back using mysql -u USER -p PASS</DataVolume/MySQLBackup.sql. You could also try a system restore if you don’t have any other mods in the rootfs.

      If you still have issues, I’ll need to look into your system. Temporarily forward port 22 from the router to your MyCloud and change your root password to your email address mike_*@*.de, I should already have your IP *.*.*.226 let me know (via the feedback form) if this is not your IP but proxy/VPN. JFYI, I’m off for a two weeks vacation this Wednesday evening GMT+8.

  5. Mathieu Vanier says:

    Hi Nazar,

    This night, my wdmycloud got a firmware update… I can’t access anymore my wordpress site i created earlier…

    I’m trying reinstalling web hosting like you mentioned above of this post, but did i do anything else after this? Is my wordpress site will be still there?

    thx a lot

    1. Hello Mathieu,

      The WordPress files, configuration and database are still intact since I set it up to reside on the DataVolume. But after reinstalling, you will need to reconfigure just the Nginx part (step #3-4 from my WordPress on WDMyCloud V4 Firmwares guide) because any configurations/modifications will be lost as the firmware update wipes our rootfs.

      If you have lots of configurations, it’s best to keep a copy elsewhere. I also would suggest that you’d switch off the MyCloud auto update and update it manually during your free time so you don’t get surprises.

      1. Mathieu Vanier says:

        Ok, I have set auto update to off.

        I have done de web hosting installation again.

        I have done the Nginx part (step #3-4 from my WordPress on WDMyCloud V4 Firmwares guide)

        But i have again the same problem from 3 weeks ago.

        I have this page

        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.

        What i’m doing wrong again?

        thx

        1. Ok don’t touch anything in the Nginx default config else you’ll get confused. Also don’t remove this file either. Your checklist:

          1. In the file /etc/nginx/sites-available/wordpress, after copy&paste the contents from my guide, have you replaced this line server_name my-freedns-subdomain-wordpress.mooo.com; with your DDNS? And did you access using your DDNS?

          2. Make sure you didn’t accidentally uncomment the first 6 lines in this file like the other time.

          3. From step #4 in my guide, make sure the symlink exists. Check with ls -l /etc/nginx/sites-enabled/wordpress. You should see something like: lrwxrwxrwx 1 root root 26 Dec 8 16:25 /etc/nginx/sites-enabled/wordpress -> ../sites-available/wordpress

          4. Has Nginx been reloaded? service nginx reload

          1. Mathieu Vanier says:

            In the file /etc/nginx/sites-available/wordpress, after copy&paste the contents from my guide, have you replaced this line server_name my-freedns-subdomain-wordpress.mooo.com; with your DDNS? And did you access using your DDNS?

            yes it was replaced with server_name classeamthieu.ddns.net;

            Make sure you didn’t accidentally uncomment the first 6 lines in this file like the other time.

            I did not uncomment the first 6 lines

            From step #4 in my guide, make sure the symlink exists. Check with ls -l /etc/nginx/sites-enabled/wordpress. You should see something like:

            lrwxrwxrwx 1 root root 28 Apr 20 11:17 /etc/nginx/sites-enabled/wordpress -> ../sites-available/wordpress

            Has Nginx been reloaded? service nginx reload

            [ ok ] Reloading nginx configuration: nginx.

            i still got this page : Welcome to nginx on Debian! …..

            1. Hmmm that’s weird yeah I saw your default page too, try restarting the daemon? service nginx restart. This should be just a matter of vhosts.

              If you like me to check now, forward your port 22, then temporarily change your ssh password using passwd to the email you use to post this message. You can revert them back when I’m done in a few minutes. I’ll post back the results.

              1. Mathieu Vanier says:

                WDMyCloud:/etc/nginx/sites-enabled# service nginx restart
                [ ok ] Restarting nginx: nginx.

                passwd change for the email i use.

                port 22 forwarded on my wdmycloud box.

                you can check it

                thx

                in the same time, do i need to reinstall transmission too?

              2. Thx, it’s now working.

                But can i know what you have change to make it worked?

                Can you tell me what do i need to save has file or folder to make it work on the next update to make it easy ??

                And my transmission does not work too, i imagine i need to reinstall it?

                thx a lot

                1. Something is strange about your DDNS. It works in the browser even with dns flushed but I can’t resolve by doing a dnslookup (both from my end and from your MyCloud) so I temporarily use my subdomain to debug. But this is not the issue here.

                  I suspect because of this intermittent lookup failure that Nginx acts strangely. So what I did for you was:

                  1. Remove the default config symlink rm -f /etc/nginx/sites-enabled/default.

                  2. Uncomment the “upstream” directive (lines 3-6) in your /etc/nginx/sites-available/wordpress then reload Nginx service nginx reload.

                  Additionally your database, although it’s still there but the settings got messed up. So I stopped your MySQL to remove the new DB /var/lib/mysql then recreate the symlink to your old DB /DataVolume/mysql.

                  Also fixed the privilege issue GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<password>'; where the password is from /etc/mysql/debian.cnf then restart MySQL service mysql start.

                  As for your latest comment, yes you need to reinstall transmission. Everything in the rootfs will be wiped upon firmware upgrade. So if there’s any config you have made in the rootfs, make a backup of it elsewhere.

                  Ok I’m done, now please revert your SSH password and remove the port 22 forwarding.

  6. Hello Nazar,
    is there another way available to donate – except paypal ? I don`t have paypal but can use my credit card.
    I need an access to reinstall a.s.a.p. my webspace because off crash my old HDD

  7. Hello Nazar,
    is webhosting-mod 1.0.0 working on firmware v04.05.00-320 ?
    After donation I tried to install it without success because of bad network connection.
    My ISP is changing the IP sometimes a day. How can I save my access without banning ?

    1. Hi Ronny,

      It should work on all v4 firmwares. I’ve updated your IP record. The installer should start tracking your ISP IP whenever it changes after the first time you use it. Any issues do let me know via the feedback form as it’s faster after which I’ll contact you directly via email. Also I’m currently on vacation in Munich and most of the time on road.

  8. Hello Nazar,
    thanx for your support, it’s working fine now. Have nice holidays in Munich – in the north of Germany it’s snowing also….

    1. No problem Ronny, glad it helps. Thanks and yeah, after covering Luxembourg, Belgium and the Netherlands, I was traveling from Berlin to Czech, Austria then now back in Munich and it’s been drizzling and snowing. Hopefully the weather is fine tomorrow in Liechtenstein.

  9. Hello Nazar,
    is it possible to extend the webhosting space ? What I´ve seen is the a limitation covered at 1GB. Is this right ?

    1. Hello Ronny,

      The limited space you see is the default setup. You can change the WWW root path or add multiple virtual hosts anywhere in your DataVolume partition. Refer to my post on this site regarding WordPress or OwnCloud. The step number two onwards will guide you further.

      1. Hello Nazar,
        one question again:
        I tried to install SSL with my certificate under NGINX with the normal procedure, but it doesn`t work. Are there any specially steps to listen up ?

        1. Hello Ronny, Could you share your first few config lines? You can mask off certain info you don’t want to share. It’s actually very easy to install the SSL certs, I have a few installed including this teanazar.com domain. You can see the sample in my WordPress or OwnCloud how-to post from step #3 e.g. below.

          Uncomment the listen 5443 ssl, ssl_certificate and ssl_certificate_key making sure it points to the cert and key location on your MyCloud. /etc/apache2/certs/ paths are the ones belonging to WD where you use the cloud feature so don’t use or replace these certs/keys (I purposely point it there as a sample incase someone uncomment it accidently) but instead you can place and load your certs/keys from anywhere within the MyCloud. Forward port 443 from your router to the MyCloud port 5443 or whichever port you have chosen. Ensure port 443 is not already used in your router. WD Apache2 for the cloud feature sometimes use this standard port 443 as the external port so double check if you need to change this port from the WD dashboard. Remember to reload nginx after making changes to its config. If it fails, check the error log tail -f /var/log/nginx/error.log. Also let me know what the error is.

          1. Hello Nazar,

            I follow your instruction without success. Now I decide to leave it on http – no problem.

            Another question: Concerning to your sample make install a outsending email configuration – is it possible to change from starttls to ssl/tls on a easy way ?

            Thank you in advance

            1. Enabling HTTPS is quite simple when you already have a valid cert/key. If there’s anything preventing it to be active you can checkout the Nginx error log. It also could be your router has already consumed the HTTPS port 443. We can look for a free time to do a remote conference (I’m 7hrs ahead) and I’ll have it quickly setup for you of course with your permission.

              For your other question, sorry I’m not sure what you meant. The starttls=enabled is only needed if your SMTP server needs a secure connection e.g. like Google. Secure connection will only mean TLS as SSLv1/2/3 was deemed obsolete. Some SMTP doesn’t require authentication so you can comment out or disable the starttls. You can see here for details, http://esmtp.sourceforge.net/manual.html.

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