Lab 1.1 Install Open Source Nginx On Centos
Lab 1.1 Install Open Source Nginx On Centos
vim /etc/yum.repos.d/nginx.repo
nginx
curl localhost
vim /etc/nginx/moduletest.js
vim /etc/nginx/nginx.conf
8. In the HTTP context (between the brackets following http) enter the following:
js_include moduletest.js;
9. Beneath the line you just entered, paste the following nginx configuration:
10. server {
11. listen 80;
12. location / {
13. js_content moduleTest;
14. }
15. }
16. Save and exit nginx.conf
17. Rename nginx default configuraiton.
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
nginx -s reload
You should get an error - unknown directive. This indicates that the njs module
hasn't been installed.
vim /etc/nginx/nginx.conf
21. Near the top of the file nginx.conf, add the following lines to enable the njs module in
both the http and stream modules:
22. load_module modules/ngx_http_js_module.so;
23. load_module modules/ngx_stream_js_module.so;
24. Save and exit nginx.conf
25. Reload nginx to affect changes
nginx -s reload
curl localhost
You should see the output of our javascript, "the njs module was loaded"