[solved] Add Extra Storage to a web server

I'm setting up a web an Apache web server and would like 2 directors "/var/www/html/nextcloud" and "/var/www/html/storage" to be connected to a Hard Disk.

I have tried mounting the Hard Disk to the directory with fstab but I get an error 403 error.

I understand you can use a SymLink with Apache, but I cannot find any good guides.

Anyone got any ideas ?

Edit: I Believe the SymLink is the better option since Ubuntu already mounts the drives.

You use /var/www/html/nextcloud as a mount point for a partition on a hard drive which contains your nextcloud PHP scripts and such, no? And when you browse to this site, your web server returns a page: "403 Access Forbidden." Am I correct? There's another directory getting a similar treatment, but for simplicity I'd like to address just one directory. What's discovered for one is good for the other.

(Assuming I'm correct...)
1. This could mean the web server does not have read privileges to this hard drive. Usually, web servers runs as a process owned some low-privileged user, often with the username 'apache,' say. (a) Does apache own the directory /var/www/html/nextcloud, its contents and subdirectories? (b) Does apache at least have read privileges? investigate these questions after nounting the drive at the mount point.
2. You didn't happen to remove/delete index.php or index.html? Web servers also return 403 when they fail to locate an index document in the root document directory.
3. You're sure your hard drive successfully mounted at /var/www/html/nextcloud? For if the mount failed, the web server would have an empty mount point directory that it does not own, cannot access, and is certainly empty: all reasons for the web server to issue 403. Peek in your system log files and assure yourself that there are no mount failure messages there.
4. When the web server sends your browser a 403 Forbidden page, what is it writing in your server's access_log? What is it writing in its error log?
5. Yep. symlinks work. But the web server still needs to have read permission of the directories to which the symlinks points.
6. PHP logging anything interesting?

I'm Building a Single Board ARM Server (bananapi pro) to replace the current server (raspberry PI B). Im useing Lubuntu as the operating system

At the current moment only apache2 is installed. (and no drives have been mounted yet)

What I have Done so far

The first attempt i managed to mount the directory to the two locations , the first drive "/owncloud" would not display "index,php" or "Index.html". it would insted just desplay error 404 not found. the nextcloud directory would was shown in the apache2 directory but would just show error 404.

the storage directory had a error 403.

PHP and MySQL is fine since PHPmyAdmin Installed with no problems.

For some reason rebooting the system with the drives mounted in diffrent locations causes ubuntu to fail to boot. I'm not100% sure if the mounting causes it since it takes an long time to burn the image to an SD and setup the OS.

What i want to do is to make it so that i have extra srorage for when i setup nextcloud along with extra web storage for my website (in the storage directiory).

i cannot find any good guides on SymLink with Apache, or how to mount a disk to a directory with the correct permissions.

Here is my document root at example.com (obviously, an example):
-rw-r--r-- 1 apache apache 366 Apr 25 2016 index.html
lrwxrwxrwx 1 apache apache 38 Oct 13 2015 morestuff -> /media/bigfourterrabytedrive

I have placed a symbolic link (made via ln -s) in the document root directory. The symbolic link points to another directory situated on a device that has massive amounts of storage. The O/S mounts this massive drive automatically via an entry in /etc/fstab in a
standard Old School fashion so I won't show it.

I write in my favorite browser locator this URL http://example.com/morestuff/ with expectations of success, and not HTTP 403 Access Forbidden or some such.

First, I need to make sure my Apache server is permitted to follow symbolic links. So I define this for the document root:

 <Directory />
        Options FollowSymLinks
        ...
</Directory>

Of course, there are other matters I've defined about the document root, but this is the essential about the symbolic link bit. Most standard httpd.conf files that ship with apache probably have done this for you. Look in your own httpd.conf to be sure (location varies among distros).

Next, I have to ensure that the user under which the web server process runs is permitted to execute all of the directories in the chain leading to the target directory, viz:

 su chmod o+x /media /media/bigfourterrabytedrive

granting execute privileges to world along the entire chain of directories, not just the last one.

Now, since I didn't specify a particular resource when I gave that URL to my browser, the Apache web server assumes I want to look at a directory index. Therefore, to avoid the dreaded 403 on this front, I need to furnish something defaultish to serve up an index. So:

ls -l /media/bigfourterrabytedrive
...
-rw-r--r-- 1 apache apache    366 Nov 20  2016 index.html
...

but, it could also be index.php or any other file, so long as I've told the web server what kind of files function as indices. So somewhere else in http.conf

<IfModule dir_module>
    DirectoryIndex index.html index.php index.aspx
</IfModule>

About the environment: the Apache web server runs as an unprivileged user, apache and any file that I'd like Apache to serve up is usually owned by apache. There are exceptions:

ls -l /
...
drwxr-xr-x  12 root root     4096 Dec 31  2015 media
...

that is, the directory media in the chain toward bigfourterrabytedrive is owned by root, but world execute privileges has been granted on /media so the unprivileged user apache can execute /media whilst on its merry way to bigfourterrabytedrive

Well, I think this is what you need for what ails you, but it is still the wee hours here and I've been known to be mistaken in those hours. Then again, I've been known to be mistaken outside of those hours. Hope this helps.

1 Like

you cannot mount a drives partition to a directory that is not clean (where there is data). I accomplished the exact thing OP did because I have a 6 TiB drive mounted to /var/www/nextcloud. One the drive has been mounted, you then need to install nextcloud in that directory.

heres what my fstab looks like

luke@Sol:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/Sol--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sdb2 during installation
UUID=682577eb-e626-4ede-97fd-7ac0eda8facf /boot           ext2    defaults        0       2
# /boot/efi was on /dev/sdb1 during installation
UUID=D569-EFF9  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/Sol--vg-swap_1 none            swap    sw              0       0

#where nextcloud will go
UUID=e8a39afc-4998-47d0-b9ef-c17bf8eda1e2	/var/www/nextcloud	btrfs	defaults	0	0

and then lsblk

NAME               MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                  8:0    0   5.5T  0 disk 
└─sda1               8:1    0   5.5T  0 part /var/www/nextcloud

Lastly, heres what my entry in apache looks like.

luke@Sol:/etc/apache2/sites-available$ cat nextcloud.conf 
Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All

    <IfModule mod_dav.c>
        Dav off
    </IfModule>

    SetEnv HOME /var/www/nextcloud
    SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

<VirtualHost *:80>
   ServerName website.net/nextcloud
   Redirect permanent / https://website.net/nextcloud
</VirtualHost>

<VirtualHost *:443>
  ServerName website.net/nextcloud
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
    </IfModule>
 </VirtualHost>

You need to make sure you install nextcloud properly. I heavily recommend this guide from digital ocean. It is for Ubuntu 16.04 but it work just the same for you. Permissions are important. Also, when it directs you to use the script that automates setting all the permissions its okay to do so but at the end you will need to remove the /assets directory as it is no longer used by nextcloud and will cause errors when you try upgrade.

2 Likes

Are you trying to have the 2nd hard disk as the primary storage or additional storage?

If you want to make it primary storage, the easiest method is just to move the data directory into the 2nd hard disk and edit the config.php to point to it.

I'm not sure if this is a bug in Lbuntu, but if set the Drives to auto mount the OS dose not boot after reboot.

The OS boots as normal then stops

Boot Screen
* Starting configure network device security _______ [ok]
* Starting configure network device_________________ [ok]
* Starting configure network device security _______ [ok]
* Starting configure network device security _______ [ok]
* Starting configure network device_________________ [ok]
* Starting Mount network file system________________ [ok]
* Starting Mount network file system________________ [ok]
* Starting configure network device_________________ [ok]
* Starting configure network device security _______ [ok]
* Starting configure network device_________________ [ok]
* Starting Bridge socket events into upstart _______ [ok]
_
Freezes at this point

Anyone got any ideas why its doing this

Also removing the drive dose not solve the problem.

Can you post the full boot log?

I don't know how to do this on lubuntu. Otherwise I would give directions on viewing the boot log.

I have made a new topic here since its a different problem

1 Like

Odd... The reproduction of /var/log/boot.log here is not the same as the one presented at Lubuntu Fails to Boot after mounting drive. The log here cuts off at line 18 Stopping Mount files.... Apart from that, the first 17 lines of both presentations are identical. To ease interpretive strain, I've taken the liberty of inserting line endings and removing the fragmentary terminal escape sequences which, once upon a time, turned the '[OK]' bits green. Here is /var/boot/boot.log, tidied up a bit:

* Starting Mount filesystems on boot [ OK ]
* Starting Signal sysvinit that the rootfs is mounted [ OK ]
* Starting Populate /dev filesystem [ OK ]
* Stopping Populate /dev filesystem [ OK ]
* Starting Fix-up /sys/kernel/debug filesystem [ OK ]
* Stopping Fix-up /sys/kernel/debug filesystem [ OK ]
* Starting Clean /tmp directory [ OK ]
* Starting Populate and link to /run filesystem [ OK ]
* Stopping Clean /tmp directory [ OK ]
* Stopping Populate and link to /run filesystem [ OK ]
* Stopping Track if upstart is running in a container [ OK ]
* Starting Initialize or finalize resolvconf [ OK ]
* Starting Signal sysvinit that virtual filesystems are mounted [ OK ]
* Starting Signal sysvinit that virtual filesystems are mounted [ OK ]
* Starting Bridge udev events into upstart [ OK ]
* Starting Signal sysvinit that local filesystems are mounted [ OK ]
* Starting Signal sysvinit that remote filesystems are mounted [ OK ]
* Stopping Mount filesâ€

Now, using <pre> markup, it becomes apparent that line eighteen of the version of /var/log/boot.log given here includes a spurt of random bytes as the logger went off the rails.

However, the version of /var/log/boot.log presented over at the other post runs on for a further 48 lines of reporting, announcing such matters as SystemD stopping "Send an event to indicate plymouth is up." Well, plymouth is the login manager, and the login manager appears multiple seconds after the kernel boot, when user space is well nigh complete.

Dear @Infinatum, I very much fear that you will enlist but little assistance with a post entitled "Lubuntu Fails To Boot after mounting drive" when the primary evidence of "boot failure" is a log that very much shows a nearly -- if not wholly -- complete system start up (including the mounting of local drives). I presume the one posted over there was a inadvertent mistake and am sad about the confusion it will elicit.

In light of that, you really should edit the post over there to include this /var/boot/boot.log instead, which actually indicates a catastrophe of some sort.

Now the real question is the nature of the catastrophe, occurring just as SystemD was announcing the completion of the rootfs-local-remote cluster of file system mountings. Be nice to get a dmesg at that point, but maybe the box is freezing in a kernel panic. Does lubuntu allow one to step through SystemD interactively...?

That could be a three pipe problem...

EDIT: This post mostly stricken because I believe @Infinatum has nicely edited out the confusing aspects. I am leaving my copy of his /var/boot/boot.log that was originally posted by him here because it shows a point of failure, useful for spelunking the matter.

Thanks for the Helpful Guide. I know have the drive ready for next cloud to be installed.

Thanks again for the help. That next cloud guide will be useful.