Here.
And welcome back.
In today's video, we will look into how we can build static modules in Nginx.
Now, we have already looked about how the dynamic modules work practically in Nginx, where you first
compile the module and then you reference it with a load module directive followed by the module path.
So this was pretty straightforward.
And in dynamic configuration you don't really have to recompile your nginx version.
So your Nginx version in production remains the same.
The only thing that you're doing is you're compiling the module by itself and then referencing it within
the nginx configuration.
So the nginx binary remains untouched.
However, in static modules things are a little different.
So static modules are compiled into the Nginx server binary at compile time.
So whenever you are compiling your Nginx, you have to reference the module there.
Whenever you are discussing about the static modules.
So it is not like you already have the nginx binary compiled and running in production and then you
want to add one more module there.
So as far as static modules are concerned, that really is not really the approach there.
So let's look into the steps which are required for building static modules.
First is to fetch the Nginx source, second is to fetch the module source.
So this two step remains similar and the step three is to build the static module along with Nginx.
Now for dynamic module we only use to build dynamic module.
However, for static module you will have to build the nginx itself because here the nginx is also compiled.
So let's look into the steps which are required.
Now.
In the previous video we had built the dynamic module.
Now if you do a nginx hyphen V, you will not really see that specific helloworld module because it
is dynamic and whatever module that you generally reference, here are the static modules.
So in today's video we'll be building static modules.
So in order to do that, let's do one thing.
Let's quickly verify the status of Nginx.
It is running.
I'll stop the Nginx service and I'll remove the Nginx directory and I'll also remove the nginx binary
by itself.
All right, great.
So now let's go to the Nginx demo directory.
We'll go to Nginx one point 16.0 and here during the configuration option we'll use the same configuration
option which you remember we had done while building Nginx from source.
So while compiling Nginx from source we had run this specific command.
We'll use the same command here.
In addition, we have to also specify the static module here.
Now, basically if you look into the Hello world we already discussed about the dynamic module this
time we have to see the static module.
So the static module here, the only difference is you remove the dynamic here.
So this is Add module followed by the module path.
And for dynamic module you have add dynamic module followed by the module path.
And basically this command remains the same.
It is not just specific to the Hello World module.
Any other module you will build, the overall process remains the same.
The only thing that will change is the config file here as well as the module file.
So let's try this out.
So I'll say hyphen, hyphen hyphen module and let's specify the module path which is.
Let's go better.
Let's get the exact directory name where the module config is present.
All right.
So this is the exact path.
So now together, we'll copy this entire command.
We'll go back to the Nginx source directory and we'll run this command.
So this will go ahead and not only build your nginx binary, but this binary will have the static module
that we had referenced.
So the next command would be make.
And the last command would be make install.
Great.
So now if you go to the Nginx directory, these are the configuration files.
Let's go ahead and start Nginx.
All right.
And if you do a nginx hyphen v here, you will see that there is one more parameter which is add module
which is your Hello world module here.
So now you don't really have to do a load module directive that we had done typically during the dynamic
module time.
So in order to verify, let's open up the Nginx configuration and let's go a bit down and we'll copy
the same server block that we had used during the dynamic module.
So this is the same server block that we had used.
Now here we are not doing load module.
So now let's quickly verify.
Everything seems to be working perfectly.
Let's restart Nginx.
All right.
So now if you do a curl on localhost colon 8080, you should see hello world as expected.
So I hope at a high level overview you understood what static modules are and you also understood what
dynamic modules are.
So with this, we'll conclude this video.
I hope this video has been informative for you and I look forward to see you in the next video.