Nas Apache Web Server



(20140208 – This post has been amended to provided an updated version of the Apache directive — iceflatline)

Over this past summer I had the pleasure of cobbling together a few spare parts in order to build a Network Attached Storage (“NAS”) box based on FreeNAS. This device has more than fulfilled my initial requirements for reliable file storage and media server in my network. This post will describe how I configured this FreeNAS box to store web files and serve as a document root for the Apache http server implemented in my Ubuntu server. This approach places my local web files on a solid, reliable and centralized RAID 5 disk storage system, and provides good logical and physical separation between file storage and file server functionality.

The versions for the software used in this post were as follows:

XigmaNAS is one of the best Linux NAS server solutions for open source enthusiasts. It offers a substantial list of modern-day features that make large-scale data management easier for people with limited or no exposure to NAS. It is based on the FreeNAS open source codebase and features the simplified BSD license. Apache HTTP Server 2.4.46 (httpd): 2.4.46 is the latest available version 2020-08-07.

Go into your nas Control Panel, and then into Web Services. Then check the box Enable Web Station. Web Server Host your own website No matter if it is a personal blog, company website, or e-commerce website, ASUSTOR NAS's Web Server function lets you host your very own website right on the NAS. Planning to add a Raid1 NAS to our home business development network. We have a web server (MAC1) serving the local network with files from its local hard drive. I want to move those files from its local drive to the NAS and serve web pages which then reside on the NAS.

  • FreeNAS v0.7.1 Shere (revision 5127)
  • Ubuntu Server v10.04 LTS (x64)
  • Apache v2.1.14
  • nfs-common v1:1.2.0-4ubuntu4
  • portmap v6.0.0-1ubuntu2

Configuring the FreeNAS Server

I began by creating the directory www on /mnt/files, an existing mount point. This directory would serve as my new Apache document root. Then, I enabled the Network File System (“NFS”) service in FreeNAS so that /mnt/files/www could be accessed from the Ubuntu server. To do this, navigate to Services->NFS->Settings and make sure that the check box for enabling NFS is checked and specify the number of servers that will run (the default value of four should easily handle dozens of users). Now select “Save and Restart.” Next, navigate to Services->NFS->Shares and select the “+” icon, where you are presented with the configuration screen for creating a new NFS share. Enter the path to be shared; the network that is authorized to access this shared path; and, make sure that the “All dirs” checkbox selected. The remaining options can retain their defaults (See Figure 1). Now select “Add” then “Apply changes.”

Configuring the Ubuntu Server

To configure the Ubuntu server I needed to add a couple of packages in order to mount the NFS shared path without error. The nfs-common package is needed when a host acts as an NFS client, and includes a number of processes that ensure a particular NFS connection is allowed and may proceed. Because NFS relies upon remote procedure calls to function, the package portmap is also needed to map RPC requests to the NFS service:

Next, I created a directory so I could mount the NFS shared path. Here you must include the IP address of the FreeNAS server as well as the directory created on it previously:

2
4
6
#Mount the FreeNAS directory /mnt/file/www for use as an Apache document root
192.168.10.5:/mnt/files/www/media/www nfs defaults00
###End iceflatline

I made sure the directory permissions were set correctly, and modified the owner and group associated with /media/www so that the Apache http server could access it:

2
4
6
8
10
#Alias and directive for FreeNAS directory /mnt/file/www
<Directory“/media/www>
AllowOverride None
</Directory>
###End iceflatline

I created an index.html file and moved it to /media/www to test the above configuration, and made sure the file permissions were set correctly: