Changes

How to forge a local file system server with IGEPv2 Board

10,344 bytes added, 13:47, 15 June 2015
no edit summary
=== 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.
-ARM-Embedded is usually cheaper than a X86-Embedded processor. -If you have a good internet broadband, is not difficult to configure your server to accept external http request. -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 your server you can use all the space as your HD or SD supports.  <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 , 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.
=== 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.<br>  - *The Web uses HTML5 technology, it tested with Firefox 7 and Chromium , 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:
*[https://www.isee.biz/products/igep- processor-boards/igepv2-dm3730 IGEPv2 Board Revision C with 1 GHz Processor and 512MB Ram. ]- *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
- [http://gparted.sourceforge.net/ Gparted] = Installing Linaro Headless =
- Use this [http://downloadslabs.igep.es/filesindex.php/How_to_boot_from_MicroSD_Card tutorial](microSD) and this [http:/IGEP_xloader/labs.igep-x-loader-2.1es/index.0-3.tar.bz2 Igep-xphp/The_IGEP_X-loader-2.1other](IGEPxloader) to install Linaro Headless in your SD card.0-3It runs well with the software detailed above.tar&nbsp; You can compile the IGEPxloader and Kernel, but is not necessary.bz2]
- [http'''NOTE://gitorious'''Use FAT16 for boot partition and EXT3 for rootfs partition.org/owncloud/owncloud/archive-tarball/master 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]<br> = Installing Linaro Headless = Using 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.  Create a new plan text file into the boot partition named igep.ini with these content and save the fileit.
<pre>[kernel]
; Kernel load address, NOT Modify
;init=/bin/bash
</pre>
NOTE: I recomend change Check MAC adressaddress is not used for avoid conflicts.<br>
= Set up internet connection =
Login as root via serie, we 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
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>
Test your server connection sending a ping request:
 &lt;<pre&gt;  >ping X.X.X.X  &lt;</pre&gt; > After this, upgrade your system with via "apt-get".
= Installing Open SSH Server =
Type login Login as root via serie, type:
<pre>apt-get install openssh-server
</pre>
<pre>passwd root
</pre>
Enter new password, i recommend use letterletters, 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:
<pre>ssh root@X.X.X.X
</pre>
Using the password typed above, 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:<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 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).<br>NOTE: Is important use visudo editor because it can detect spelling errors before write sudoers file.<br>
= 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 Apache HTTP Serverit: <pre>sudo apt-get install apache2 apache2-mpm-prefork </pre>
After installation, we are going to make some configurations:
<pre lang="php">mkdir /home/&lt;user&gt;adminserver/web/</pre>
We create that folder called web to store all the web files.
Replace by:
<pre>DocumentRoot /home/&lt;user&gt;/web/</pre>
DocumentRoot is the root folder that contains our web pages.
 
Search line:
<pre>Directory /var/www/
Options FollowSymLinks</pre>
For security reasons, we are going to hide our files and folders.
 
Search line:
<pre>AllowOverride None</pre>
Replace by:
<pre>AllowOverride all</pre>
<br> &lt;/blockquote&gt; /etc/initAllows a file .d/apache2 restart htaccess to override the options for the respective directory
<br> Save and exit.
Add the following lines to the bottom of /etc/apache2/apache2.conf <brpre> ServerSignature OffServerTokens Prod</pre> For security reasons, this lines hide the version of Apache and Linux Distro.
Restart Apache: <pre>sudo /etc/init.d/apache2 restart</pre> Now we have a Apache with basic improved configuration.<br> Under construction
=== 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: <pre>sudo apt-get install php5-mysql php5-sqlite php5-json php5-curl libapache2-mod-php5 libxml2 php5-cli php5-common sgml</pre> Restart Apache: <pre>sudo /etc/init.d/apache2 restart</pre> === MySQL + PHPmyAdmin ===<pre>sudo apt-base xmlget install mysql-core php5server mysql-ming libcurl3 libfreetype6 libgif4 libming1 libmysqlclient16 libsqlite0 mysqlclient 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 php5-curl php5-ming php5, type root MySQL password again,&nbsp; type phpmyadmin password database and choose apache2 confiuration .<br>  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 mysqldatabases (managing databases, tables, fields, relations, indexes, users, permissions, etc) via web browser. It is useful for Owncloud or another program than uses MySQL.<br>
Under construction= 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:<br> <pre>sudo apt-get install unattended-upgrades</pre> To configure <span class=== MySQL ==="application">unattended-upgrades</span>, edit:/etc/apt/apt.conf.d/50unattended-upgrades and adjust the following to fit your needs: <br>
Under construction 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.
=== PHPmyAdmin ===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 constructionFor more information go to [https://help.ubuntu.com/12.04/serverguide/automatic-updates.html here.]
= Enabling Automatic Updates Set up a External HD =
Under constructionExternal 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.
= Set up Format your HD with a External HD =EXT3 Filesystem.
Under constructionCreate 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" # Import FS infosIMPORT{program}="/sbin/blkid -o udev -p&nbsp;%N" # Get a label if present, otherwise specify oneENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k" # Global mount optionsACTION=="add", ENV{mount_options}="relatime"# Filesystem-specific mount optionsACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002" # Mount the deviceACTION=="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 removalACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}" # ExitLABEL="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 =
=== Installing Owncloud.org ===
Under construction Owncloud software need some extra packages:<br>
=== Configuring 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 Owncloudin your root Apache folder. <pre>sudo apt-get install wgetcd /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-sda1sudo mkdir DATAsudo 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/ </pre> The estable version, the folder is named owncloud. [[Image:Previewowncloudinstallation1.png|right|331px]]
Under constructionOpen 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 ===
Under constructionPHP 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.lockPidFile ${APACHE_PID_FILE}Timeout 700KeepAlive OnMaxKeepAliveRequests 500KeepAliveTimeout 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/plainHostnameLookups OffErrorLog ${APACHE_LOG_DIR}/error.logLogLevel warnInclude mods-enabled/*.loadInclude mods-enabled/*.confInclude httpd.confInclude ports.confLogFormat "%v:%p&nbsp;%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combinedLogFormat "%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h&nbsp;%l&nbsp;%u&nbsp;%t \"%r\"&nbsp;%&gt;s&nbsp;%O" commonLogFormat "%{Referer}i -&gt;&nbsp;%U" refererLogFormat "%{User-agent}i" agentInclude conf.d/Include sites-enabled/ServerSignature OffServerTokens 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 = 100upload_max_filesize = 2M upload_max_filesize = 750Mpost_max_size = 8M post_max_size = 800Mdefault_socket_timeout = 60 default_socket_timeout = 600max_execution_time = 30 max_execution_time = 500max_input_time = 60 max_input_time = 600memory_limit = 128M memory_limit = 1025Mmysql.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 512Mphp_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]]
0
edits