My Cloud local web server setup

#1

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?

#2

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.

#3

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.

#4

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

1 Like
#5

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!

#6

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.

#7

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?

#8

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?

#9

do you have more details?

#10

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?

#11

Hey, did you managed to settle this?
i’m also on the same path as you did.

i managed to get it working until i noticed every changes i made in the page or files added requires me to update the symlink again manually.

is there anyway to do it automatically? or triggered by cron or something?
currently i’m using wordpress to trigger the sh command.

#12

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
#13

Thanks. i assumed i would still need to do this before the ln code.

mkdir -p /var/www/nefs

#14

will that update every files and sub folders inside automatically?

#15

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.

#16

You have docker to pull in all these dependencies though.

#17

ok, i’m actually coding my own website.
is there anyway to setup independent task to execute shell command?
what i would like to know is, how does the Wordpress get to execute the init.sh and clean.sh?
Is there away i can also make my own init.sh and get the system to execute it?
Also what if i would like to have an update.sh? where to trigger that?

#18

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.