Skip to main content

Compiling Nginx with WebDAV Support on Rocky/Alma/RHEL 10

· 3 min read
All round blogger

Compiling Nginx with WebDAV and HTTPS Support on Rocky/Alma/RHEL 10

Nginx comes with basic support for WebDAV but if you want full support for all WebDAV features you'll need to compile it yourself.

This guide assumes you are using one of the following Linux distros:

  • Alma Linux 10
  • Rocky Linux 10
  • Red Hat Enterprise Linux 10

Make sure your Linux install is fully updated:

sudo dnf update

and then install wget to download the Nginx source code:

sudo dnf install wget

The first task is to download the latest version of Nginx from nginx.org.

https://nginx.org/

for instance to download 1.29 you would run this command:

wget https://nginx.org/download/nginx-1.29.0.tar.gz

You'll need to install GCC from your package manager in order to compile Nginx. Any reasonably new version should be fine.

sudo dnf install gcc

Once you have the file you downloaded from nginx.org can uncompress it like this:

tar -xvzf nginx-1.29.0.tar.gz

If you downloaded a newer version you might need to change the filename above to the one you downloaded.

You might need to install the tar command:

sudo dnf install tar

Once you have uncompressed it enter the directory:

cd nginx-1.29.0

and then we need to run configure with a list of all the features we want built into the nginx server.

Before we start rebuilding the Nginx server we need to download the WebDAV extension module from the Github repo:

https://github.com/arut/nginx-dav-ext-module

You need to install git in order to clone the repo:

sudo dnf install git

then clone the repo like this:

git clone https://github.com/arut/nginx-dav-ext-module.git

Then rename the folder to webdav:

mv nginx-dav-ext-module/ webdav

Once you have the repo cloned and renamed you are you are ready to compile Nginx.

In order to include as many features as possible I'm going to enable most things in Nginx. If there is something you explicitly do not want then just remove the flag passed to configure.

Before you start you'll need the following libraries installed in order to compile Nginx with these features:

sudo dnf install pcre2-devel
sudo dnf install openssl-devel
sudo dnf install zlib-devel
sudo dnf install libxml2-devel
sudo dnf install libxslt-devel
sudo dnf install gd-devel
sudo dnf install perl-ExtUtils-Embed

then you need to run the configure script:

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --add-module=../webdav

Once configure has run you can simply run:

make

to compile the Nginx source code and add the WebDAV module. If you get an error when compiling Nginx talking about PIE or PIC then you might need to run these two commands to make sure Nginx builds properly:

export CFLAGS="${CFLAGS} -fPIC"
export LDFLAGS="${LDFLAGS} -pie"

run configure and make again and it should compile fine.

Then you simply run:

sudo make install

and your newly configured Nginx will be installed and ready to rock! You can find Nginx in this folder:

/usr/local/nginx