2

Previously, I had Nginx installed through yum on my CentOS 6 machine. This gave me /etc/nginx/conf.d folder, in which I created a separate file per site containing server directive and other configuration.

Now, I have to add Phusion Passenger support to Nginx, and uninstalled the one from the main repositories and manually compiled it to /opt/nginx. This time it gives nginx.conf file, to add my server definition blocks.

Is there any way to tell Nginx to load vhost files from a folder, say /opt/nginx/conf.d?

Omid Kamangar
  • 5,768
  • 9
  • 40
  • 69

2 Answers2

5

You can use this line to include configuration files from the /opt/nginx/conf.d folder:

include /opt/nginx/conf.d/*.conf;

K. S.
  • 586
  • 5
  • 20
1

It all depends on what's written in the nginx.conf, read what kind of folder it includes inside the http block and you'll know where you should put your config files.

In my answer on another question I explained how to create the sites-enabled and sites-available folders, you can replace and/or add more to that include line, using any folder you want, and nginx will read it when reloading the config.

Community
  • 1
  • 1
Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89