Method of installation and configuration of nginx server
This article mainly explains "the method of installation and configuration of nginx server". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the method of installation and configuration of nginx server".
Installation and configuration of nginx server
1. Installation
1) installation in windows environment
After downloading the windows version of nginx, extract it, then go to the directory, and run: start nginx
Other commands: nginx-s [stop | quit | reopen | reload]
2) installation under linux
The code is as follows:
Tar zxvf pcre-8.21.tar.gz (required to install nginx)
. / configure
Make
Make install
Cp / usr/local/lib/libpcre.so.1 / usr/lib
Tar zxvf nginx..../tar.gz
Cd nginx...
. / configure
Make
Make install
Startup of 2.nginx
Linux command: / usr/local/nginx/sbin/nginx-c / usr/local/nginx/conf/nginx.conf
(- c means specified profile)
Stop of 3.nginx
The code is as follows:
Ps-ef | grep nginx
Find master process's id.
Id of kill-QUIT nginx
Quick stop
Id of kill-TERM nginx
Force shutdown of all processes in nginx
Pkill-9 nginx
Restart of 4.nginx
1) check whether the configuration file is correct
/ usr/local/nginx/sbin/nginx-t-c / usr/local/nginx/conf/nginx.conf
2) smooth restart
Kill-HUP Nginx main process number
If the configuration file is incorrect, nginx will still use the modified configuration file
Basic configuration of nginx
As can be seen from the configuration file example, the structure of the nginx.conf configuration file is mainly composed of:
The code is as follows:
....
Events
{
...
}
Http
{
....
Server
{
...
}
Server
{
...
}
...
}
Virtual host configuration
The code is as follows:
# server {
# listen 8000
# server_name localhost
# server_name somename alias another.alias
# location / {
# root html
# index index.html index.htm
#} www.yisu.com
#}
# server {
# listen 8080
# server_name localhost
# server_name somename alias another.alias
# location / {
# root html
# index index.html index.htm
#}
#}
Thank you for your reading, the above is the content of "the method of installation and configuration of nginx server". After the study of this article, I believe you have a deeper understanding of the method of installation and configuration of nginx server, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!