My Cloud local web server setup

As a web developer I use my NAS as a (local) server. I develop different websites on my server. I’m not directly interested in hosting these sites. I need to work on them from one simple to manage share.

Before, I had a QNAP. They have this option called “Web server”. With just one click the NAS creates a share called “web”. All folders on the web-share are considered websites. That way, i can go to http://localIP/website1 or http://localIP/website2 and so on. That way I can work on different (Wordpress) installations at one time.

I’m trying to figure out how to set up my new PR4100 like this. I can install the “wordpress-app”. This creates just one site in the NAS_Prog folder. Accessing this folder from my finder is not natively supported nor advised.

What am i missing? How can I set up a “web server” where one share hosts a multitude of sites that i can localy work on and simply acces by finder?

Almost every app creates a website in /var/www, usually by symlinking a web directory to /var/www/somesite in the init.sh script. In the clean.sh this symlink is deleted again.
I suggest you have a look at the init scripts of tautulli and cops here.

I’m sorry but i have no idea but you are referring to. I appreciate the help but this above my knowledge. No ‘simple’ solution? My problem seems a bit basic.

Sorry, I was a bit brief.
Enable SSH and use cyberduck or similar to browse the NAS.
All webpages, e.g. http://nasIP/wordpress, http://nasIP/website1, http://nasIP/website2 are sitting at /var/www … e.g. /var/www/wordpress, /var/www/website1 and /var/www/website2 …

Note that the /var/www directory exists in RAM, so it is destroyed on reboot.
That is why you should create your website e.g. in /shares/Public/websites/site1 and create a symlink to /var/www.
You may use these ssh commands to do so.

ln -s /shares/Public/websites/site1 /var/www/mywebsite

On shutdown, this symlink needs to be removed.

rm /var/www/mywebsite

To survive reboots, add these commands to a boot script, e.g. with cron or in the Nas_Prog/wordpress/init.sh + clean.sh

2 Likes

Thanks again TFl for you support. I’m so happy that you point me in the right direction. Although I have a general idea of what you are trying to say, I still can’t create this on my own. Isn’t there an app to do this? I always thought that a lot of people use their nas for these purposes.

  1. How can i create a symlink? Do i need to do this manually for every site?
  2. “On shutdown, this symlink needs to be removed. rm /var/www/mywebsite” Why does this need to be removed? How can i do that?

Thanks!

I gave you the ssh commands and what they do and links to relevant scripts.
Now it’s up to you to do your research and experiment to get a ‘hello world’ index.html working.

AFAIK, symlinks in /var/www to the hard disks may cause umount to get stuck during shutdown.

You are right Tfl, I successfully created the folders and symlinks liked you sad. Everything seems to work fine that way. Maybe it is possible to create an app on the NAS for this. An app to replicate a “web station”. Can you point me in the right direction again?

Everything worked out great, i learned a ton of new stuff working this out.
Problem is, when trying to work with php inside the symlinked folders, i get a 403 forbidden. Any ideas why this is happening?

do you have more details?

When following your above steps everything worked fine. The above 403 message was gone after a reboot of the system. I think however there is a problem with apache:

following your steps, I’ve created an index.php with an echo 'hello world'; in the root of
/shares/Public/websites/site1/ and symlinked this properly.

when opening 192.168.x.x/site1 the index.php get’s loaded. “hello world” is visible.

I was trying to install wordpress in this folder. Now the same link gives me an 404 error when the index.php is loading. “The requested URL /site1/wp-admin/setup-config.php was not found on this server.

I think that recursive folders and files are not loaded properly. Is there any way to fix this? Thanks again!

Edit:

I figured out what was going on. The symlink is not automatically showing new files. I have to manually add the symlink again to make new files show up.
Symlink used:
ln -s /shares/sites/site1/* /var/www/site1

Does this have something to do with my setup? What am i not seeing here?

Maybe it’s better to simply symlink the website directory instead of the separate files.
If the webserver cache is not in the way, this should be sufficient.

init.sh

ln -sf /shares/Public/websites/site1 /var/www/mywebsite

clean.sh

rm /var/www/mywebsite

The whole proces is just awful. After successfully creating symlinks I stumbled into problems like the PR4100 not being able to install node.js or npm. I just gave up. This system is not playing nice for web developers.

You have docker to pull in all these dependencies though.

The app manager in the firmware runs following scripts for registered apps:

  • preinst and install.sh on app install
  • init.sh on NAS boot
  • start.sh when the app gets enabled in the GUI and on NAS boot
  • stop.sh when the app gets disabled in the GUI
  • clean.sh on NAS shutdown
  • remove.sh on app uninstall

You can run a custom update.sh during the start.sh (or just put the commands in there) and then disable/enable the app in the web GUI to run the stop / start scripts.

You can safely remove anything from the wordpress scripts and files you don’t need (e.g. to only run your scripts on init / start / stop / clean). Careful with the remove.sh though, I’d suggest to leave it as is.

To create your own binaries, see wdpksrc.

1 Like

Any idea how I can do it in OS5 to work on Public IP? Local It’s working. I find a way to do from the system but I have to change the name for lots of files because the system files don’t accept special characters.

@Tfl, thank you so much for that info! I don’t understand why there isn’t more readily available, layman instructions on using the MyCloudEx2Ultra as a WebServer, but I got mine to work as a local website testing server with this reply.

I’m concerned about editing boot scripts though. Can you point me towards a bit more info on editing the .sh files? I guess my major question is: does init.sh control booting and clean.sh control shutting down? If that’s the case, I guess I would add the first command to init.sh and the second command to clean.sh. But again, I’m scared to edit those files…