Here’s what I did to install a successful installation of Discourse for multiple instances on a dedicated server that uses Nginx and Apache.
I decided to create a new topic since my installation seems to be a little unique from what I have seen others having to go through. I am very new to Nginx webservers and thought this might help others who may be struggling to connect the dots. I’m also at a beginner level when it comes to using the terminal to access my server, I still have to look up commands for most of the stuff I want to do, but I am finding it so much faster and powerful vs FTP. I still use FTP for a visual representation to locate files and text editing (I don’t like vi or nano editing in the terminal) I use Coda (on a Mac) as my text editor so I have direct access to the server. Which means I can live edit my files just as one would do in the terminal.
I’m using ServerPilot as the control panel to manage my websites on an Ubuntu 14.04 installation. ServerPilot uses Nginx as a reverse proxy in front of the Apache webserver. At first I was a bit confused with this, and basically what they have done is use Nginx as the hub where website requests come into the Nginx server and get routed to Apache to be executed and then back through Nginx to be displayed. This proved to cause some trouble with my installation as I had to figure out where all the config files and such were located.
I started with this tutorial for installing the first instance of Discourse as a dev version …
https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md
Pay special attention to the TCP/IP ports as that was the first place I stumbled, and I see a lot of other posts in the forums from other people who have done the same. If you leave them at the default “80:80” you may get an error stating that port is already in use.
Change the first half of the ports to a port that is not being used, I used 85
This got me through the installation with no errors, but when I went to the url I setup for the forum nothing was showing up. I could connect to the forum using the IP with the port number. Since the forum doesn’t need Apache, I found the conf file that was directing the site to the Apache server with a local IP. I changed this IP to the forum IP with port number.
The path to that section (if you’re also using ServerPilot)
/etc/nginx-sp/vhosts.d/main.conf
(ServerPilot recommends that you change the name of the main.conf file so it is not overwritten on updates)
Now I had a working instance of Discourse, and here’s what I did to set up the multiple instances.
I started with this tutorial, but I was having trouble understanding how the structure was supposed to be setup
If you scroll down to this section …
https://meta.discourse.org/t/multisite-configuration-with-docker/14084/18
This is where I based my installation from, however I did not use the hook settings in the original post. Instead, I duplicated the app.yml file for each site I was creating (only two sites) and renamed them for site specific use. I’ll use the example - site1 and site2.
So in the /var/discourse/containers the files there are as such …
app.yml
site1.yml
site2.yml
(these are your separate containers, which was a term that I didn’t understand at first)
For each file you need to make sure to change the following areas to be specific to your instance …
## which TCP/IP ports should this container expose?
expose:
- "127.0.0.1:4000:80" # fwd host port 80 to container port 80 (http)
- "2222:22" # fwd host port 2222 to container port 22 (ssh)
Notice I changed the first port on both, otherwise you will get port conflict errors.
## TODO: List of comma delimited emails that will be made admin and developer
## on initial signup example 'user1@example.com,user2@example.com'
DISCOURSE_DEVELOPER_EMAILS: 'changeme@site1.com'
change the developer email to the email you will use for the admin account
In the mailserver section that follows, be sure to change any settings that are specific to this site such as the username and password. I ended up using Mandrill so the smtp and port numbers were the same for all instances, but I created two accounts. (one for each website)
This next section to edit is key to you getting a separate database for each site. Be sure to change the ‘yoursite’ to something unique to each site.
## These containers are stateless, all data is stored in /shared
volumes:
- volume:
host: /var/discourse/shared/yoursite
guest: /shared
- volume:
host: /var/discourse/shared/yoursite/log/var-log
guest: /var/log
The next thing to do is make sure you have the Nginx proxy URL (the one that is pointing to Apache) changed to match the port you configured in the TCP/IP section. So using the port I used as an example your file should look like this and as I mentioned above, ServerPilot recommends changing the name of the file if you MUST edit (that’s why they give the do not edit warning)
###############################################################################
# DO NOT EDIT THIS FILE.
#
# Your changes to this file will be overwritten by ServerPilot.
#
# For information on how to customize nginx settings, see
# https://serverpilot.io/community/articles/customize-nginx-settings.html
###############################################################################
# Send all requests to apache.
location / {
proxy_pass http://localhost:4000;
Be sure to restart Nginx if you make changes to the .conf file (I forgot to do this) and with ServerPilot the restart command is a little different than I had seen elsewhere, this is what did it for me …
service nginx-sp restart
Then start bootstrapping your containers. (do this for each site your configured) Enter these commands in the terminal
./launcher bootstrap site1
(after that is done)
./launcher start site1
You should now be able to load the URL you have for the forum and see your Discourse forum.
I ended up with one of the sites not recognizing the Admin account when I registered with the developer email, and I found I had a stray character at the end of the URL that caused the email to be different. I then went into the /var/discourse/shared/ directory and deleted the folder matching that site. Then I used ./launcher destroy site2 command followed by ./launcher bootstrap site2 and then ./launcher start site2 I’m not sure a rebuild would work since you want the database to be recreated.
I know I probably over-simplified this is some areas, but from what I have seen in other topics/threads, some people need instructions that are overly simplified
Please let me know if I left any holes, or there is any need for clarification as long as you understand I can only speak for what worked for me since I barely understand this myself HA!!!
One more thing … does any one see any issue with duplicating the app.yml file to be used in this way? It seems this would work perfectly for updating as well.
Best regards … Pops