Install NGINX on FreeBSD

Installing NGINX

  1. Install NGINX
     $ pkg install nginx
  2. Create folder
     $ mkdir /data/www
  3. Find configuration file nginx.conf
    It’s either in /usr/local/nginx/conf, /etc/nginx or /usr/local/etc/nginx
  4. Edit conf file, comment out everything then add a new server block
     http {
         server {
         }
     }
  5. Add a location into the server block
     location / {
       root /data/www;
     }
     location /images/ {
       root /data;
     }
  6. Create a basic html file in /data/www
    <html>
    <head></head>
    <body><h1>hello NGINX</h1></body>
    </html>
    
  7. Start nginx
    $ nginx
    
  8. To stop NGINX use
    $ nginx -s stop

sample nginx.conf file


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *