Overview
This article explains where configuration files should be placed on Nginx servers at DreamHost. View the following articles for examples of custom configuration files you could create:
- How to make statistics and permalinks work with WordPress and Nginx
- Password protecting directories with Nginx
- Creating redirects with Nginx
- Blocking IPs with Nginx
Will my .htaccess file function?
Nginx does not support directory-level configurations (such as .htaccess) outside of the primary server configuration file. However, it's still possible to set up local configuration files under your username.
Local website configuration files
This section explains how to create a directory for website configuration files.
Where should configuration files be placed?
-
Nginx uses a directory named /nginx under your website username. In this directory, you'll add another directory for your website. For example:
/home/username/nginx/example.com
This is the only directory you should place any configuration files you want your website to use.
The /nginx/example.com directory does not exist by default. You must create it manually.
Creating the configuration directory
-
- Log into your server via SSH.
- Navigate to your user's home directory.
- Run the following command:
[server]$ mkdir -p nginx/example.com
The two Nginx directories
-
To clarify, you'll now have two directories your domain uses:
Your website directory: This is your website directory where all files are located.
-
/home/username/example.com
Your nginx configuration directory: This is where all Nginx config files are located.
-
/home/username/nginx/example.com
-
How should files be named?
-
You can name your files anything you like, but they must all use the .conf extension. Nginx will look for files with this extension to insert into the server block of the nginx.conf file.
The nginx.conf file (Dedicated servers only)
The server's config file can only be seen or edited if you're using an admin user on a Dedicated Server.
- Log into your Dedicated Server via SSH.
- Navigate to the /etc/nginx directory:
[server]$ cd /etc/nginx
- Use sudo to view the directory contents:
[server]$ sudo ls -la
- Enter your password when prompted. You'll see the nginx.conf file listed.
-
Edit the file using sudo:
[server]$ sudo nano nginx.conf
- Save and close the file and return to your shell.