How
to install NGINX:
To
install nginx type
#apt-get
install nginx
To
restart the nginx service
#
/etc/init.d/nginx restart
Then
go to the file and default file it will be generated will nstalling
nginx
#rm
-rf /etc/nginx/sites-enabled/default
#
rm -rf /etc/nginx/sites-available/default
To
create a new configuration file
#
vim /etc/nginx/sites-available/basic
Inside
the file use this format
server { listen 127.0.0.1:80; server_name basic; access_log /var/log/nginx/basic.access.log; error_log /var/log/nginx/basic.error.log; location / { root /var/www/basic; index index.html index.htm; } }
Then
create a root directory and index.html file
#
mkdir /var/www/basic
# cd /var/www/basic
#
vim index.html
here
type your website files
To
enable the site and restart nginx
# cd /etc/nginx/sites-enabled # ln -s ../sites-available/basic # /etc/init.d/nginx restart then go to browser and type http;//127.0.0.1/ then your site will be open using nginx
STATIC
IP PROCESS:
for
this you have to assign static ip
#
vim /etc/network/interface
there
change the address, netmask, gateway for example
auto
lo
iface
lo inet loopback
address
192.168.1.249
netmask
255.255.255.0
gateway
192.168.1.1
then
save
after
that go to resolv.conf
#
vim /etc/resolv.conf
and
here #(comment) the old name server
if
you are using internet means give the dns server name of the service
provider
then
save
then
go to the nginx for ip resolution
RESOLVING
THE SITE WITH IP ADDRESS:
#
vim /etc/nginx/sites-avialable/basic
server
{
listen
192.168.1.249:80;
(here it is new ip address which we have given)
server_name
basic;
access_log
/var/log/nginx/basic.access.log;
error_log
/var/log/nginx/basic.error.log;
location
/ {
root
/var/www/basic;
index
index.html index.htm;
}
}
then
save
then
go
#vim
/etc/hosts
give
the new ip address and name of server
for
exp: 192.168.1.249 basic
then
save
then
after start the service
#/etc/init.d/nginx
restart
then
go to browser and give the new address.
TO
RESOLVE NGINX WITH HOSTNAME:
Go
to nginx
#
vim /etc/nginx/sites-available/basic
then
server
{
listen
192.168.1.249:80;
server_name
sunny.example.com;
(which we would like to give)
access_log
/var/log/nginx/basic.access.log;
error_log
/var/log/nginx/basic.error.log;
location
/ {
root
/var/www/basic;
index
index.html index.htm;
}
}
then
save
then
go to
#
vim /etc/hosts
192.168.1.249
sunny.example.com
then
save
after
this start the service
#/etc/init.d/nginx
restart
then
go browser and type the server name like sunny.example.com then the
site will be resolved
No comments:
Post a Comment