June 2018
M T W T F S S
« May    
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

WordPress Quotes

Are you bored with life? Then throw yourself into some work you believe in with all your heart, live for it, die for it, and you will find happiness that you had thought could never be yours.
Dale Carnegie

Recent Comments

June 2018
M T W T F S S
« May    
 123
45678910
11121314151617
18192021222324
252627282930  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (26)
Ansibile (17)
Apache (124)
Asterisk (2)
cassandra (2)
Centos (207)
Centos RHEL 7 (250)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (24)
Eassy (11)
EXCHANGE (3)
Fedora (6)
ftp (5)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (6)
JBOSS (32)
jenkins (1)
Kubernetes (1)
Ldap (4)
Linux (188)
Linux Commands (167)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (21)
MYSQL (80)
Nagios (5)
NaturalOil (13)
Nginx (27)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (33)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (11)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (59)
Uncategorized (29)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

16 visitors online now
4 guests, 12 bots, 0 members

Hit Counter provided by dental implants orange county

How to Setup a WebDAV Server Using Apache on CentOS 7

How to Setup a WebDAV Server Using Apache on CentOS 7

CentOS Linux Guides Server Apps Web Servers

WebDAV stands for “Web-based Distributed Authoring and Versioning”. It’s an extension of the HTTP protocol that allows users to manage and share files stored on a WebDAV-enabled web server.

This tutorial will show you how to setup a WebDAV server using Apache on a Vultr CentOS 7 server instance.

Prerequisites
A Vultr CentOS 7 server instance.
A non-root sudo user. You can learn more about how to create a sudo user in this Vultr tutorial.
Step one: Update the system
sudo yum install epel-release
sudo yum update -y
sudo shutdown -r now
After the reboot, use the same sudo user to log in.

Step two: Install Apache
Install Apache using YUM:

sudo yum install httpd
Disable Apache’s default welcome page:

sudo sed -i ‘s/^/#&/g’ /etc/httpd/conf.d/welcome.conf
Prevent the Apache web server from displaying files within the web directory:

sudo sed -i “s/Options Indexes FollowSymLinks/Options FollowSymLinks/” /etc/httpd/conf/httpd.conf
Start the Apache web server:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service
Step three: Setup WebDAV
For Apache, there are three WebDAV-related modules which will be loaded by default when a Apache web server getting started. You can confirm that with this command:

sudo httpd -M | grep dav
You should be presented with:

dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
Next, create a dedicated directory for WebDAV:

sudo mkdir /var/www/html/webdav
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
For security purposes, you need to create a user account, say it is “user001”, to access the WebDAV server, and then input your desired password. Later, you will use this user account to log into your WebDAV server.

sudo htpasswd -c /etc/httpd/.htpasswd user001
Modify the owner and permissions in order to enhance security:

sudo chown root:apache /etc/httpd/.htpasswd
sudo chmod 640 /etc/httpd/.htpasswd
Step four: Create a virtual host for WebDAV
sudo vi /etc/httpd/conf.d/webdav.conf
Populate the file with:

DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/webdav/
ErrorLog /var/log/httpd/error.log
CustomLog /var/log/httpd/access.log combined
Alias /webdav /var/www/html/webdav
<Directory /var/www/html/webdav>
DAV On
AuthType Basic
AuthName “webdav”
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
Save and quit:

:wq!
Restart Apache to put your changes into effect:

sudo systemctl restart httpd.service
Step five: Modify firewall rules
sudo firewall-cmd –zone=public –permanent –add-service=http
sudo firewall-cmd –reload
Step six: Test the functionality of the WebDAV server from a local machine
In order to take advantage of WebDAV, you need to use a qualified client. For example, you can install a program called cadaver on a CentOS 7 desktop:

sudo yum install cadaver
Having cadaver installed, use the following command to access the WebDAV server:

cadaver http://<your-server-ip>/webdav/
Use the username “user001” and the password you setup earlier to log in.

In the cadaver shell, you can upload and organize files as you wish. Here are some examples.

To upload a local file “/home/user/abc.txt” to the WebDAV server:

dav:/webdav/> put /home/user/abc.txt
To create a directory “dir1” on the WebDAV server:

dav:/webdav/> mkdir dir1
To quit the cadaver shell:

dav:/webdav/> exit
If you want to learn more about cadaver, you can look up the cadaver manual in the Bash shell:

man cadaver
or

cadaver -h

 

 

Once it is done, you shall disable Apache’s default welcome page.

[root@linuxhelp ~]# sed -i ‘s/^/#&/g’ /etc/httpd/conf.d/welcome.conf

Also, prevent the Apache web server from displaying files within the web directory.

[root@linuxhelp ~]# sed -i “s/Options Indexes FollowSymLinks/Options FollowSymLinks/” /etc/httpd/conf/httpd.conf

After that, start and enable the Apache web server.

[root@linuxhelp ~]# systemctl start httpd.service
[root@linuxhelp ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Setup WebDAV

For Apache, there are three WebDAV-related modules which will be loaded by default when an Apache web server is getting started.

[root@linuxhelp ~]# httpd -M | grep dav
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)

Next, create a dedicated directory for WebDAV:

[root@linuxhelp ~]# mkdir /var/www/html/webdav
[root@linuxhelp ~]# chown -R apache:apache /var/www/html
[root@linuxhelp ~]# chmod -R 755 /var/www/html

For security purposes, you need to create a user account.

[root@linuxhelp ~]# htpasswd -c /etc/httpd/.htpasswd user1
New password:
Re-type new password:
Adding password for user user1

And also, you need to modify the owner and permissions in order to enhance security

[root@linuxhelp ~]# chown root:apache /etc/httpd/.htpasswd
[root@linuxhelp ~]# chmod 640 /etc/httpd/.htpasswd

Once it is done, you need to create a VirtialHost for WebDAV.

[root@linuxhelp ~]# vi /etc/httpd/conf.d/webdav.conf
DavLockDB /var/www/html/DavLock
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/webdav/
ErrorLog /var/log/httpd/error.log
CustomLog /var/log/httpd/access.log combined
Alias /webdav /var/www/html/webdav
<Directory /var/www/html/webdav>
DAV On
AuthType Basic
AuthName “webdav”
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
</VirtualHost>

Once the VirtualHost is configured, you need to restart Apache to put your changes into effect.

[root@linuxhelp ~]# systemctl restart httpd.service

Test the functionality of the WebDAV server from a local machine. In order to take advantage of WebDAV, you need to use a qualified client. For example, you can install a program called cadaver on a CentOS 7 desktop

[root@linuxhelp ~]# yum install cadaver
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.dhakacom.com
* epel: mirror2.totbb.net
* extras: mirrors.viethosting.com
* updates: centos-hn.viettelidc.com.vn
Resolving Dependencies
–> Running transaction check
—> Package cadaver.x86_64 0:0.23.3-9.el7 will be installed
–> Finished Dependency Resolution

.
.
Running transaction
Installing : cadaver-0.23.3-9.el7.x86_64 1/1
Verifying : cadaver-0.23.3-9.el7.x86_64 1/1

Installed:
cadaver.x86_64 0:0.23.3-9.el7

Complete!

Having cadaver installed, use the following command to access the WebDAV server.

[root@linuxhelp ~]# cadaver http://192.168.7.234/webdav/
Authentication required for webdav on server `192.168.7.234′:
Username: user1
Password:
dav:/webdav/>

In the cadaver shell, you can upload and organize files as you wish. Here are some examples. To upload a local file

dav:/webdav/> put /root/Desktop/linuxhelp.txt
Uploading /root/Desktop/linuxhelp.txt to `/webdav/linuxhelp.txt’: succeeded.

To create a directory “dir1” on the WebDAV server

dav:/webdav/> mkdir dir

To quit the cadaver shell

dav:/webdav/> exit
Connection to `192.168.7.234′ closed.
If you want to learn more about cadaver, you can look up the cadaver manual in the Bash shell. With this, the tutorial on setting up a WebDAV Server Using Apache on CentOS 7 comes to an end.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam