PHP WebDAV Module: Enabling on Apache and NGINX

Sometimes while creating a website we face the need to build some complicated method of viewing and updating the information on the site. There are lots of solutions, which use local copies of your files and a combination of HTTP and FTP tools to download the original files and upload the changes etc. WebDAV (Web-based Distributed Authoring and Versioning) is one of such solutions and you can freely use it in Jelastic. Create, change, copy and move files on your server and create and manage file directories right in the cloud, simply by accessing them via HTTP/HTTPS. By using WebDAV, you can have free, instant, and secure access to your application files anywhere you have a network connection. Besides any application built on top of WebDAV can use cryptographically strong authentication, proxying, caching and encryption with SSL, if so desired.

WebDAV is turning into an important tool which was invented in order to simplify the way you update websites. So let’s examine how to use this great tool in the cloud for your PHP applications.

In the following instruction you’ll see how to enable WebDAV connection for Apache and NGINX application servers.

Create an environment

1. Go to Jelastic.com and sign up if you haven’t done it yet or log in with your Jelastic credentials by clicking the Sign In link on the page.

2. While in Jelastic dashboard, click the Create environment button:

12

3. In the Environment Topology window pick Apache or NGINX as your application server. Then type your environment name, for example, webdavtest.

webdavphp1

In a minute your environment with Apache or NGINX will be created and appears in the environments list.

Enabling WebDAV module

A. Enabling WebDAV module for Apache server

1. Click Config button for the server in your environment.

2. Navigate to conf.d folder and open modules.conf file. Make sure you have mod_dav and mod_dav_fs modules enabled in your configuration, modules.conf should have next lines uncommented:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so

Снимок1

3. In the conf folder open httpd.conf file. Modify VirtualHost configuration by adding the following as it is shown in the picture below:

<Directory /> 
       DAV on 
</Directory> 

webdav

4. Save the changes and restart Apache.

Setting up security configuration

1. Generate hash from your password. For that you can use any htpasswd tool or online service

(for example, http://www.htpasswdgenerator.net/)

2. Create simple text file with previously generated hash (in our case we name it .htpasswd). There should be one per line, for example:

test
abcdefg

3. Click Config button for your Apache server.

4. Upload the created file to the webroot/ROOT folder.

5. In the conf folder open httpd.conf file. Modify directory configurations by adding the following strings as it is shown in the picture below:

AuthName "Restricted area"
AuthType Basic
AuthBasicProvider file
AuthUserFile /var/www/webroot/ROOT/.htpasswd
Require valid-user

Снимок

6. Save the changes and restart Apache.

B. Enabling WebDAV module for NGINX server

1. Click Config button for the server in your environment.

2. In the conf folder open nginx.conf file. Modify configuration by adding the following strings as it is shown in the picture below:

dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;

Снимок

3. Save the changes and restart NGINX.

Using nginx.conf file you can set any other configurations for WebDav module. Follow the link (http://wiki.nginx.org/HttpDavModule) to find some additional useful information.

Setting up security configuration

1. Generate hash from your password. For that you can use any htpasswd tool or online service

(for example, http://www.htpasswdgenerator.net/)

2. Create simple text file with previously generated hash (in our case we name it .htpasswd).

3. Click Config button for your NGINX server.

4. Upload the created file to the webroot/ROOT folder.

5. In the conf folder open nginx.conf file. Add the following strings:

auth_basic "Restricted area";
auth_basic_user_file /var/www/webroot/ROOT/.htpasswd;

Снимок1

6. Save the changes and restart NGINX.

Connection to the server

1. Finally you can go to any WebDAV client (we’ll use BitKinex as an example).

webdav12

2. State there the host (also your credentials if you set up security configuration) and connect to the server.

webdav13

3. As a result you’ll see your files and will be able to edit them, update, add some new files etc.

webdav15

WebDAV provides you a secure remote way of viewing, uploading, moving and changing your files, since they will be editable in-place, typically in a location provided by an Internet service provider. Enjoy!

One Response to “PHP WebDAV Module: Enabling on Apache and NGINX”

  1. PHP WebDAV Module: Enabling on Apache and NGINX « Jelastic — Die nächste Generation Java-Hosting-Plattform

    [...] Marina Sprava hat einen neuen interessanten Artikel in unserem englischen Blog geschrieben, den wir Euch nicht vorenthalten wollen. PHP WebDAV Module: Enabling on Apache and NGINX [...]

    Reply

Leave a Reply