1. Download
At present (2015-07-11), the stable version of nginx is 1.8.0, download it from the official website first, the windows version of nginx 1.8.0
This is a zip file that can be used after unzipping
2. Start
The green file can be started directly without installation.
As far as I know, the 3 startup paths are actually similar:
1. Double-click the nginx.exe icon, a black window can be seen flashing by, and the startup is complete.
Second, the command line to the nginx directory, enter nginx to start. (Note, in this way the command line window has no prompts and is locked)
3. Go to the nginx directory from the command line, enter start nginx to start, this method is not locked
After startup, by default (without modifying the configuration), you can see that there are two nginx processes, one is the master process and the other is the worker process.
If you configure 2 worker_processes in the configuration, you will see 1 master process and 2 worker processes in the process.
3. Test
By default nginx deploys some static content, we can use it to test whether nginx is working.
The default configuration file (NGINX_HOME/conf/nginx.conf) is as follows:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
By observing the non-commented items of the configuration file (refer to the detailed explanation of the Nginx configuration file nginx.conf in Chinese ), we can know that:
1. Started a worker process
2. worker_connections, the maximum concurrent number is 1024
3. include mime.types, import the file extension and file type mapping declared by the mime.types file
4. application/octet-stream, use application/octet-stream by default
5, sendfile, open the efficient file transfer mode
6. Listen to port 80 of the local "localhost"
7. The mapping directory is "html directory of the current directory"
8. If 500, 502, 503, 504 errors occur, map to 50x.html
Browse the address http://localhost to access its default page, which is mapped to NGINX_HOME/html/index.html
Other static content, such as html and pictures, can be tested by themselves.
4. Logs
The log is located in NGINX_HOME/logs/ by default, which can be seen:
1, access.log, access log
2, error.log, exception log
3. nginx.pid, process (this log is only available after starting nginx)
5. Installation of Nginx under CentOS
tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure make make install /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
After the installation is complete, check the process and related logs:
ps -ef | grep nginx less /usr/local/nginx/logs/error.log less /usr/local/nginx/logs/nginx.pid less /usr/local/nginx/logs/access.log