An issue with sudo?
Danger (Please don't use the root account)
If you configure your server directly as root, don’t forget to remove sudo from each command.
If you set a password for the root account, the sudo command won’t be accepted.
Connect directly as root to execute commands.
You can also reinstall your system leaving the root password empty during installation.
sudo will install and work properly.
➡️ To have the necessary modules, you need to install nginx in its complete version:
sudo apt update && sudo apt install nginx-full- It’s done! Your site is accessible in your browser at the address
http://IP_of_your_machine
WebDAV configuration
Tip
Create a configuration file for each site, don’t forget to change the port, to avoid having several configurations with the same port.
- Here we will edit the default file, but we could very well copy and rename it:
sudo cp /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/site.confsudo rm /etc/nginx/sites-enabled/defaultEdit the configuration file
sudo nano /etc/nginx/sites-enabled/site.confserver { listen 80 default_server; listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP 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 ^~ /webdav { auth_basic "realm_name"; auth_basic_user_file /var/www/.auth.allow; alias /var/www/html; autoindex on; autoindex_exact_size on; autoindex_localtime on; index file.html; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; dav_access user:rw; client_body_temp_path /var/www/tmp; client_max_body_size 0; create_full_put_path on;
}}-
Ligne 1-3The server listens on port 80. -
Ligne 5Defines the path of the root of the internet site (or where your index.html is, for example). -
Ligne 18location ^~ /webdav {says that to reach/var/www/htmlI enterthe ip or the name of my machine+/webdav=http://172.16.30.30/webdavfor example. -
Ligne 20Defines the path of the authentication file.
Create the authentication file
- Switch to root
su -- Replace
userby your username
echo -n 'user:' | tee -a /var/www/.auth.allow- Define the password of the user:
Enter your password, confirm, it will be displayed in the form of a hash.
openssl passwd -apr1 | tee -a /var/www/.auth.allowPassword:Verifying - Password:$apr1$t.VOQfZL$bHLajKSa1gA34tgAVWA2l/Tip
Check the user configuration:
cat /var/www/.auth.allowuser_name:$apr1$9WppBYUH$L4S3jfDRXqfcAJ1mD93KD/Define the permissions of the authentication file
chown root:www-data /var/www/.auth.allow && chmod 640 /var/www/.auth.allowActivate gzip compression (saves bandwidth)
Gzip compression is optional and is discouraged if the site uses https.
sed -i '/gzip_/ s/#\ //g' /etc/nginx/nginx.confTest and restart nginx
nginx -t && systemctl restart nginxTip
You can connect to the webdav share (/var/www/html) using the link (http://IP_server/webdav)