How to configure the default site directory in nginx?

In the Nginx configuration file, you can configure the directory of the default site by modifying the `root` directive. Open the Nginx configuration file, which is typically located in `/etc/nginx/nginx.conf` or `/etc/nginx/conf.d/default.conf`, find the `server` block, and then modify the `root` directive. For example, to set the directory of the default site to `/var/www/html`, you can add the following code to the `server` block:

server {

    ...

    root /var/www/html;

    ...

}

Save the file and restart the Nginx service to apply the configuration. Keep in mind: after modifying the configuration file, make sure the directory exists and the Nginx process has permission to access that directory.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds