Example of getting started with nginx

nginx uses domain name access

 (Tip) nginx directory resolution

  conf/nginx.conf
  #Main configuration file directory html #The default release directory of nginx. After deployment, the website will be installed in this directory. The
  nginx installation directory is: /usr/local/nginx    Configuration file directory: /usr/local/nginx/conf Release directory: /usr/local/nginx/html

 

(1) Modify the configuration file nginx.conf in the /usr/local/nginx/conf directory and add it to the original nginx.conf file

 

    # 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;
    # }
    #}

#Add the following configuration
server under the above file { listen
80; server_name www.ddffxx.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root html/demo; index index.html index.htm; } }

 

Configuration parsing:

server #represents       a service

listen #Define          the listening port number

server_name #Define       the input domain name when accessing

location               #path 

root           #nginx published folder naming

index         #pages under the folder published by nginx

 

(2) Create new folders and pages according to the configuration in the configuration file

  cd /usr/lcoa/nginx #Enter   the nginx installation directory

  cd html #Enter    the release directory

  mkdir demo #Create the file directory specified by root in the new configuration file

  cp index.html demo #Copy the default index.htm page to the demo directory. (This corresponds to the configuration of the index)

 

(3) Modify the hosts file of Windows

  File location:  C:\Windows\System32\drivers\etc hosts

  Add the following configuration at the end of the file: The host ip where nginx is installed The server_name specified in the nginx configuration file, the example is as follows:

       119.23.24.87    www.ddffxx.com

 

(4) Start nginx on linux

    /usr/local/nginx/sbin/nginx

 

(5) Access nginx in the browser

    www.ddffxx.com

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814964&siteId=291194637