Freebsd Install Nginx

27 Januari 2021 • 2 menit untuk membaca artikel ini

Install nginx:

[email protected]:~ # pkg install nginx
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
  nginx: 1.20.1_3,2
  pcre: 8.45

Number of packages to be installed: 2

The process will require 8 MiB more space.
2 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/2] Fetching nginx-1.20.1_3,2.pkg: 100%  458 KiB 117.3kB/s    00:04
[2/2] Fetching pcre-8.45.pkg: 100%    1 MiB 104.3kB/s    00:12
Checking integrity... done (0 conflicting)
[1/2] Installing pcre-8.45...
[1/2] Extracting pcre-8.45: 100%
[2/2] Installing nginx-1.20.1_3,2...
===> Creating groups.
Using existing group 'www'.
===> Creating users
Using existing user 'www'.
[2/2] Extracting nginx-1.20.1_3,2: 100%
=====
Message from nginx-1.20.1_3,2:

--
Recent version of the NGINX introduces dynamic modules support.  In
FreeBSD ports tree this feature was enabled by default with the DSO
knob.  Several vendor's and third-party modules have been converted
to dynamic modules.  Unset the DSO knob builds an NGINX without
dynamic modules support.

To load a module at runtime, include the new `load_module'
directive in the main context, specifying the path to the shared
object file for the module, enclosed in quotation marks.  When you
reload the configuration or restart NGINX, the module is loaded in.
It is possible to specify a path relative to the source directory,
or a full path, please see
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/ and
http://nginx.org/en/docs/ngx_core_module.html#load_module for
details.

Default path for the NGINX dynamic modules is

/usr/local/libexec/nginx.

Enable service nginx:

[email protected]:~ # sysrc nginx_enable="yes"
nginx_enable:  -> yes

command tadi akan menambahkan baris nginx_enable="yes" pada file /etc/rc.conf

Start service nginx:

[email protected]:~ # service nginx status
nginx is not running.
[email protected]:~ # service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
[email protected]:~ # service nginx status
nginx is running as pid 2545.

Konfigurasi nginx freebsd ada di:

/usr/local/etc/nginx/

Mencoba edit konfigurasi nginx

ee /usr/local/etc/nginx/nginx.conf

...
...
        location / {
            default_type application/json;
            return 200 '{"code":"0", "message": "I am alive"}';

            root   /usr/local/www/nginx;
            index  index.html index.htm;
        }
...
...
[email protected] ~ % curl -i http://10.211.55.5
HTTP/1.1 200 OK
Server: nginx/1.20.1
Date: Sun, 21 Nov 2021 17:16:20 GMT
Content-Type: application/json
Content-Length: 37
Connection: keep-alive

{"code":"0", "message": "I am alive"}%

Sumarsono

DevOps Engineer
Kembali ke atas

Freebsd Install Mysql Server>>

<<Freebsd Check Listening Port