Owncloud setup notes

How to set up owncloud with nginx, php-fpm, postgresql on Arch Linux.
This setup is without SSL and access control.

1. Installing necessary packages.


pacman -S owncloud nginx php-fpm php-pgsql postgresql

2. Setting up postgresql.


sudo su -
su - postgres -c "initdb --locale en_GB.UTF-8 -D '/var/lib/postgres/data'"
systemctl start postgresql
systemctl enable postgresql
psql -hlocalhost -Upostgres
CREATE USER username WITH PASSWORD 'password';
CREATE DATABASE owncloud TEMPLATE template0 ENCODING 'UNICODE';
ALTER DATABASE owncloud OWNER TO username;
GRANT ALL PRIVILEGES ON DATABASE owncloud TO username;
\q

3. Setting up php

Create a file /etc/php/conf.d/owncloud.ini with texts below


extension=gd.so
extension=iconv.so
extension=xmlrpc.so
extension=zip.so
extension=pdo_pgsql.so
extension=pgsql.so

[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

Edit /etc/php/php.ini


open_basedir = /srv/http/:/usr/share/webapps/:/etc/webapps/owncloud/config/

post_max_size = 10G
upload_max_filesize = 10G

Start php-fpm


systemctl start php-fpm
systemctl enable php-fpm

3. Setting up nginx.

server {
listen 80;
server_name localhost;

# Path to the root of your installation
root /srv/http/;

client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
deny all;
}

location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ index.php;
}

location ~ ^(.+?\.php)(/.*)?$ {
try_files $1 = 404;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}

# Optional: set long EXPIRES header on static assets
location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}

}

service


systemctl enable nginx
systemctl start nginx

4. Setting up owncloud contents


ln -s /usr/share/webapps/owncloud /srv/http/
chown http:http -R /usr/share/webapps/owncloud/
chown http:http /srv/http/owncloud -R

5. Access 127.0.0.1/owncloud from your browser and finish the setup.

6. Remove the line with trusted domain in /etc/webapps/owncloud/config/config.php, and add below


'loglevel' => '4',
'updatechecker' => false,
'check_for_working_htaccess' => false,
'appstoreenabled' => false,
'check_for_working_webdav' => false,
Advertisements

PCI passthrough in KVM

1.  make sure to add “iommu=on” in the grub otion.

e.g. /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT=”iommu=on”

2.  unbind pci from the host

find the pci id by “lscpi”  and “lspci -n” command, and do something like below.

e.g.

echo "1033 0194" > /sys/bus/pci/drivers/pci-stub/new_id
echo "0000:0d:00.0" > /sys/bus/pci/drivers/xhci_hcd/unbind
echo "0000:0d:00.0" > /sys/bus/pci/drivers/pci-stub/bind
echo "1033 0194" > /sys/bus/pci/drivers/pci-stub/remove_id

3. Attach the pci to the VM before booting, and boot the VM.