Advertisement
Guest User

Installing Flarum for dummies (for Apache)

a guest
Dec 15th, 2016
537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. Flarum is still in beta so it can be quite tricky to install.
  2. After doing this a few times and finally mastering it, I have assembled a guide for new users to install Flarum.
  3. There are multiple other ways to set up the forum software, but this is the one that worked for me and other users.
  4.  
  5. Any of the text shown in the code blocks are commands. You should paste them into your session and enter
  6. them unless told to do something else.
  7.  
  8. This guide isn't for professionals, it's for people not experienced at setting up things like this (like me).
  9. I didn't make most of this guide, credit to @ron_jeremy (from the Flarum forum) to most of it.
  10. I only switched a few things around and added some stuff to make it easier for you.
  11.  
  12. We will be using a DigitalOcean droplet.
  13. Here are the settings you will need for your droplet:
  14.  
  15. Under 'one-click apps', choose the 'LAMP on 14.04' option. This will create a Ubuntu LAMP droplet.
  16. I chose the $10.00/mo option. With a GitHub Student Pack, you can freely use this droplet for five months.
  17. Any geographical location will be suitable, choose the one closest to you.
  18. Under the additional options, you need to select two checkboxes (one optional):
  19. - Private networking
  20. - IPv6
  21. - Backup (optional)
  22. Selecting the backup option will add an extra 20% to your cost.
  23. Name your droplet a hostname you will remember and then click 'create'.
  24. You will then receive an e-mail containing your droplet's IP, root username, and password.
  25.  
  26. Next, we will make a SSH connection to the droplet. This guide is for Windows, so download and install PuTTY
  27. if you don't have it already. Enter the settings accordingly and start a session.
  28.  
  29. You will be asked to change your password. Make it something secure and memorable.
  30.  
  31. Now that you're connected, you will want to take note of your MySQL root password. This is important, you
  32. will need it for later to set up Flarum.
  33. cat /root/.digitalocean_password
  34. This will give you the root password. Copy it and save it somewhere.
  35.  
  36. Next, we will need to install curl. This can easily be done by entering this command.
  37. sudo apt-get install php5-curl
  38.  
  39. After curl is installed, we will make a new user for your droplet. Name it 'flarum'.
  40. adduser flarum
  41. Entering this command will result in being prompted for a new UNIX password. Make it something secure and
  42. memorable. Press enter for all the questions asked after this (such as your room number, name, etc.) until
  43. you reach the confirmation message. This asks if your information is accurate. Press the Y key and then press
  44. enter.
  45.  
  46. Now we must give our new user sudo privileges.
  47. visudo
  48. Search for the following line:
  49. root ALL=(ALL:ALL) ALL
  50. Enter your new user's username below so it looks like this. I will do it for my 'flarum' user.
  51. flarum ALL=(ALL:ALL) ALL
  52. Type Ctrl+X to exit and then type Y. Then hit enter to exit the editor.
  53.  
  54. Now your user can execute commands with administrative privileges. Let's logout of the root account.
  55. logout
  56.  
  57. Now restart PuTTY, reconnect to your droplet, and login with the new user account. Mine is 'flarum'.
  58.  
  59. Our droplet does not come with a swapfile by default. Let's add one and make some adjustments.
  60.  
  61. Here we will create the file.
  62. sudo fallocate -l 2G /swapfile
  63.  
  64. Now we will enable the file.
  65. sudo chmod 600 /swapfile
  66. sudo mkswap /swapfile
  67. sudo swapon /swapfile
  68.  
  69. Now we will make the swapfile permanent.
  70. sudo nano /etc/fstab
  71.  
  72. At the bottom of the file, add the following line.
  73. /swapfile none swap sw 0 0
  74. Type Ctrl+X to exit and then type Y. Then hit enter to exit the editor.
  75.  
  76. Next, we will make a couple tweaks.
  77. sudo sysctl vm.swappiness=10
  78. sudo sysctl vm.vfs_cache_pressure=50
  79.  
  80. Now we will make the above tweaks permanent.
  81. sudo nano /etc/sysctl.conf
  82.  
  83. At the bottom of the file, add the following two lines.
  84. vm.swappiness=10
  85. vm.vfs_cach
  86. Type Ctrl+X to exit and then type Y. Then hit enter to exit the editor.
  87.  
  88. Next, we will enable mod_rewrite. This is required for Flarum.
  89. sudo a2enmod rewrite
  90.  
  91. Now we must restart Apache.
  92. sudo service apache2 restart
  93.  
  94. Now we will exit the default VirtualHost to use mod_rewrite.
  95. sudo nano /etc/apache2/sites-available/000-default.conf
  96.  
  97. Search for "DocumentRoot /var/www/html" and add the following lines directly below it.
  98. <Directory "/var/www/html">
  99. AllowOverride All
  100. </Directory>
  101. Type Ctrl+X to exit and then type Y. Then hit enter to exit the editor.
  102.  
  103. Now we will restart Apache again.
  104. sudo service apache2 restart
  105.  
  106. Next, we will install Composer. This is also required for Flarum to work.
  107. sudo curl -sS https://getcomposer.org/installer | php
  108. sudo mv composer.phar /usr/local/bin/composer
  109.  
  110. Phew, with all that done it is finally time to install Flarum.
  111. There are many ways to do this, but this method gets the job done.
  112.  
  113. First we will navigate to our web directory:
  114. cd /var/www/html
  115.  
  116. There are already two files in this folder.
  117. Flarum doesn't like being installed on a folder that isn't empty. Let's delete these files.
  118. sudo rm index.html
  119. sudo rm info.php
  120.  
  121. Now we will install Flarum.
  122. sudo composer create-project flarum/flarum . --stability=beta
  123. Composer may give you a warning that it doesn't like being ran with sudo (or as a superuser).
  124. Don't worry about this, it is fine.
  125.  
  126. At this point the Flarum installer may or may not pause. If it does, it is waiting for your token.
  127.  
  128. If the Flarum installer is waiting for your token: (skip this part if it isn't)
  129. There should be a web address at the bottom of your terminal window. Go to that address in your browser,
  130. but make sure you have a GitHub account. If not, create one. Do not change any settings, just click the
  131. 'generate token' button at the bottom of the screen. Then copy and paste it into the terminal and hit enter to
  132. finish with the Flarum installer. Everyone must do everything below, token or not.
  133.  
  134. Now we should double-check that Flarum installed correctly. Make sure it didn't output any errors.
  135. If it did, search the error on the Flarum support forum and get help from there.
  136. Now let's see if Flarum is working properly.
  137. Go visit the IP of your droplet on the Internet with your web browser.
  138. It should show the Flarum logo first, and then show an issue with the permissions.
  139. Do not panic, this is to be expected. Close your browser window and follow the rest of the instructions.
  140.  
  141. First, we need to enable headers with Apache.
  142. sudo a2enmod headers
  143.  
  144. Then we will restart Apache.
  145. sudo service apache2 restart
  146.  
  147. Now, we will give ownership of the following folders to Apache.
  148. sudo chgrp www-data /var/www/html
  149. sudo chgrp -R www-data /var/www/html/assets
  150. sudo chgrp -R www-data /var/www/html/storage
  151. sudo chmod 775 /var/www/html
  152. sudo chmod -R 775 /var/www/html/assets
  153. sudo chmod -R 775 /var/www/html/storage
  154.  
  155. That's it with Flarum. You can re-visit your droplet's IP with a web browser and it should show a form.
  156. Don't fill it out yet, close your web browser. We need to configure MySQL first.
  157.  
  158. First, let's secure MySQL.
  159. mysql_secure_installation
  160. Type your root password when prompted. Now you will see a message telling you that a root password
  161. is already set. Enter N and press enter. You can change the MySQL root password some other time.
  162.  
  163. Press Y and enter for the rest of the questions.
  164.  
  165. Now we should access the MySQL shell.
  166. mysql -u root -p
  167. You are asked for your MySQL root password. This is the password you noted down back at the very
  168. beginning, it's from the MOTD. Enter this password (or paste it in) and hit enter.
  169.  
  170. Now, let's see the databases already installed.
  171. SHOW DATABASES;
  172. There should be three default databases. Leave them alone.
  173.  
  174. Let's create our database, we should call it 'flarum'.
  175. CREATE DATABASE flarum;
  176.  
  177. If you list the databases again, you should see the new database.
  178. SHOW DATABASES;
  179.  
  180. Now, let's exit the MySQL shell. Press Ctrl+C.
  181.  
  182. Now go back to your web browser and visit your droplet. Let's fill out that form.
  183.  
  184. Forum Title: Enter the name of your new forum.
  185.  
  186. MySQL Host: Leave this as 'localhost'.
  187.  
  188. MySQL Database: Enter your database name. We named it 'flarum', so enter that.
  189.  
  190. MySQL Username: 'root'
  191.  
  192. MySQL Password: Enter your MySQL root password, the one you noted down from the MOTD.
  193.  
  194. Table Prefix: 'myforum01_'
  195.  
  196. Admin Username: Whatever you want to name your admin account.
  197.  
  198. Admin Email: The e-mail for your admin account.
  199.  
  200. Admin Password: The password you want to use for your admin account.
  201.  
  202. Now press the button under the form.
  203. This may take a few seconds.
  204. Now it should redirect to the homepage of your new Flarum forum.
  205. You have now installed Flarum. Hooray!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement