Initial preperation
In this scenario the server is headless and is accessed via SSH. At this point I have run through my own RaspberryPi 3 setup guide and amended the IP tables to allow access over ports, 80, 443 and 3306. I then turn off the Pi, remove the MicroSD card and make a back with the following command where /dev/sdf is the mount location for the card on your PC.
sudo dd bs=4M if=/dev/sdf | gzip > raspberrypi.img.gz
and if you balls up the install later on you can restore with
sudo gunzip --stdout raspberrypi.img.gz | dd bs=4M of=/dev/sdf
First install all the required packages via the command below. You will be asked for the root password for the installation of MySQL at some point.
sudo apt-get install nginx openssl ssl-cert php5-cli php5-sqlite php5-gd php5-common php5-cgi sqlite3 php-pear php-apc curl libapr1 libtool curl libcurl4-openssl-dev php-xml-parser php5 php5-dev php5-curl php5-gd php5-fpm memcached php5-memcache varnish mysql-server php5-mysql
Now create an SSL certificate. We can get a "real" one later.
sudo openssl req $@ -new -x509 -days 730 -nodes -out /etc/nginx/cert.pem -keyout /etc/nginx/cert.key
Answer the prompts and then run the commands below to se the correct permissions.
sudo chmod 600 /etc/nginx/cert.pem
sudo chmod 600 /etc/nginx/cert.key
Now remove contents of the nginx config file with the command below
sudo sh -c "echo '' > /etc/nginx/sites-available/default"
Now open it up with
sudo nano /etc/nginx/sites-available/default
And paste in the next below. Be sure to change the server IPs to the one for your server (mine is 192.168.0.7) and amend the certificate paths and names if they are different.
upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name 192.168.0.7;
return 301 https://$server_name$request_uri; # enforce https
}
server {
listen 443 ssl;
server_name 192.168.0.7;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.key;
# Path to the root of your installation
root /var/www/owncloud;
client_max_body_size 1000M; # 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 ~ ^/(?:\.htaccess|data|config|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(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}
# 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;
}
}
Now edit the php.ini file and change the upload sizes to whatever you like. Use "Ctrl-W" to search the file.
sudo nano /etc/php5/fpm/php.ini
upload_max_filesize = 1024M
post_max_size = 1024M
Now edit the FPM PHP config file with
sudo nano /etc/php5/fpm/pool.d/www.conf
and change the listening port as below.
listen = 127.0.0.1:9000
Now set your swap space value in the below file
sudo nano /etc/dphys-swapfile
CONF_SWAPSIZE = 512