1, we go to the next / usr / local / nginx, open the configuration file nginx.conf
cd /usr/local/nginx
vim nginx.conf
So we opened the nginx configuration file, the basic configuration is as follows:
the nobody #user; // set user worker_processes 1 ; // set the number of worker processes If the machine is 4 core 8 threads, we can set 8 Events { worker_connections 1024 ; // set the maximum number of concurrent connections 1024 } HTTP { the include mime.types ; default_type file application / OCTET - Uninterpreted Stream; #log_format main ' $ REMOTE_ADDR - $ REMOTE_USER [$ time_local] "$ Request" ' # ' $ $ body_bytes_sent Status "$ HTTP_REFERER" ' # ' "$ HTTP_USER_AGENT" "$ HTTP_X_FORWARDED_FOR"'; logs #access_log / the access.log main; the sendfile ON; #tcp_nopush ON; #keepalive_timeout 0 ; keepalive_timeout 65 ; #gzip ON; Server { the listen 80 ; // monitor interface (not lose semicolon) server_name localhost; // address can be written ip domain name can also write #charset KOI8 - r; #access_log logs / host.access.log main; LOCATION / { // can pass ~ = / blah blah root HTML; // default access folders index.html index.htm index; // file matching } error_page 500 502 503 504 /50x.html; // given access HTML LOCATION /50x.html = { // = / precise match the root HTML; } } }
2, we can, so we own together with some of their own code is arranged after the server according to written comments on the various uses of the code:
server { listen 8000; server_name www.wuaipic.cn; location / { root wuaipic; index index.html index.htm; } }
In this code, I set the listening port 8000 access address (domain name) is www.wuaipic.cn, we set the access path for the wuaipic files in / usr / local / nginx folder, we save about changes, and then restart nginx .
3, we created a simple html in wuaipic folder named index.html and edit content:
<html>
<h1>123456</h1>
</html>
4, of course, we can directly replace the domain name ip address of the virtual machine, if you want to set up a domain name, we need to open the C window systems:. \ Windows \ System32 \ drivers \ etc modify the hosts file to add the path inside *** * **. ***. *** (ip address) www.wuaipic.cn, so our windows system can access a domain name
192.168.42.128 www.wuaipic.cn
5, we access the browser look www.wuaipic.cn:8000, the browser will output the contents of the html
6, if the situation can not be accessed, please refer to an essay on the firewall settings, the 8080 to 8000 can be.