Skip to content

Creating a vhost

omgslinux edited this page Mar 6, 2025 · 4 revisions

For creating a vhost, you have to check the existing vhost types and choose the one that fits your needs. So, check the Templates page if you don't know the existing vhost types and find the proper one.

  1. Create a directory for your vhost in the working directory. It can be any name, but the recommended name is the same name as your vhost (not needed FQDN).
  2. Place a copy of the example file for your vhost in this directory. Again, this file can have any name, as long as it has the .inc extension. The recommended name here is vhost.inc.
  3. Edit the vhost.inc file and set the parameters for your vhost.
  4. Once you've finished editing, you have to generate the vhost files with mkvhost. From the working directory, run ./mkvhost <dir>, where <dir> is the directory name you created for your vhost. You can use several directories as arguments. A message will appear saying that the vhost file, link and log files have been created.
  5. Check the /etc/nginx/conf.d directory for the instructions given in every template.
  6. Check with nginx -t that there are no errors. Also, if you want, you can take a look at the contents of the generated file.
  7. When you please, you can restart nginx.

That's all!!

Clone this wiki locally