Configure two-level domain names and multi-domain names with nginx pan domain name resolution
The directory structure of the site is html├──bbs└──www
HTML is the default installation directory for the source code path.
BBS for Forum program source code path WWW for Home 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 is the forum other two-level 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 is 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 500 502 503 504 /50x.html; location = /50x.html { root html; } # pass the PHP scripts to fastcgi server listening on 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; }&nbsP; # deny access to .htaccess files, if apache ' S document root # concurs with nginx ' s one # location ~ /.ht { deny all; } }
A summary of the steps is
1. Replace the above red configuration with your domain name and add it to your nginx.conf profile
2. Confirm the level two domain name you want to add, such as bbs.yourdomain.com
3. Set bbs.yourdomain.com resolution to your Nginx server IP
4. Create BBS directory in HTML directory
5. Put the source into the BBS directory
6. Reload the Nginx configuration
Kill-hup ' cat/usr/local/lnmp/nginx/nginx.conf '
(You 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