The configuration of two-level domain name and multi-domain Site directory structure is the default path of storing source code under the installation directory of Nginx html├──bbs└──wwwhtml. BBS for Forum program source code path WWW for home page program source code path put the corresponding program into the above path through http://www.youdomain.com access is the home page http://bbs.yourdomain.com Access to the Forum Other level two domain name analogy. server {Listen 80; Server_Name ~^ (? <subdomain>.+) \.yourdomain\.com$; Root html/$subdomain; Index index.html index.htm index.php; Fastcgi_intercept_errors on; Error_page 404 =/404.html; Location/{# This is cool because no PHP are touched for static content. # include the "? $args" part so non-default permalinks doesn ' t # break when using query string Try_files $uri $uri/= 404; } # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.htm L Location =/50x.html {root html; # Pass the PHP scripts to FastCGI server listening in 127.0.0.1:9000 # location~ \.php$ {Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Fastcgi_param domain $subdomain; Include Fastcgi_params; } # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # loc ation ~/\.ht {deny all; }} To summarize the steps is 1. Add the above red configuration to your domain name after adding it to your nginx.conf Profile 2. Confirm the two-level domain name that you want to add, such as bbs.yourdomain.com3. Set bbs.yourdomain.com resolves to your nginx server ip4 Create BBS directory in HTML directory 5. Put the source into the BBS directory 6. Reload nginx config kill-hup ' cat/usr/local/lnmp/nginx/nginx.conf ' (need to change the path of the above command to your profile path) 7. Visit http://bbs.yourdomain.com
Configure two-level domain names and multi-domain names with nginx pan domain name resolution