Skip to content

Commit 109075b

Browse files
authored
Merge pull request #2483 from rsyracuse/ubuntu18.04-conf.d-edit
[Update] Install NGINX on Ubuntu 18.04
2 parents 0b031b4 + 30dd8c4 commit 109075b

File tree

1 file changed

+15
-21
lines changed
  • docs/web-servers/nginx/install-nginx-ubuntu

1 file changed

+15
-21
lines changed

docs/web-servers/nginx/install-nginx-ubuntu/index.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,36 @@ Currently, the best way to install NGINX on Ubuntu 18.04 is to use the version i
3232

3333
### Add Basic Site
3434

35-
NGINX site-specific configuration files are kept in `/etc/nginx/conf.d/`. Generally you will want a separate file in this directory for each domain or subdomain you will be hosting.
35+
NGINX site-specific configuration files are kept in `/etc/nginx/sites-available` and symlinked into `/etc/nginx/sites-enabled/`. Generally you will want to create a separate original file in the `sites-available` directory for each domain or subdomain you will be hosting, and then set up a symlink in the `sites-enabled` directory.
3636

3737
1. Copy the default configuration file. Replace `example.com` with your website's domain name or your Linode's public IP address.
3838

39-
sudo cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/example.com.conf
39+
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com
4040

41-
2. Disable the default configuration file by adding `.disabled` to the filename:
41+
2. Disable the default configuration file by removing the symlink in `/etc/nginx/sites-enabled/`:
4242

43-
sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled
43+
unlink /etc/nginx/sites-enabled/default
4444

4545
3. Open your site's configuration file in a text editor. Replace `example.com` in the `server_name` directive with your site's domain name or IP address. If you already have content ready to serve (such as a WordPress installation or static files) replace the path in the `root` directive with the path to your site's content:
4646

47-
{{< file "/etc/nginx/conf.d/example.com.conf" nginx >}}
47+
{{< file "/etc/nginx/sites-available/example.com" nginx >}}
4848
server {
4949
listen 80;
50-
server_name example.com;
50+
server_name example.com
5151

52-
#charset koi8-r;
53-
#access_log /var/log/nginx/host.access.log main;
52+
root /var/www/example.com;
53+
index index.html;
5454

55-
location / {
56-
root /usr/share/nginx/html;
57-
index index.html index.htm;
58-
}
59-
60-
#error_page 404 /404.html;
61-
62-
# redirect server error pages to the static page /50x.html
63-
#
64-
error_page 500 502 503 504 /50x.html;
65-
location = /50x.html {
66-
root /usr/share/nginx/html;
67-
}
55+
location / {
56+
try_files $uri $uri/ =404;
57+
}
6858
}
6959
{{< /file >}}
7060

61+
4. Set up a new symlink to the `/etc/nginx/sites-enabled/` directory to enable your configuration:
62+
63+
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
64+
7165
### Test NGINX
7266

7367
1. Test your configuration for errors:

0 commit comments

Comments
 (0)