Difference between revisions of "Subdomain setup"

From Dreamwidth Notes
Jump to: navigation, search
(Configuration)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
== DNS Management ==
 
== DNS Management ==
  
First, you will also have to set up a wildcard subdomain record with your host. If you are hosting your installation on Linode, here is an example of how to do this.
+
First, you will have to set up a wildcard subdomain record for your host. Different hosting providers have different interfaces, but here are some examples.
  
Go to the DNS Manager section of your account and click on the domain zone your DW install is hosted on. Go to the "A/AAA Records" section and note the IP address of the hosts:
+
=== On Linode ===
 +
 
 +
Go to the DNS Manager section of your account and click on the domain zone your DW install is hosted on. Go to the "A/AAAA Records" section and note the IP address of the hosts:
  
 
[[Image:Linode a records.png]]
 
[[Image:Linode a records.png]]
  
(Note: the above picture already has the wildcard listed in it.  Yours won't have that yet, but will when you finish this.) You will want to click on "Add a new A/AAA Record":
+
(Note: the above picture already has the wildcard listed in it.  Yours won't have that yet, but will when you finish this.) You will want to click on "Add a new A/AAAA Record":
  
 
[[Image:Linode subdomain wildcard.png]]
 
[[Image:Linode subdomain wildcard.png]]
  
Here, you will want to add <code>*.yourdomain.com</code> and the IP address you noted on the last page.  Save this form and a wildcard subdomain should be added to your A/AAA Records section.
+
Here, you will want to add <code>*.yourdomain.com</code> and the IP address you noted on the last page.  Save this form and a wildcard subdomain should be added to your A/AAAA Records section.
 +
 
 +
 
 +
=== Local development via dnsmasq ===
 +
 
 +
If you've set up a Dreamwidth development server on your local machine, you can use <tt>dnsmasq</tt> to give you a local DNS server with wildcard matching.  Install it with
 +
    apt-get install dnsmasq
 +
The install should create the config directory <tt>/etc/dnsmasq.d/</tt> -- text files in there will be picked up and added to <tt>dnsmasq</tt>'s configuration.
 +
 
 +
Say you have a local webserver that you want to set up as <tt>avengers.mylocal</tt>.  Create a file in <tt>dnsmasq</tt>'s config directory (eg <tt>/etc/dnsmasq.d/avengers</tt>) with the following contents:
 +
    address=/avengers.mylocal/127.0.0.1
 +
Now restart dnsmasq:
 +
    /etc/init.d/dnsmasq restart
 +
...and now anything ending in <tt>avengers.mylocal</tt> should resolve to <tt>127.0.0.1</tt>: <tt>avengers.mylocal</tt>, <tt>www.avengers.mylocal</tt>, <tt>thor.avengers.mylocal</tt>, <tt>www.loki.avengers.mylocal</tt>, ...
  
 
== Configuration ==
 
== Configuration ==
  
To configure your installation for user subdomains, uncomment the bolded lines in <code>etc/ljconfig.pl</code>:
+
{{Note|text=This section is enabled by default (note current as of November 2015).}}
  
# Support URLs of the form http://username.yoursite.com/ ?
+
To configure your installation for user subdomains, uncomment the bolded lines in <code>$LJHOME/etc/config.pl</code>:
# If so, what's the part after "username." ?
+
 
<b>$USER_VHOSTS = 1;
+
<source lang="perl"># Support URLs of the form http://username.yoursite.com/ ?
$USER_DOMAIN = $DOMAIN;</b>
+
# If so, what's the part after "username." ?
 +
$USER_VHOSTS = 1;
 +
$USER_DOMAIN = $DOMAIN;
 
   
 
   
# If you ONLY want USER_VHOSTS to work and not the typical /users/USER and /community/USER
+
# If you ONLY want USER_VHOSTS to work and not the typical /users/USER and /community/USER
# then set this option:
+
# then set this option:
<b>$ONLY_USER_VHOSTS = 1;</b>
+
$ONLY_USER_VHOSTS = 1;</source>
  
 
If you only want certain user classes to have user subdomains, <b>do not</b> set <code>$ONLY_USER_VHOSTS</code> to 1, or journals who do not have this user capability won't work!
 
If you only want certain user classes to have user subdomains, <b>do not</b> set <code>$ONLY_USER_VHOSTS</code> to 1, or journals who do not have this user capability won't work!
  
You will also have to set a user capability in <code>etc/ljconfig.pl</code> called <code>userdomain</code>.  If you want all users to have this capability, add it to %CAP_DEF:
+
You will also have to set a user capability in <code>etc/config.pl</code> called <code>userdomain</code>.  If you want all users to have this capability, add it to <code>%CAP_DEF</code>:
  
%CAP_DEF = (  
+
<source lang="perl">%CAP_DEF = (  
 
         'maxfriends' => 500,
 
         'maxfriends' => 500,
 
         'userpics' => 1,
 
         'userpics' => 1,
Line 41: Line 58:
 
         'findsim' => 1,
 
         'findsim' => 1,
 
         'getselfemail' => 0,
 
         'getselfemail' => 0,
         <b>'userdomain' => 1</b>
+
         'userdomain' => 1
);
+
);</source>
  
 
Otherwise, you will have to add <code>'userdomain' => 1</code> to one or more of the user classes listed in <code>%CAP</code>.
 
Otherwise, you will have to add <code>'userdomain' => 1</code> to one or more of the user classes listed in <code>%CAP</code>.
 +
 +
You also need to add an entry to <code>%SUBDOMAIN_FUNCTIONS</code> (and create this hash if it does not already exist):
 +
 +
<source lang="perl">%SUBDOMAIN_FUNCTION = (
 +
    'community' => 'journal',
 +
);</source>
  
 
[[Category: Dreamwidth Installation]]
 
[[Category: Dreamwidth Installation]]

Latest revision as of 15:09, 16 November 2015

DNS Management

First, you will have to set up a wildcard subdomain record for your host. Different hosting providers have different interfaces, but here are some examples.

On Linode

Go to the DNS Manager section of your account and click on the domain zone your DW install is hosted on. Go to the "A/AAAA Records" section and note the IP address of the hosts:

Linode a records.png

(Note: the above picture already has the wildcard listed in it. Yours won't have that yet, but will when you finish this.) You will want to click on "Add a new A/AAAA Record":

Linode subdomain wildcard.png

Here, you will want to add *.yourdomain.com and the IP address you noted on the last page. Save this form and a wildcard subdomain should be added to your A/AAAA Records section.


Local development via dnsmasq

If you've set up a Dreamwidth development server on your local machine, you can use dnsmasq to give you a local DNS server with wildcard matching. Install it with

   apt-get install dnsmasq

The install should create the config directory /etc/dnsmasq.d/ -- text files in there will be picked up and added to dnsmasq's configuration.

Say you have a local webserver that you want to set up as avengers.mylocal. Create a file in dnsmasq's config directory (eg /etc/dnsmasq.d/avengers) with the following contents:

   address=/avengers.mylocal/127.0.0.1

Now restart dnsmasq:

   /etc/init.d/dnsmasq restart

...and now anything ending in avengers.mylocal should resolve to 127.0.0.1: avengers.mylocal, www.avengers.mylocal, thor.avengers.mylocal, www.loki.avengers.mylocal, ...

Configuration

Note: This section is enabled by default (note current as of November 2015).

To configure your installation for user subdomains, uncomment the bolded lines in $LJHOME/etc/config.pl:

# Support URLs of the form http://username.yoursite.com/ ?
# If so, what's the part after "username." ?
$USER_VHOSTS = 1;
$USER_DOMAIN = $DOMAIN;
 
# If you ONLY want USER_VHOSTS to work and not the typical /users/USER and /community/USER
# then set this option:
$ONLY_USER_VHOSTS = 1;

If you only want certain user classes to have user subdomains, do not set $ONLY_USER_VHOSTS to 1, or journals who do not have this user capability won't work!

You will also have to set a user capability in etc/config.pl called userdomain. If you want all users to have this capability, add it to %CAP_DEF:

%CAP_DEF = ( 
         'maxfriends' => 500,
         'userpics' => 1,
         'checkfriends_interval' => 60, 
         'checkfriends' => 1,
         'styles' => 0,
         'todomax' => 25, 
         'todosec' => 0,
         'friendsviewupdate' => 30, 
         'findsim' => 1,
         'getselfemail' => 0,
         'userdomain' => 1
);

Otherwise, you will have to add 'userdomain' => 1 to one or more of the user classes listed in %CAP.

You also need to add an entry to %SUBDOMAIN_FUNCTIONS (and create this hash if it does not already exist):

%SUBDOMAIN_FUNCTION = ( 
    'community' => 'journal',
);