ADD Nginx Sub-Domains (or WordPress Blogs): VPS BIBLE




new password?
login
X

Adding Sub-Sites with Nginx

sub-site file structure image

Create sub-sites or, for example, prefixed WordPress blogs / Drupal sites quickly & easily. Just create an A record, add a vhost file & symlink and restart Nginx.

This is very similar to adding a domain, which is detailed here and cheat-sheeted here, but not quite the same, so I’ve cranked out this lil’ guide.

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

  .. from blank box to cute-as server ..  

with this easy-to-follow copy/paste guide.

22+ parts with video, here’s the index.

This tutorial presumes you have already set up a site or blog with the VPS Bible, and therefore have already enabled FastCGI and, for WordPress, the required FURL & caching scripts. If not, check out the the Ubuntu-Nginx Bible Index. Otherwise, just substitute “mySubSite” for yours and “mydomain.com” for your_domain.tld throughout this how-to.

Create an A or AAAA Record

If we do this first, by the time everything else is done the new DNS record should have registered and we’ll be ready to go.

Go to your web host’s DNS manager and create an A record, adding the following:-

Hostname IP TTL (Time to Live)
mySubSite the IP you use for mydomain.com shortest option

Save the record and exit the DNS manager. It’ll take a short while for the new setting to propagate. At my VPS, Linode, it’s minutes not hours. Yours? Dunno, but probably no longer than an hour or two.

Add Site Directories

Changing USERNAME for yours, at the terminal type:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

So we have a nicely independent site or blog and, if you like, you can add users to maintain the sub-sites, giving them SFTP access to only that site and so on.

Create a Temp Homepage (optional)

You don’t have to bother with this section, but it can be useful.

Type:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. hit return and paste:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Add Virtual Host (vhost) with FastCGI, FURL Support & Optional WordPress Caching

Type this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Hit return and paste this, with the five domain substitutions:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Option: If you don’t use WordPress with this sub-site, delete the following lines from the above:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Option: If you do want WordPress, and want both pretty permalinks and WP Super Caching support, leave the above, as is.

Option: If you do want WordPress, and want pretty permalinks but not WP Super Caching, swap this:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. for this :-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Save the file.

Create the Symlink and Restart Nginx

Paste this into the terminal:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

And reboot the web server by typing ..


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

.. Or if you followed Edit bashrc for User-Friendly Linux, plus System Updates, just type:-


Please sign up for automatic premium content access.

Just $15/year* will save you hours, maybe days!

Alternatively, the vpsBible forum is free and you are welcome.

Upload your sub-domain files and go check it. If you’re moving an existing site, you should read this for a hassle-free relocation.

Setup Unmanaged VPS: The Ubuntu-Nginx Guide

Take your virtual private server from zero to hero

with this easy-to-follow copy/paste guide.

“My local PC runs Windows” Show me for Linux

22+ parts with video, here’s the index ..

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Already set it up? We’d best maintain it then.

Toggle to the ..  Ubuntu-Nginx Admin Index

Manage Unmanaged VPS: Ubuntu-Nginx Administration

Maintain your virtual private server with ..

.. cheatsheets, tutorials, tips & guides.

Head back to the ..  Ubuntu-Nginx Installation Index

Nginx Admin: In the Works ..

This lot’s marked for addition already:-

  • Setup or Edit DNS using Bind
  • Network Tools Troubleshooting Guide
  • The Comprehensive Permissions Guide
  • Configuring Nginx Rewrites
  • Custom Website Error Page
  • Setting up Cron Jobs
  • Rsync for Incremental Remote-to-Local Backup
  • Cron & Rsync for Automatic Backup
  • Cron & mysqldump for Auto DB Backup
  • Safeguard Bandwidth with Hotlink Protection
  • Block Access with Nginx’ IP Deny



Got a Question? Want to Comment?

This site has no comments system. We've got a better system!

Please use the link at the top of the post and goto this topic's forum thread:-

  • to help build community
  • for a superior knowledge base
  • to keep info in one place, not diluted between forum & comments.

For those posts ported from Guvnr.com (pre-Feb/2010), archive comments remain.

Handy info from these comments is in the process of being ported to the forum and attributed to the original author.

If you think this idea sucks, let me know.

Thank you.

  • eyecool September 4th, 2009 at 8:40 am

    Hey Guvnr, is there an easy was to do domain mapping on nginx and mu? You know, something like ILoveTheGuv.com points to luvguv.yoursite.com or MeetTheGuvnr points to meetme.yoursite.com.

    Thanks for the great guides.

  • Don September 10th, 2009 at 3:58 pm

    Really useful guide, thanks :-]

  • the_guv September 16th, 2009 at 8:33 pm

    @eyecool .. big tx.

    you need Redirect Web Pages with Nginx Rewrite Rule. oh, mu you say, hmmn, not sure that’ll work actually. no, course it won’t!

    er, anyone? (i’m only just getting into wp mu)

    @Don .. lovely dovely, thank you.