Difference between revisions of "How to forge a local file system server with IGEPv2 Board"

From IGEP - ISEE Wiki

Jump to: navigation, search
 
(123 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
=== Objectives  ===
 
=== Objectives  ===
  
This project aims to create a local file system server using ARM Platform. It is very useful for this purpose for the next reasons:
+
This project aims to create a local file system server using ARM Platform. It is very useful for this purpose for the next reasons:  
  
-ARM is designed for low power consumption. This server should be connected to power supply all the day, if you use this architecture you can lower your electric bill.
+
*ARM is designed for low power consumption. This server should be connected to power supply all the day, if you use this architecture, you can lower your electric bill.
 +
*ARM-Embedded is usually cheaper than a X86-Embedded processor.
 +
*If you have a good internet broadband connection, is not difficult to configure your server to accept external http requests.
 +
*Your data are 100% under your control, other services you don't know where are your files.
 +
*Commercial services offer premium accounts with extra hard disk space, in this project you can use all the space as your HD or SD supports.
  
-ARM-Embedded is usually cheaper than a X86-Embedded processor.
+
<br> When you finish this how-to, you will have your own local web service similar than Dropbox and SugarSync. Your service will powered by [http://www.owncloud.org Owncloud.org] software. I used for this tutorial Owncloud 3 alpha 1 release to prove all new characteristics, but you can follow this tutorial using the stable version, there characteristics are: File management, WebDAV access, sharing, music streaming, calendar, contacts, users &amp; groups, image gallery, online text editor, online task manager and bookmarks. For more information go to [http://www.owncloud.org Owncloud.org] page.
  
-If you have a good internet broadband, is not difficult to configure your server to accept external http request.
+
=== Limitations  ===
  
-Your data are 100% under your control, other services you don't know where are your files.
+
When i finished this project, i tested the system performance making some tests. After this i did the next conclusions:
  
-Commercial services offer premium accounts with extra hard disk space, in your server you can use all the space as your HD or SD supports.  
+
*If you upload a folder with more than 100 files, i recommend that you compress it before the upload.
 +
*Don't compress via Web a folder large than 100 MB, use WebDAV for download it.
 +
*Don't upload more than 750 MB via Web, use WebDAV for this purpose.<br>
 +
*The Web uses HTML5 technology, it tested with Firefox 7, Google Chrome 14 browser and mobile phone with IOS 4.3.3. Older browsers maybe have problems.
  
<br> When you finish this how-to, you will have your own local web service similar than Dropbox and SugarSync. Your service will powered by [http://www.owncloud.org Owncloud.org] software. I used for this tutorial Owncloud 3 alpha 1 release to prove all new characteristics, but you can follow this tutorial using the stable version. There characteristics are: File management, WebDAV access, sharing, music streaming, calendar, contacts, users &amp; groups, image gallery, online text editor, online task manager and bookmarks. For more information go to [http://www.owncloud.org Owncloud.org] page.
+
= Hardware Used  =
  
=== Limitations ===
+
The hardware used for this project is:
 +
 
 +
*[https://www.isee.biz/products/igep-processor-boards/igepv2-dm3730 IGEPv2 Board]
 +
*5 V power supply.
 +
*MicroSD card 2GB at least with SD card adapter.
 +
*IGEPv2 Serial Debug cable (it isn't necessary later).
 +
*Ethernet cable.
 +
*Switch or Router.<br>
 +
*External USB Hard Disk with USB&nbsp;cable.<br>
 +
 
 +
= Software Used  =
 +
 
 +
I used the following software:
 +
 
 +
*[http://releases.linaro.org/platform/linaro-m/headless/final/linaro-m-headless-tar-20101108-2.tar.gz Linaro Headless]
 +
*[http://gparted.sourceforge.net/ Gparted]
 +
*[http://downloads.isee.biz/pub/releases/IGEP_xloader/igep-x-loader-2.4.0-2.tar.bz2 igep-x-loader-2.4.0-2.tar.bz2]
 +
*[http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud Owncloud software]
 +
*[http://labs.igep.es/index.php/Linux_Kernel_2.6.35.y Kernel 2.6.35.y]
 +
*[http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29 LAMP]
 +
*[http://www.openssh.com/ OpenSSH Server]
 +
'''NOTE:''' Tested using Owncloud version 2
 +
 
 +
= Installing Linaro Headless  =
 +
 
 +
Use this [http://labs.igep.es/index.php/How_to_boot_from_MicroSD_Card tutorial](microSD) and this [http://labs.igep.es/index.php/The_IGEP_X-loader other](IGEPxloader) to install Linaro Headless in your SD card. It runs well with the software detailed above.&nbsp; You can compile the IGEPxloader and Kernel, but is not necessary.
 +
 
 +
'''NOTE: '''Use FAT16 for boot partition and EXT3 for rootfs partition.
 +
 
 +
Create a new plan text file into the boot partition named igep.ini with these content and save it.
 +
<pre>[kernel]
 +
; Kernel load address, NOT Modify
 +
kaddress=0x80008000
 +
; RAM disk load Address, NOT Modify
 +
;rdaddress=0x84000000
 +
; Board Serial ID
 +
serial.low=00000001
 +
serial.high=00000000
 +
; Board Revision
 +
revision=0003
 +
; Kernel Image Name
 +
kImageName=zImage
 +
; Kernel RAM Disk Image Name
 +
;kRdImageName=initrd.img-2.6.35-1010-linaro-omap
 +
MachineID=2344
 +
; Where Machine ID = 2344 for IGEPv2 and ID = 2717 for IGEP Module
 +
 +
[kparams]
 +
;buddy=igep0022
 +
;buddy=base0010
 +
; Setup the Kernel console params
 +
console=ttyS2,115200n8
 +
; Enable early printk
 +
;earlyprintk=serial,ttyS2,115200
 +
; Setup the Board Memory Configuration
 +
;mem=430M
 +
mem=512M
 +
; Setup the Boot Delay
 +
boot_delay=0
 +
; Setup the ARM Processor Speed
 +
;mpurate=800
 +
; Setup the loglevel
 +
;loglevel=7
 +
; Enable Kernel Debug Output
 +
;debug=1
 +
; Fix RTC Variable
 +
;fixrtc=1
 +
; Configure nocompcache variable
 +
nocompcache=1
 +
; Configure Frame Buffer Configuration
 +
;omapfb.mode=dvi:1280x720MR-16@60
 +
;omapfb.mode=dvi:hd720-16@60
 +
; Configure Video Ram assigned
 +
vram=40M
 +
; Configure Video RAM assigned to every frame buffer
 +
omapfb.vram=0:12M,1:16M,2:12M
 +
; Configure frame buffer debug output
 +
;omapfb.debug=1
 +
; Configure DSS Video Debug option
 +
;omapdss.debug=1
 +
; Configure the Board Ethernet Mac Address
 +
smsc911x.mac=0xb2,0xb1,0x1f,0xb5,0xcd,0xdf
 +
; --- Configure UBI FS boot ---
 +
;ubi.mtd=2
 +
;root=ubi0:igep0020-rootfs
 +
;rootfstype=ubifs
 +
;  --- Configure NFS boot ---
 +
;ip=192.168.2.123:192.168.2.129:192.168.2.1:255.255.255.0::eth0:
 +
;root=/dev/nfs
 +
;nfsroot=192.168.2.129:/srv/nfs/igep_rootfs
 +
;  --- Configure MMC boot ---
 +
root=/dev/mmcblk0p2 rw rootwait
 +
; Assign Init program
 +
;init=/bin/bash
 +
</pre>
 +
NOTE: Check MAC address is not used for avoid conflicts.<br>
 +
 
 +
= Set up internet connection  =
 +
 
 +
Login as root via serie, and use "vi" editor to add the following lines to<span class="st"> the bottom of </span>/etc/network/interfaces
 +
<pre>auto eth0
 +
iface eth0 inet dhcp
 +
</pre>
 +
NOTE: Some routers give a static IP&nbsp;via Dhcp identifying the MAC&nbsp;address, others give a free IP when we send Dhcp request. Also you can configure /etc/network/interfaces to get a static IP with the following lines:
 +
<pre>auto eth0
 +
iface eth0 inet static
 +
address &lt;type your address&gt;
 +
netmask &lt;normally: 255.255.255.0&gt;
 +
gateway &lt;where send Dhcp request&gt;
 +
</pre>
 +
Save changes and restart the system with via "reboot" command. <br> After reboot, if you don't know private ip of your server, find it typing:
 +
<pre>ifconfig
 +
</pre>
 +
Search in eth0: "inet addr:X.X.X.X", where X.X.X.X is the private IP server.
 +
 
 +
Test your server connection sending a ping request:
 +
<pre>ping X.X.X.X
 +
</pre>
 +
After this, upgrade your system via "apt-get".
  
When i finished this project, i tested the system performance making some tests. After this i did the next conclusions:
+
= Installing Open SSH Server  =
  
- If you upload a folder with more than 100 files, i recommend that you compress it before the upload.  
+
Login as root via serie, type:
 +
<pre>apt-get install openssh-server
 +
</pre>
 +
Change root password typing:<br>
 +
<pre>passwd root
 +
</pre>
 +
Enter new password, i recommend use letters, numbers and symbols like:?¿!...  
  
- Don't compress via Web a folder large than 100 MB, use WebDAV for download it.  
+
Search in eth0: inet addr:X.X.X.X, where X.X.X.X is the server private IP. We are going to prove it login as root via ssh:
 +
<pre>ssh root@X.X.X.X
 +
</pre>
 +
Now we be able to connect to server via SSH, using the password typed above.  
  
- Don't upload more than 750 MB via Web, use WebDAV for this purpose.<br>
+
The next steps are not necessary use serial communication .  
  
- The Web uses HTML5 technology, it tested with Firefox 7 and Chromium 14 browser and mobile phone with IOS 4.3.3. Older browsers maybe have problems.
+
= Creating and editing Server Users  =
  
= Hardware Used  =
+
Using root user can be dangerous, for this reason we are going to create a new user named adminserver to access server. Create new user typing:<br>
 +
<pre>adduser adminserver
 +
The next steps are not necessary use serial communication . </pre>
 +
Follow the assistant entering a password and your user data.
  
The hardware used for this project is:  
+
Once adminserver user was create, we are going to give sudoers privileges. Type:  
 +
<pre>visudo
 +
</pre>
 +
Go to: # User privilege specification, and add below: <br>
 +
<pre>adminserver ALL=(ALL) ALL
  
- IGEPv2 Board Revision C with 1 GHz Processor and 512MB Ram.  
+
Defaults:adminserver    timestamp_timeout=0, runaspw, passwd_tries=1
 +
</pre>
 +
The first line says that adminserver user can access like root with sudo command.  
  
- 5 V power supply.  
+
The second line, configure some paremetres to adminserver sudo access: adminserver needs root's password to run sudo (runaspw), the password will not be remembered (timestamp_timeout) and he gets only one chance to enter it (passwd_tries).<br>NOTE: Is important use visudo editor because it can detect spelling errors before write sudoers file.<br>
  
- MicroSD card 2GB at least with SD card adapter.
+
= Installing LAMP  =
  
- IGEPv2 Serial Debug cable, it isn't necessary later.
+
=== Apache  ===
  
- Ethernet cable.
+
The Apache HTTP Server is an open-source HTTP server for modern operating systems including UNIX, Microsoft Windows, Mac OS/X and Netware.  
  
- Switch or Router.<br>
+
We are going to install it:
 +
<pre>sudo apt-get install apache2 apache2-mpm-prefork</pre>
 +
After installation, we are going to make some configurations:
 +
<pre>mkdir /home/adminserver/web/</pre>  
 +
We create that folder called web to store all the web files.
  
- External USB Hard Disk with USB&nbsp;cable.<br>
+
Now we are going to change some basic Apache configuration, edit: /etc/apache2/sites-available/default
  
= Software Used  =
+
Search line:
 +
<pre>DocumentRoot /var/www/</pre>
 +
Replace by:
 +
<pre>DocumentRoot /home/&lt;user&gt;/web/</pre>
 +
DocumentRoot is the root folder that contains our web pages.
  
I used a laptop with ubuntu 10.04 environtment, <br>
+
Search line:
 +
<pre>Directory /var/www/
  
 +
Options Indexes FollowSymLinks MultiViews</pre>
 +
Replace by:
 +
<pre>Directory /home/&lt;user&gt;/web/
  
 +
Options FollowSymLinks</pre>
 +
For security reasons, we are going to hide our files and folders.
  
Under contruction
+
Search line:
 +
<pre>AllowOverride None</pre>
 +
Replace by:
 +
<pre>AllowOverride all</pre>
 +
Allows a file .htaccess to override the options for the respective directory
  
= Installing Linaro Headless =
+
Save and exit.
  
Under construction
+
Add the following lines to the bottom of /etc/apache2/apache2.conf
 +
<pre>ServerSignature Off
 +
ServerTokens Prod</pre>
 +
For security reasons, this lines hide the version of Apache and Linux Distro.
  
= Set up internet connection =
+
Restart Apache:
 +
<pre>sudo /etc/init.d/apache2 restart</pre>
 +
Now we have a Apache with basic improved configuration.<br>
  
Under construction
+
=== PHP  ===
  
= Creating and editing Server Users =
+
Now we are going to install, the required packages to run Owncloud, if you want to install more Webs like Wordpress, Joomla, etc. Maybe you need install others. Type:
 +
<pre>sudo apt-get install php5 php5-sqlite php5-common
 +
</pre>
 +
Restart Apache:
 +
<pre>sudo /etc/init.d/apache2 restart</pre>
 +
=== MySQL + PHPmyAdmin  ===
 +
<pre>sudo apt-get install mysql-server mysql-client phpmyadmin</pre>
 +
When we are installing MySQL, we configure it entering password for root MySQL database. Also when we are installing phpmyadmin we should choose: configure database for phpmyadmin with dbconfig-common, type root MySQL password again,&nbsp; type phpmyadmin password database and choose apache2 confiuration .<br>
  
Under construction
+
Restart Apache:
 +
<pre>sudo /etc/init.d/apache2 restart</pre>
 +
Make a simbolic link to phpmyadmin:<br>
 +
<pre>sudo ln -s /usr/share/phpmyadmin /home/adminserver/web/phpmyadmin</pre>
 +
With phpmyadmin you can handle your mysql databases (managing databases, tables, fields, relations, indexes, users, permissions, etc) via web browser. It is useful for Owncloud or another program than uses MySQL.<br>
  
= Installing Open SSH Server =
+
= Enabling Automatic Updates  =
  
Under construction
+
Automatic updates can be used to automatically install updated packages. You can configure it to update all packages or just security packages. Install the following package:<br>
 +
<pre>sudo apt-get install unattended-upgrades
 +
</pre>
 +
To configure <span class="application">unattended-upgrades</span>, edit:/etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs: <br>
  
= Installing LAMP  =
+
The double “//” serve as comments, so whatever follows "//" will not be evaluated. Coment/uncoment the repositoris that you prefe, i recommend this configuration:
 +
<pre>Unattended-Upgrade::Allowed-Origins {
 +
        "${distro_id} stable";
 +
        "${distro_id} ${distro_codename}-security";
 +
//      "${distro_id} ${distro_codename}-updates";
 +
//      "${distro_id} ${distro_codename}-proposed-updates";
 +
};
 +
</pre>
 +
You can blacklisted some packeges, you can enable automatic removes, autoremove orphans packages,etc.
  
=== Apache  ===
+
To set everything first create a file: /etc/apt/apt.conf.d/10periodic and edit it with your favorite editor, my configuration is:
 +
<pre>APT::Periodic::Update-Package-Lists "1";
 +
APT::Periodic::Download-Upgradeable-Packages "1";
 +
APT::Periodic::AutocleanInterval "7";
 +
APT::Periodic::Unattended-Upgrade "1";
 +
</pre>
 +
The above configuration updates the package list, downloads, and installs available upgrades every day. The local download archive is cleaned every week.
  
Under construction
+
For more information go to [https://help.ubuntu.com/12.04/serverguide/automatic-updates.html here.]
  
=== PHP ===
+
= Set up a External HD  =
  
Under construction
+
External HD is useful to get more space for our project. In this part we are going to set up our HD when it is connected to server.
  
=== MySQL  ===
+
Format your HD with a EXT3 Filesystem.
  
Under construction
+
Create the following script: /etc/udev/rules.d/50-mount-external.rules, and paste this:
 +
<pre>KERNEL!= "sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
  
=== PHPmyAdmin  ===
+
# Import FS infos
 +
IMPORT{program}="/sbin/blkid -o udev -p&nbsp;%N"
  
Under construction
+
# Get a label if present, otherwise specify one
 +
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
 +
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
  
= Enabling Automatic Updates =
+
# Global mount options
 +
ACTION=="add", ENV{mount_options}="relatime"
 +
# Filesystem-specific mount options
 +
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
  
Under construction
+
# Mount the device
 +
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
  
= Set up a External HD =
+
# Clean up after removal
 +
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
  
Under construction
+
# Exit
 +
LABEL="media_by_label_auto_mount_end"
 +
</pre>
 +
Stop/start the udev deamon:
 +
<pre>/etc/init.d/udev stop
 +
/etc/init.d/udev start
 +
</pre>
 +
Connect your HD to server. Use "mount" command to see External HD information.
 +
<pre>/dev/root on / type ext3 (rw)
 +
none on /proc type proc (rw,noexec,nosuid,nodev)
 +
none on /sys type sysfs (rw,noexec,nosuid,nodev)
 +
none on /sys/kernel/debug type debugfs (rw)
 +
none on /dev type tmpfs (rw,mode=0755)
 +
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
 +
none on /dev/shm type tmpfs (rw,nosuid,nodev)
 +
none on /var/run type tmpfs (rw,nosuid,mode=0755)
 +
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
 +
/dev/sda1 on /media/usbhd-sda1 type ext3 (rw,relatime)
 +
</pre>
 +
Where our HD isi mounted in media folder, and its name is u"sbhd-sda1"
  
 
= Set up Owncloud.org Software  =
 
= Set up Owncloud.org Software  =
Line 101: Line 323:
 
=== Installing Owncloud.org  ===
 
=== Installing Owncloud.org  ===
  
Under construction
+
Owncloud software need some extra packages:<br>
  
=== Configuring Owncloud.org ===
+
For improved scanning of music files:
 +
<pre>sudo apt-get install mp3info
 +
</pre>
 +
For downloading multiple files:
 +
<pre>sudo apt-get install zip
 +
</pre>
 +
For the OpenID plugin
 +
<pre>sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
 +
</pre>
 +
This how-to uses the lastest release of Ownlcoud but if you use stable version it would be similar. Download Owncloud in your root Apache folder.
 +
<pre>sudo apt-get install wget
 +
cd /home/adminserver/web/
 +
wget http://gitorious.org/owncloud/owncloud/archive-tarball/master
 +
</pre>
 +
Uncompres it:
 +
<pre>tar -zxvf master
 +
</pre>
 +
Make Root file folder in External HD:
 +
<pre>cd /media/usbhd-sda1
 +
sudo mkdir DATA
 +
sudo chown -R www-data:www-data DATA
 +
</pre>
 +
Make ownCloud directory accessible to Apache:
 +
<pre>cd /home/adminserver/web/
 +
sudo chown -R www-data:www-data owncloud-owncloud/
  
Under construction
+
</pre>
 +
The estable version, the folder is named owncloud. [[Image:Previewowncloudinstallation1.png|right|331px]]
 +
 
 +
Open your web browser and finish your Owncloud installation. Go to: http://&lt;IP PRIVATE SERVER&gt;/owncloud-owncloud/ Put your personal information and select MySQL Database. once finish, click Finish Setup. <br><br><br><br><br><br><br>
  
 
=== Configuring Apache and PHP for Owncloud  ===
 
=== Configuring Apache and PHP for Owncloud  ===
  
Under construction
+
PHP and Apache have a standard configuration, we need to change it to improve performance&nbsp; of our project and server.<br>
 +
 
 +
Edit &lt;span style="font-family: monospace;" /&gt;/etc/apache2/apache2.conf
 +
<pre>LockFile ${APACHE_LOCK_DIR}/accept.lock
 +
PidFile ${APACHE_PID_FILE}
 +
Timeout 700
 +
KeepAlive On
 +
MaxKeepAliveRequests 500
 +
KeepAliveTimeout 600
 +
&lt;IfModule mpm_prefork_module&gt;
 +
    StartServers          5
 +
    MinSpareServers      5
 +
    MaxSpareServers      10
 +
    MaxClients          10
 +
    MaxRequestsPerChild  0
 +
&lt;/IfModule&gt;
 +
&lt;IfModule mpm_worker_module&gt;
 +
    StartServers          2
 +
    MinSpareThreads      25
 +
    MaxSpareThreads      75
 +
    ThreadLimit          64
 +
    ThreadsPerChild      25
 +
    MaxClients          10
 +
    MaxRequestsPerChild  0
 +
&lt;/IfModule&gt;
 +
&lt;IfModule mpm_event_module&gt;
 +
    StartServers          2
 +
    MaxClients          10
 +
    MinSpareThreads      25
 +
    MaxSpareThreads      75
 +
    ThreadLimit          64
 +
    ThreadsPerChild      25
 +
    MaxRequestsPerChild  0
 +
&lt;/IfModule&gt;
 +
User ${APACHE_RUN_USER}
 +
Group ${APACHE_RUN_GROUP}
 +
AccessFileName .htaccess
 +
&lt;Files ~ "^\.ht"&gt;
 +
    Order allow,deny
 +
    Deny from all
 +
    Satisfy all
 +
&lt;/Files&gt;
 +
DefaultType text/plain
 +
HostnameLookups Off
 +
ErrorLog ${APACHE_LOG_DIR}/error.log
 +
LogLevel warn
 +
Include mods-enabled/*.load
 +
Include mods-enabled/*.conf
 +
Include httpd.conf
 +
Include ports.conf
 +
LogFormat "%v:%p&nbsp;%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
 +
LogFormat "%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O \"%{Referer}i\" \"%{User-Agent}i\"" combined
 +
LogFormat "%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O" common
 +
LogFormat "%{Referer}i -&gt;&nbsp;%U" referer
 +
LogFormat "%{User-agent}i" agent
 +
Include conf.d/
 +
Include sites-enabled/
 +
ServerSignature Off
 +
ServerTokens Prod
 +
</pre>
 +
I reduce the number of clients and increased the persistent connection time.
 +
 
 +
Edit: /etc/php5/apache2/php.ini.<br>
 +
<pre>max_file_uploads = 20            max_file_uploads = 100
 +
upload_max_filesize = 2M        upload_max_filesize = 750M
 +
post_max_size = 8M              post_max_size = 800M
 +
default_socket_timeout = 60      default_socket_timeout = 600
 +
max_execution_time = 30          max_execution_time = 500
 +
max_input_time = 60              max_input_time = 600
 +
memory_limit = 128M              memory_limit = 1025M
 +
mysql.connect_timeout = 60      mysql.connect_timeout = 600</pre>
 +
I configure it for a local connection.
 +
 
 +
Edit Owncloud .htaccess and erase the following lines:
 +
<pre>php_value upload_max_filesize 512M
 +
php_value post_max_size 512M
 +
</pre>
 +
Now .htacces don't limit the upload filesize and post size.
 +
 
 +
Restart Apache service:
 +
<pre>sudo /etc/init.d/apache2 restart
 +
</pre>
 +
=== Configuring WebDAV for Owncloud  ===
 +
 
 +
Owncloud development team are creating a native client to manage files more easyly, but is not release yet. Although we can set up a WebDAV protocol to solve it. I tested with a Ubuntu 10.04 laptop, but can be use in other paltforms, see this [http://owncloud.org/use/webdav/ page] for more information.<br>
 +
 
 +
Install the WebDAV support:
 +
<pre>sudo apt-get install davfs2
 +
</pre>
 +
Reconfigure davfs2 to allow access to normal users:
 +
<pre>&lt;code&gt;sudo dpkg-reconfigure davfs2&lt;/code&gt;
 +
</pre>
 +
Select ''Yes'' when prompted
 +
 
 +
Add the users you want to be able to mount the share to the <code></code>davfs2 group:
 +
<pre>sudo usermod -aG davfs2 &lt;userclient&gt;
 +
</pre>
 +
Edit /etc/fstab, and add the following line for each user who wants to mount the folder (with your details where appropriate)
 +
<pre>http://&lt;IPPRIVATE&gt;/owncloud-owncloud/files/webdav.php /home/&lt;username&gt;/owncloud davfs user,rw,noauto 0 0
 +
</pre>
 +
Create the folders owncloud &amp; .davfs2 in your home directory Create the file named secrets inside .davfs2 folder, fill it with the following (with your credentials where appropriate)
 +
<pre>http://&lt;IPPRIVATE&gt;/owncloud-owncloud/files/webdav.php &lt;yourowncloudusername&gt; &lt;yourowncloudpassword&gt;
 +
</pre>
 +
Ensure the file is only writable by you either through the file manager:
 +
<pre>chmod 600 ~/.davfs2/secrets
 +
</pre>
 +
Mount your Virtual Owncloud Hardrive with the command: mount ~/owncloud You can automatically mount the folder on login, add the last command to ~/.bashrc
 +
 
 +
[[Category:Tutorials]]

Latest revision as of 13:47, 15 June 2015

Introduction

Objectives

This project aims to create a local file system server using ARM Platform. It is very useful for this purpose for the next reasons:

  • ARM is designed for low power consumption. This server should be connected to power supply all the day, if you use this architecture, you can lower your electric bill.
  • ARM-Embedded is usually cheaper than a X86-Embedded processor.
  • If you have a good internet broadband connection, is not difficult to configure your server to accept external http requests.
  • Your data are 100% under your control, other services you don't know where are your files.
  • Commercial services offer premium accounts with extra hard disk space, in this project you can use all the space as your HD or SD supports.


When you finish this how-to, you will have your own local web service similar than Dropbox and SugarSync. Your service will powered by Owncloud.org software. I used for this tutorial Owncloud 3 alpha 1 release to prove all new characteristics, but you can follow this tutorial using the stable version, there characteristics are: File management, WebDAV access, sharing, music streaming, calendar, contacts, users & groups, image gallery, online text editor, online task manager and bookmarks. For more information go to Owncloud.org page.

Limitations

When i finished this project, i tested the system performance making some tests. After this i did the next conclusions:

  • If you upload a folder with more than 100 files, i recommend that you compress it before the upload.
  • Don't compress via Web a folder large than 100 MB, use WebDAV for download it.
  • Don't upload more than 750 MB via Web, use WebDAV for this purpose.
  • The Web uses HTML5 technology, it tested with Firefox 7, Google Chrome 14 browser and mobile phone with IOS 4.3.3. Older browsers maybe have problems.

Hardware Used

The hardware used for this project is:

  • IGEPv2 Board
  • 5 V power supply.
  • MicroSD card 2GB at least with SD card adapter.
  • IGEPv2 Serial Debug cable (it isn't necessary later).
  • Ethernet cable.
  • Switch or Router.
  • External USB Hard Disk with USB cable.

Software Used

I used the following software:

NOTE: Tested using Owncloud version 2

Installing Linaro Headless

Use this tutorial(microSD) and this other(IGEPxloader) to install Linaro Headless in your SD card. It runs well with the software detailed above.  You can compile the IGEPxloader and Kernel, but is not necessary.

NOTE: Use FAT16 for boot partition and EXT3 for rootfs partition.

Create a new plan text file into the boot partition named igep.ini with these content and save it.

[kernel]
; Kernel load address, NOT Modify
kaddress=0x80008000
; RAM disk load Address, NOT Modify
;rdaddress=0x84000000
; Board Serial ID
serial.low=00000001
serial.high=00000000
; Board Revision
revision=0003
; Kernel Image Name
kImageName=zImage
; Kernel RAM Disk Image Name
;kRdImageName=initrd.img-2.6.35-1010-linaro-omap
MachineID=2344
; Where Machine ID = 2344 for IGEPv2 and ID = 2717 for IGEP Module
 
[kparams]
;buddy=igep0022
;buddy=base0010
; Setup the Kernel console params
console=ttyS2,115200n8
; Enable early printk
;earlyprintk=serial,ttyS2,115200
; Setup the Board Memory Configuration
;mem=430M
mem=512M
; Setup the Boot Delay
boot_delay=0
; Setup the ARM Processor Speed
;mpurate=800
; Setup the loglevel
;loglevel=7
; Enable Kernel Debug Output
;debug=1
; Fix RTC Variable
;fixrtc=1
; Configure nocompcache variable
nocompcache=1
; Configure Frame Buffer Configuration
;omapfb.mode=dvi:1280x720MR-16@60
;omapfb.mode=dvi:hd720-16@60
; Configure Video Ram assigned
vram=40M
; Configure Video RAM assigned to every frame buffer
omapfb.vram=0:12M,1:16M,2:12M
; Configure frame buffer debug output
;omapfb.debug=1
; Configure DSS Video Debug option
;omapdss.debug=1
; Configure the Board Ethernet Mac Address
smsc911x.mac=0xb2,0xb1,0x1f,0xb5,0xcd,0xdf
;  --- Configure UBI FS boot --- 
;ubi.mtd=2 
;root=ubi0:igep0020-rootfs 
;rootfstype=ubifs
;  --- Configure NFS boot --- 
;ip=192.168.2.123:192.168.2.129:192.168.2.1:255.255.255.0::eth0:
;root=/dev/nfs
;nfsroot=192.168.2.129:/srv/nfs/igep_rootfs
;  --- Configure MMC boot --- 
root=/dev/mmcblk0p2 rw rootwait
; Assign Init program
;init=/bin/bash

NOTE: Check MAC address is not used for avoid conflicts.

Set up internet connection

Login as root via serie, and use "vi" editor to add the following lines to the bottom of /etc/network/interfaces

auto eth0
iface eth0 inet dhcp

NOTE: Some routers give a static IP via Dhcp identifying the MAC address, others give a free IP when we send Dhcp request. Also you can configure /etc/network/interfaces to get a static IP with the following lines:

auto eth0
iface eth0 inet static
address <type your address>
netmask <normally: 255.255.255.0>
gateway <where send Dhcp request>

Save changes and restart the system with via "reboot" command.
After reboot, if you don't know private ip of your server, find it typing:

ifconfig

Search in eth0: "inet addr:X.X.X.X", where X.X.X.X is the private IP server.

Test your server connection sending a ping request:

ping X.X.X.X 

After this, upgrade your system via "apt-get".

Installing Open SSH Server

Login as root via serie, type:

apt-get install openssh-server

Change root password typing:

passwd root

Enter new password, i recommend use letters, numbers and symbols like:?¿!...

Search in eth0: inet addr:X.X.X.X, where X.X.X.X is the server private IP. We are going to prove it login as root via ssh:

ssh root@X.X.X.X

Now we be able to connect to server via SSH, using the password typed above.

The next steps are not necessary use serial communication .

Creating and editing Server Users

Using root user can be dangerous, for this reason we are going to create a new user named adminserver to access server. Create new user typing:

adduser adminserver
The next steps are not necessary use serial communication . 

Follow the assistant entering a password and your user data.

Once adminserver user was create, we are going to give sudoers privileges. Type:

visudo

Go to: # User privilege specification, and add below:

adminserver ALL=(ALL) ALL

Defaults:adminserver    timestamp_timeout=0, runaspw, passwd_tries=1

The first line says that adminserver user can access like root with sudo command.

The second line, configure some paremetres to adminserver sudo access: adminserver needs root's password to run sudo (runaspw), the password will not be remembered (timestamp_timeout) and he gets only one chance to enter it (passwd_tries).
NOTE: Is important use visudo editor because it can detect spelling errors before write sudoers file.

Installing LAMP

Apache

The Apache HTTP Server is an open-source HTTP server for modern operating systems including UNIX, Microsoft Windows, Mac OS/X and Netware.

We are going to install it:

sudo apt-get install apache2 apache2-mpm-prefork

After installation, we are going to make some configurations:

mkdir /home/adminserver/web/

We create that folder called web to store all the web files.

Now we are going to change some basic Apache configuration, edit: /etc/apache2/sites-available/default

Search line:

DocumentRoot /var/www/

Replace by:

DocumentRoot /home/<user>/web/

DocumentRoot is the root folder that contains our web pages.

Search line:

Directory /var/www/

Options Indexes FollowSymLinks MultiViews

Replace by:

Directory /home/<user>/web/ 

Options FollowSymLinks

For security reasons, we are going to hide our files and folders.

Search line:

AllowOverride None

Replace by:

AllowOverride all

Allows a file .htaccess to override the options for the respective directory

Save and exit.

Add the following lines to the bottom of /etc/apache2/apache2.conf

ServerSignature Off
ServerTokens Prod

For security reasons, this lines hide the version of Apache and Linux Distro.

Restart Apache:

sudo /etc/init.d/apache2 restart

Now we have a Apache with basic improved configuration.

PHP

Now we are going to install, the required packages to run Owncloud, if you want to install more Webs like Wordpress, Joomla, etc. Maybe you need install others. Type:

sudo apt-get install php5 php5-sqlite php5-common

Restart Apache:

sudo /etc/init.d/apache2 restart

MySQL + PHPmyAdmin

sudo apt-get install mysql-server mysql-client phpmyadmin

When we are installing MySQL, we configure it entering password for root MySQL database. Also when we are installing phpmyadmin we should choose: configure database for phpmyadmin with dbconfig-common, type root MySQL password again,  type phpmyadmin password database and choose apache2 confiuration .

Restart Apache:

sudo /etc/init.d/apache2 restart

Make a simbolic link to phpmyadmin:

sudo ln -s /usr/share/phpmyadmin /home/adminserver/web/phpmyadmin

With phpmyadmin you can handle your mysql databases (managing databases, tables, fields, relations, indexes, users, permissions, etc) via web browser. It is useful for Owncloud or another program than uses MySQL.

Enabling Automatic Updates

Automatic updates can be used to automatically install updated packages. You can configure it to update all packages or just security packages. Install the following package:

sudo apt-get install unattended-upgrades

To configure unattended-upgrades, edit:/etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs:

The double “//” serve as comments, so whatever follows "//" will not be evaluated. Coment/uncoment the repositoris that you prefe, i recommend this configuration:

Unattended-Upgrade::Allowed-Origins {
        "${distro_id} stable";
        "${distro_id} ${distro_codename}-security";
//      "${distro_id} ${distro_codename}-updates";
//      "${distro_id} ${distro_codename}-proposed-updates";
};

You can blacklisted some packeges, you can enable automatic removes, autoremove orphans packages,etc.

To set everything first create a file: /etc/apt/apt.conf.d/10periodic and edit it with your favorite editor, my configuration is:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

The above configuration updates the package list, downloads, and installs available upgrades every day. The local download archive is cleaned every week.

For more information go to here.

Set up a External HD

External HD is useful to get more space for our project. In this part we are going to set up our HD when it is connected to server.

Format your HD with a EXT3 Filesystem.

Create the following script: /etc/udev/rules.d/50-mount-external.rules, and paste this:

KERNEL!= "sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

Stop/start the udev deamon:

/etc/init.d/udev stop
/etc/init.d/udev start

Connect your HD to server. Use "mount" command to see External HD information.

/dev/root on / type ext3 (rw)
none on /proc type proc (rw,noexec,nosuid,nodev)
none on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/kernel/debug type debugfs (rw)
none on /dev type tmpfs (rw,mode=0755)
none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
none on /dev/shm type tmpfs (rw,nosuid,nodev)
none on /var/run type tmpfs (rw,nosuid,mode=0755)
none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
/dev/sda1 on /media/usbhd-sda1 type ext3 (rw,relatime)

Where our HD isi mounted in media folder, and its name is u"sbhd-sda1"

Set up Owncloud.org Software

Installing Owncloud.org

Owncloud software need some extra packages:

For improved scanning of music files:

sudo apt-get install mp3info

For downloading multiple files:

sudo apt-get install zip

For the OpenID plugin

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

This how-to uses the lastest release of Ownlcoud but if you use stable version it would be similar. Download Owncloud in your root Apache folder.

sudo apt-get install wget
cd /home/adminserver/web/
wget http://gitorious.org/owncloud/owncloud/archive-tarball/master

Uncompres it:

tar -zxvf master

Make Root file folder in External HD:

cd /media/usbhd-sda1
sudo mkdir DATA
sudo chown -R www-data:www-data DATA

Make ownCloud directory accessible to Apache:

cd /home/adminserver/web/
sudo chown -R www-data:www-data owncloud-owncloud/

The estable version, the folder is named owncloud.
Previewowncloudinstallation1.png

Open your web browser and finish your Owncloud installation. Go to: http://<IP PRIVATE SERVER>/owncloud-owncloud/ Put your personal information and select MySQL Database. once finish, click Finish Setup.






Configuring Apache and PHP for Owncloud

PHP and Apache have a standard configuration, we need to change it to improve performance  of our project and server.

Edit <span style="font-family: monospace;" />/etc/apache2/apache2.conf

LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 700
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 600
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients           10
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          10
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_event_module>
    StartServers          2
    MaxClients          10
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/
ServerSignature Off
ServerTokens Prod

I reduce the number of clients and increased the persistent connection time.

Edit: /etc/php5/apache2/php.ini.

max_file_uploads = 20            max_file_uploads = 100
upload_max_filesize = 2M         upload_max_filesize = 750M
post_max_size = 8M               post_max_size = 800M
default_socket_timeout = 60      default_socket_timeout = 600
max_execution_time = 30          max_execution_time = 500
max_input_time = 60              max_input_time = 600
memory_limit = 128M              memory_limit = 1025M
mysql.connect_timeout = 60       mysql.connect_timeout = 600

I configure it for a local connection.

Edit Owncloud .htaccess and erase the following lines:

php_value upload_max_filesize 512M
php_value post_max_size 512M

Now .htacces don't limit the upload filesize and post size.

Restart Apache service:

sudo /etc/init.d/apache2 restart

Configuring WebDAV for Owncloud

Owncloud development team are creating a native client to manage files more easyly, but is not release yet. Although we can set up a WebDAV protocol to solve it. I tested with a Ubuntu 10.04 laptop, but can be use in other paltforms, see this page for more information.

Install the WebDAV support:

sudo apt-get install davfs2

Reconfigure davfs2 to allow access to normal users:

<code>sudo dpkg-reconfigure davfs2</code>

Select Yes when prompted

Add the users you want to be able to mount the share to the davfs2 group:

sudo usermod -aG davfs2 <userclient>

Edit /etc/fstab, and add the following line for each user who wants to mount the folder (with your details where appropriate)

http://<IPPRIVATE>/owncloud-owncloud/files/webdav.php /home/<username>/owncloud davfs user,rw,noauto 0 0

Create the folders owncloud & .davfs2 in your home directory Create the file named secrets inside .davfs2 folder, fill it with the following (with your credentials where appropriate)

http://<IPPRIVATE>/owncloud-owncloud/files/webdav.php <yourowncloudusername> <yourowncloudpassword>

Ensure the file is only writable by you either through the file manager:

chmod 600 ~/.davfs2/secrets

Mount your Virtual Owncloud Hardrive with the command: mount ~/owncloud You can automatically mount the folder on login, add the last command to ~/.bashrc