Nginx Installation
How to setup nginx
In this article you will learn how to setup NGINX along with is directory structure. You’ll also learn how to setup virtual hosts for NGINX, port forwarding also known as reverse proxy.
We assume that you have already up and running Ubuntu based machine up and running with your hostname and network configure.
If you do not, or you don’t know how to set your hostname for Linux or Ubuntu, please refer to one of our previous articles on how to set your hostname under Ubuntu or Linux.
First update your repositories and upgrade any existing packages that may have installed.
sudo apt-get update
sudo apt-get upgrade |
When all the repositories and upgrade process is completed, you can now install MySQL server and client.
sudo apt-get install mysql-server mysql-client
|
During the installation of MySQL it will ask you for the root password. Please enter the root password for the root user of the MySQL server and remember it as you may need it later when creating new databases, users etc.
Now, our MySQL server is up and running and you can install NGINX web server.
sudo apt-get install nginx
|
When you get “Completed” message it means NGINX is installed. You need to start theservice for NGINX as by default it does not start.
You can start service for NGINX by using below command.
You can start service for NGINX by using below command.
sudo /etc/init.d/nginx start
or sudo service nginx start |
When the service is started you can find your ip address or if you have domain configured and DNS is pointed to the machine you are installing NGINX on, you can try opening it to see the test default page.
In our case, we find our ip address using below command
$ sudo ifconfig
|
We get result “192.168.10.20”
vOpen up any web browser and point URL to http://192.168.10.20 and you should get a default test page of NGINX. This means NGINX is installed and working properly.
Location of Configuration file of nginx
----------------------------------------------
All Nginx configuration files are located in the
/etc/nginx/
directory. The primary configuration file is /etc/nginx/nginx.conf
.
This is where the files will be located if you install Nginx from the package manager. Other possible locations include
/opt/nginx/conf/
.error_log = /var/log/nginx/error.log;
include = /etc/nginx/conf.d/*.conf;
include =/etc/nginx/sites-enabled/*;
by defult path of html folder of nginx in ubuntu :/usr/share/nginx/html
To restart nginx : sudo service nginx restart Or nginx -s reload
To test nginx is started or not: netstat | grep nginx
To test nginx url: curl http://127.0.1.1:81/index.htmlNote:To check NGINX is working or not "netstat -nlp | grep nginx"
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment