Jump to content

Define nginx logs in vhost


brent

Recommended Posts

if you are running multiple vhost in nginx, you may want to change the location of your site logs.

in this exercise we have a structure of: /var/www/domain.com/html & /var/www/domain.com/log

1.  Create a folder in /var/www/domain.com/log

2.  open /etc/nginx/sites-enabled/domain.com

3.  Add the access_log and error_log to your vhost file and save the configuration file.

server {
    listen 80;
    server_name www.domain.com;
    root /var/www/domain.com/html/;
    access_log /var/www/domain.com/log/domain.com.access.log;
    error_log /var/www/domain.com/log/domain.com.error.log;
}

 

4. Reload Nginx server

systemctl restart nginx.service

5. Check /var/www/domain.com/log to ensure two log files have been created.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...