Install ownCloud on Raspberry Pi (Arch Linux) using Lighttpd

Install ownCloud on Raspberry Pi (Arch Linux) using Lighttpd

First of all, you can see all my posts about ownCloud and Raspberry Pi.

For my project, I used a Raspberry Pi (Model B), a 8GB SD card. It's connected with ethernet and the power plugs on my router (there's a USB that can be used as SAMBA server or Print Server).

I used Arch Linux as distro, because I wanted to have the latest packages. ownCloud is only a pacman away. NOT. I found there's an error. More or less here it is:

This update changed the config directory from
/usr/share/webapps/owncloud/config to /etc/webapps/owncloud/config,
and created the following symlink:
/usr/share/webapps/owncloud/config --> /etc/webapps/owncloud/config

I copied my config.php configuration file to /etc/webapps/owncloud/config/config.php, and double checked ownerships and permissions:
/etc/webapps/owncloud/config has 775 permissions and is owned by http.http.
/etc/webapps/owncloud/config/config.php has 660 permissions and is owned by http.http.
Even though the http server has write permissions, each time I tried to open owncloud in my browser, it just shows the error message: "Can't write into config directory 'config'. This can usually be fixed by giving the webserver write access to the config directory.". I have even tried setting 777 permissions to the config directory and config.php file without luck.

I have worked around the problem by deleting the /usr/share/webapps/owncloud/config symlink, and replacing it by a "config" directory with the config file, but this will cause problems the next time I update owncloud, so I would like to know how to properly fix this.

So the only thing I didn't do, is the pacman -S owncloud

I also tried to install nginx. Although I found many tutorials how to do it, but it didn't work my systemd entry. Maybe I'm doing something wrong. I might test it next time. So next server in a row was Lighttpd. I read lighttpd vs nginx and a test of Nginx, Cherokee and Lighttpd.

This tutorial has 3 sections:


Before we start, download Arch Linux image for Raspberry Pi. After I copy it (dd if=Arch.....img of=/dev/sdX bs=1M;sync), I opened gparted to create a new partition, the rest of the SD (ext4 partition). This can be done with fdisk but you save some time.

1. Now boot your Raspberry pi and update everything:

pacman -Syu

2. Mount the extra partition you made. How to do that?

Find the name of the partition

cat /proc/partitions

Usually it's mmcblk0p3. So now mount this partition.

# you better change the permissions
chmod -R 777 /dev/mmcblk0p3

mkdir /mnt/sd

# and then

nano /etc/fstab

# and add the following line
/dev/mmcblk0p3 /mnt/sd ext4 defaults 1 0

Now reboot your Raspberry Pi.

3. Install all needed programs (Sqlite, Lighttpd etc)

pacman -S lighttpd fcgi php-cgi php-sqlite openssl

4. Change Lighttpd properties:

nano /etc/lighttpd/lighttpd.conf

and change it to the following:

server.port = 80
server.username = "http"
server.groupname = "http"
server.document-root = "/usr/share/webapps"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html","index.php")
mimetype.assign = (
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "application/ogg",
".wav" => "audio/x-wav",
".svg" => "image/svg+xml",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".cpp" => "text/plain",
".log" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".spec" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar",
".odt" => "application/vnd.oasis.opendocument.text",
".ods" => "application/vnd.oasis.opendocument.spreadsheet",
".odp" => "application/vnd.oasis.opendocument.presentation",
".odg" => "application/vnd.oasis.opendocument.graphics",
".odc" => "application/vnd.oasis.opendocument.chart",
".odf" => "application/vnd.oasis.opendocument.formula",
".odi" => "application/vnd.oasis.opendocument.image",
".odm" => "application/vnd.oasis.opendocument.text-master",
".ott" => "application/vnd.oasis.opendocument.text-template",
".ots" => "application/vnd.oasis.opendocument.spreadsheet-template",
".otp" => "application/vnd.oasis.opendocument.presentation-template",
".otg" => "application/vnd.oasis.opendocument.graphics-template",
".otc" => "application/vnd.oasis.opendocument.chart-template",
".otf" => "application/vnd.oasis.opendocument.formula-template",
".oti" => "application/vnd.oasis.opendocument.image-template",
".oth" => "application/vnd.oasis.opendocument.text-web",

# make the default mime type application/octet-stream.
"" => "application/octet-stream",
)

# MODULOS #
server.modules = (
"mod_fastcgi",
)

# CONFIG MODULOS #
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket"
)))

# OWNCLOUD # Disable access to data folder
$HTTP["url"] =~ "^/owncloud/data/" {
url.access-deny = ("")
}

# OWNCLOUD # Disable directory listing
$HTTP["url"] =~ "^/owncloud($|/)" {
dir-listing.activate = "disable"
}

I usually copy the file to another file, then delete it and create it from scratch.

cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.old

# and then

nano /etc/lighttpd/lighttpd.conf

Now run the server:

systemctl start lighttpd.service
systemctl enable lighttpd.service

You can check if it works, if you point your browser to the raspberry ip.

5. Now you should make some changes to PHP.

nano /etc/php/php.ini

and find-change the following:

...
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/mnt/sd
...
default_charset = "UTF-8"
cgi.fix_pathinfo = 1
...

extension=curl.so
extension=gd.so
extension=iconv.so
extension=openssl.so
extension=pdo_sqlite.so
extension=sqlite3.so
extension=xmlrpc.so
extension=zip.so

...
[sqlite3]
sqlite3.extension_dir = /usr/lib/php/modules/

Restart your lighttpd service.

systemctl restart lighttpd.service

6. Now you can download ownCloud. Go to Download page and choose tar or zip.

A cool tip is to go to server folder (cd /srv/http) and write


the extract the file

tar -xjf owncloud-6.0.3.tar.bz2

Then you should change the permissions:

chown http:http owncloud
chown http:http owncloud/config

Create a directory to store data. It's safer to have your data outside your server directory.

mkdir /mnt/sd/data

Check the documentation for some extra settings, just in case you use other servers etc.

7. Now open your browser to http://IP/owncloud. If everything is OK, you'll be prompted to enter your NEW admin user and password and the location of the data folder (message in red tells you to change the path). Remember I created the folder before. The location is /mnt/sd/data.

If there's something wrong, there'll be a message like the following:

ownCloud Error

Since it wasn't set by default, I followed the Arch Linux tutorial how to do it.
Usually there are some PHP modules missing. You can install them or uncomment them on the php.ini file.

8. You can change the php.ini file (nano /etc/php/php.ini) with the following information:

post_max_size = 50G
upload_max_filesize = 25G
max_file_uploads = 200
max_input_time = 3600
max_execution_time = 3600
session.gc_maxlifetime = 3600
memory_limit = 512M

9. If you want to change the security, you can follow some tutorials from the documentation how to do them.
Finally, you should port forward and dynamic dns, so you can have access from out your house.

Δεν υπάρχουν σχόλια

Από το Blogger.