We will now build nginx from source rather than installing pre complied versions.(:P) and host a directory
We have to download these files for doing so.
1) latest nginx source code (http://nginx.org)
2) latest PCRE source code (www.pcre.org)
3) latest zlib source code (http://www.zlib.net)
Extract all files etc.. and then cd into the nginx-x.x.x folder
Note:
PATHN = "the path to folder where nginx build will be stored"
PATHP = "the path to pcre folder"
PATHZ = "the path to zlib folder"
Now run
./configure --prefix=PATHN --with-zlib=PATHP --with-pcre=PATHP && make && make install
After some time of compiling, linking etc the nginx binary will be built
cd into the PATHN (nginx folder) . we wil have 4 folders namely sbin , conf , logs , html .
sbin -> nginx built binary
conf -> contains the configuration files
logs -> contains various logs when server is running
html -> basic html files
we can now run the nginx binary and test at 127.0.0.1 or localhost in any browser to get this page.
(nginx should be run with root privileges to bind to port 80(default port))
cd into the conf folder and open nginx.conf
go to server part
change: listen 80 -> listen xxxx . xxxx stands for any valid port
in location: change root html -> root "path of folder you want to host"
also add :-> autoindex on; //if you want to enable automatic directory index
save, close the file.
restart nginx and check the new configuration you have set.
to restart nginx -> run killall nginx
-> run nginx binary again
All done :)
We have to download these files for doing so.
1) latest nginx source code (http://nginx.org)
2) latest PCRE source code (www.pcre.org)
3) latest zlib source code (http://www.zlib.net)
Extract all files etc.. and then cd into the nginx-x.x.x folder
Note:
PATHN = "the path to folder where nginx build will be stored"
PATHP = "the path to pcre folder"
PATHZ = "the path to zlib folder"
Now run
./configure --prefix=PATHN --with-zlib=PATHP --with-pcre=PATHP && make && make install
After some time of compiling, linking etc the nginx binary will be built
cd into the PATHN (nginx folder) . we wil have 4 folders namely sbin , conf , logs , html .
sbin -> nginx built binary
conf -> contains the configuration files
logs -> contains various logs when server is running
html -> basic html files
we can now run the nginx binary and test at 127.0.0.1 or localhost in any browser to get this page.
(nginx should be run with root privileges to bind to port 80(default port))
cd into the conf folder and open nginx.conf
go to server part
change: listen 80 -> listen xxxx . xxxx stands for any valid port
in location: change root html -> root "path of folder you want to host"
also add :-> autoindex on; //if you want to enable automatic directory index
save, close the file.
restart nginx and check the new configuration you have set.
to restart nginx -> run killall nginx
-> run nginx binary again
All done :)
No comments:
Post a Comment