Skip to content

Instantly share code, notes, and snippets.

@0xIslamTaha
Last active July 25, 2019 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xIslamTaha/da09b759819a0f02766edd4c698a8818 to your computer and use it in GitHub Desktop.
Save 0xIslamTaha/da09b759819a0f02766edd4c698a8818 to your computer and use it in GitHub Desktop.
saberDav, php, nginx installation steps

1- Installation steps:

apt-get install -y nginx php php-fpm php-mysql htop vim php7.2-xml php-mbstring unzip php-curl
mkdir /var/www/html/saberdav 
cd /var/www/html/saberdav
mkdir data public
php -r "readfile('http://getcomposer.org/installer');" > composer-setup.php && php composer-setup.php --install-dir=/usr/bin --filename=composer && php -r "unlink('composer-setup.php');" && composer require sabre/dav ~3.2.0 

2- Create server.php:

Save the following file as /var/www/html/saberdav/server.php

<?php

use
    Sabre\DAV;

// The autoloader
require 'vendor/autoload.php';

// Now we're creating a whole bunch of objects
$rootDirectory = new DAV\FS\Directory('public');

// The server object is responsible for making sense out of the WebDAV protocol
$server = new DAV\Server($rootDirectory);

// If your server is not on your webroot, make sure the following line has the
// correct information
$server->setBaseUri('/saberdav/server.php');

// The lock manager is reponsible for making sure users don't overwrite
// each others changes.
$lockBackend = new DAV\Locks\Backend\File('data/locks');
$lockPlugin = new DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);

// This ensures that we get a pretty index in the browser, but it is
// optional.
$server->addPlugin(new DAV\Browser\Plugin());

// All we need to do now, is to fire up the server
$server->exec();

3- update defualt sites-available:

save the following file as /etc/nginx/sites-available/default

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }
}

4- Run nginx and php-fpm:

service php7.2-fpm start
service nginx start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment