Tutorial: Setting Up DigitalOcean

From Lorekeeper Wiki
Revision as of 14:09, 24 July 2021 by Wych(Witch) (talk | contribs) (→‎Digitalocean Setup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Hello! This is wych(witch)’s tutorial on how to get lorekeeper running on your digitalocean droplet!

Please do not follow this guide yet. It is in the process of being rewritten!

<img src="https://i.imgur.com/P2ka9Cz.jpg">

First, special thanks to Cy for creating lorekeeper in the first place, and special thanks to Juni for writing their own visual guide for dreamhost here.

Warning: This is just how I personally set up lorekeeper, and as such, I decided to forgo local-side testing. If you want to do this yourself, follow the instructions on the wiki! They’ll work regardless of your server’s config.

Also, to make this guide easier to read, go to View -> Print Layout and uncheck it!

Please check the changelog to see the last time this guide was updated! If you’re reading this significantly after this date and run into problems, there’s a good chance it is out of date! Please go to the lorekeeper wiki here for more up-to-date information.

Also, once you’re done reading through this guide I Highly recommend you look at the troubleshooting section! It will help prepare you for any errors you might encounter during or even post-installation.

Programs you need to have installed on your local (windows) computer:

   Putty

   FileZilla

   Sourcetree

Visual Studio Code (or really, any text-editor better than default notepad)

If you are uncomfortable with setting up git, hold off on installing sourcetree until the section on it farther down.

Text in a dark blue background like the following

$ List

$ Of

$ Commands

Are commands you need to run one at a time, hitting enter each time. However Do not type the $ symbol, that’s just there to show you the beginning of the command when there are several in one block! Everything after the $ must be entered as one long string

Meanwhile text like this:

Output text that is

Very

Very

helpful

Is command-line output provided as an example.

Finally text like this:

This is a

File you need to

Copy and paste

Is a file you’ll need to copy and paste as specified!

Also, whenever I type something in green like this it is recommended to save the info I’m referring somewhere like in a .txt file that you can easily access!

Also, one last word of warning, once you’re done with this guide Do Not edit or upload files directly on the server through filezilla, it will get your git repository out of wack and you won’t be able to push updates or install extensions to it. If you want to make changes, please make them locally and push through git!

If you don’t understand what that means just yet, don’t worry! Once you’re done with this tutorial you’ll get it!

With the basics all out of the way, let’s begin!

Change-log:

   May 11 2020 - First written!

   May 12 2020 - minor typos corrected

   May 13 2020 - Provided section on how to fix a phpmyadmin bug!

   May 29th 2020 - Fixed git stash error, and added some resources to learn git!

   July 25th 2020 - added section on how to install extensions, including how to backup your database just to be safe!

   August 14th 2020 - further clarified which programs need to be installed where

   August 21st 2020 - added warning about editing files through filezilla

   September 1st 2020 - Added section on cronjobs

   November 30th 2020 - added note about sourcetree error  

Digitalocean Setup

Select debian 9, and make sure to choose standard and the 5 dollar a month plan!

Select the one-time password option (even if it says its less secure)

Choose a name! Preferably your site’s name, but it doesn’t have to be!

I also recommend enabling backups, just in case anything goes wrong!

Wait for the site to get the droplet up and running! It will take under a minute

Now, go to email and get the root password that was emailed to you.

Return to digital ocean, click on your droplet, and hit console


(Ignore the text after login: ) type root and Copy and paste (with ctrl-V) your password!

When it says Changing Password for root you need to paste it one more time, then input your NEW password! Please save this somewhere safe, like on a text file on your computer.

After you’re signed into root, you need to now make a new normal user! Enter the following commands,  but change <username> to an actual username

$ adduser <username>

$ usermod -aG sudo <username>

Be sure to save this password too!

Once this is done, you need to update your server so you can install new software! Run the following command:

$ apt-get update

Then run the following to install a program called ssh, so we can use a much better program to control your server with.

$ apt-get install ssh


You might need to edit this file to allow ssh connections:

  • sudo nano /etc/ssh/sshd_config
  • then change PasswordAuthentication no to PasswordAuthentication yes at the very bottom of the file

sudo systemctl restart ssh

also run chmod o+r /etc/resolv.conf

Note to self wych: edit this and make sure its needed (PasswordAuthentication to yes, and uncomment the passwordkey thing)

chmod 644 /etc/resolv.conf


With this, close out the console window! Now you need to install a new program called putty if you haven’t already on your local computer.

SSH, Putty, and keys

Download it, install it, and once you launch it you should see something like this.

Go back to digitalocean and find your ip either here:

Or here:

And save it! You’ll be using it a lot, so keep it somewhere safe.

Copy that ip into the hostname box (1), name your settings (2) and hit save (3)! After that, hit open (4)!

Remember, the username is CASE SENSITIVE mine here is incorrect (i had to fix it later)

You will get this alert, this is totally fine. Hit Yes.

Now type in your password!

Now you are logged in! Now that we have verified that SSH is working, we now need to setup some ssh keys for use with git and putty! An ssh key is a file that allows you to connect to your server without having to type in your password every time.

Go to the folder where you installed putty, or search “puttygen” in your windows search bar and open the program.

Hit generate, and move your mouse around in the indicated area as instructed!

You’ll now get something like this:

Save both the public key(1) and the private key(2) somewhere safe and easily locatable! Be sure to make it clear in the file names which is public and which is private (we will be using them both!)

You’ll get a message like this, hit yes!

Once you’ve saved them both, close out puttygen

Now it's time to use FileZilla! Install it if you haven’t already onto your local computer, and open it up.


Fill out your ip address, username, and password! Also make sure you type 22 in the port box!

Also, make sure that you navigate to the folder with your ssh keys! On the left-side!

Once you’ve done these both, hit quickconnect!

Drag and drop the public key into the server!

After it is transferred, go back to your putty window and run the following commands. Remember to replace sitepublickey with what you named your public key!!

Important note: When you want to paste something in putty, you just need to right click the window. I know it's weird, but bear with it! (btw, copying something from putty is automatically done when you select text too! It’s weird but you’ll get used to it)

$ cd ~

$ mkdir .ssh

$ chmod 700 .ssh

$ ssh-keygen -i -f sitepublickey>> ~/.ssh/authorized_keys

$ chmod 600 ~/.ssh/authorized_keys

$ rm sitepublickey

Close out your putty window and open putty again

Select the profile you saved before (1) and hit load (2)

On the lefthand side, select the ssh button (1), then Auth(2), and browse to select your private sshkey! (3)

Select session (1), hit save to save (2) your private key settings! Then hit open! (3)

It should sign you in without using your password! Next we need to setup git!

Git Setup

First install sourcetree if you haven’t already

Keep these default settings! You’ll have to make a bitbucket account but dont worry, it’s free!

Now once you got it installed, hit clone.

In the source path / url box, put in the lorekeeper’s github url [https://github.com/corowne/lorekeeper] and select an empty directory to host it in! I recommend you name it the your site’s name

Once you’re done, hit clone!

Next you should see something like this

If so, next you need to hit pull and pull Release 2.0.0 branch into your local master!

Once that's finished, you’re done with sourcetree for the moment! Now switch back to putty and input the following commands

First we need to install git

$ sudo apt-get install git

If this is your first time running sudo you’ll get a message like this. This is totally normal! Just type in your password at the prompt:

We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

   #1) Respect the privacy of others.

   #2) Think before you type.

   #3) With great power comes great responsibility.

[sudo] password for wych:

When it asks you Do you want to continue? [Y/n] type y and hit enter

Now its time to create your site’s directory and get it set up for git! Remember to change site-name to your actual site’s name.

$ cd ~

$ mkdir site-name.com

$ cd site-name.com

$ mkdir www

$ cd www

$ git init

$ cd ..

$ mkdir site_hub.git

$ cd site_hub.git

$ git --bare init

Now back in source tree, we need to add your private sshkey

Select this option!

Fill out your name (it doesn't need to be your real one) and your email address (1). Then browse to your private ssh key! (2) after that, hit ok!

Next, close soucetree and open it again (I know, sounds useless but its to apply the settings!)

Next go to settings

Hit add!

Now you need to fill out the connect! Name your remote (1), then in the url / path (2), insert the following

ssh://username@<ip address>/~/site-name.com/site_hub.git

Replace username with the username you created, and your ip with your droplet’s ip, then hit ok!

Next, you need to edit the lorekeeper’s profile. Select it (1) and hit edit (2). If your sourcetree crashes when clicking edit, you must instead delete the origin remote and add it back again as a non-default remote. This is a bug that has not been fixed as of writing.

Now uncheck default remote (1)  rename the origin hose to Lorekeeper (2)! This is so you don't accidentally attempt to push changes to the lorekeeper github.

On the left side you should see this

If you do, you configured it correctly!

If

Next hit push, select your server, (1)(2), check (3), and hit push! (4)

You might get a message like this

It's okay! Hit yes

If it ran successfully, now it’s time to return to putty and run the following commands

$ cd ../www

$ git remote add hub ../site_hub.git

Check to make sure it's working by typing git remote show hub and seeing if it matches the following output

$ git remote show hub

* remote hub

  Fetch URL: ../site_hub.git

  Push  URL: ../site_hub.git

  HEAD branch: master

  Remote branch:

   master new (next fetch will store in remotes/hub)

Next, you need to run git pull hub master to update the site!

remote: Counting objects: 3223, done.

remote: Compressing objects: 100% (956/956), done.

remote: Total 3223 (delta 2168), reused 3223 (delta 2168)

Receiving objects: 100% (3223/3223), 3.31 MiB | 0 bytes/s, done.

Resolving deltas: 100% (2168/2168), done.

From ../site_hub

* branch            master     -> FETCH_HEAD

* [new branch]      master     -> hub/master

Once that’s done, type the command ls and see if there are files in the folder. If so, you did it correctly!

Now we need to set up some files to run git pull hub master automatically for us!

$ cd .git/hooks

$ nano post-commit

You should now see the putty window change and look like this

Paste the following text into it (remember, use right click!)

#!/bin/sh

echo

echo "**** Pushing changes to Hub [Prime's post-commit hook]"

echo

git push hub

Hit ctrl+X, hit y, then enter

Now type chmod +x post-commit to allow the system to run that file!

Now we need to make one more

Now run these commands!

$ cd ../../../site_hub.git/hooks

$ nano post-update

Now you need to copy and paste the following into it. Remember to change site-name to your actual site’s name

#!/bin/sh

echo

echo "**** Pulling changes into Prime [Hub's post-update hook]"

echo

cd $HOME/site-name.com/www||exit

unset GIT_DIR

git pull hub master

exec git-update-server-info

Hit Ctrl + X, y, enter just like before and type chmod +x post-update again just like before!

Now we need to make sure the git is configured correctly!

First, navigate to your local git’s folder, or hit this button in sourcetree to open it for you!

Create a new txt file and name it something you’ll recognize, like GitTest.txt

Go back to sourcetree, and you should see that it’s slightly changed.

Now, select file status (1) and iIn unstaged files should be the file you just created!  Hit Stage All (2), then type in a commit message (3). You can type anything you want here!

After that, hit commit in the bottom right corner

Now go back to history (1) and you should see the new change! Now hit the push button (2)

Again, make sure you’re posting to your site and not the github! (1) and push! (2)

Once you’re done, type the following commands on the server:

$ cd ../../www

$ ls

If you see the .txt file in the list of files, it worked!

Installing LAMP, and configuring the database

Next we need to install a few programs onto the server and configure the database!

$ sudo apt install apache2 apache2-utils

$ sudo apt install curl

$ sudo apt install mariadb-server mariadb-client

$ sudo apt-get install wget

Database configuration

Next,  you need to configure your database! Run this command.

$ sudo mysql_secure_installation

You’ll get the following message

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):

Hit enter (since this is your first time using  this)

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n]

Set your root password here! Again, save this root password in your notepad!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n]

Hit y here!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]

Hit Y here too! Despite what it sounds like, you can still log into your database thru ssh (and later phpmyadmin)

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n]

Y on  this as well!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n]

Hit Y here as well!

PHP7.2 installation

Next we need to install php7.2 Run these commands

$ sudo apt-get install ca-certificates apt-transport-https

$ wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

$ sudo apt-get update

Now paste this long command!

$ sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-curl php7.4-mbstring php7.4-mysql php7.4-zip php7.4-xml php7.4-gd php-gettext

Now that php is installed, you need to enable it! Type these commands:

$ sudo a2enmod php7.4

$ sudo a2enmod rewrite

Apache Configuration

Next, open up your apache2’s settings

$ sudo nano /etc/apache2/sites-available/000-default.conf

Change

DocumentRoot /var/www/html

to

DocumentRoot /home/username/site-name.com/www/public

Now, run this command to edit another apache2 config!

$ sudo nano /etc/apache2/apache2.conf

Use ^W to search for the section you need to replace in nano (type it out, don't paste), which is a text editor within the command-line. The caret symbol (^) represents the CTRL key on your keyboard.

Replace this:

<Directory />

        Options FollowSymLinks

        AllowOverride None

        Require all denied

</Directory>

With this:

<Directory />

      Options Indexes FollowSymLinks Includes ExecCGI

        AllowOverride All

        Require all granted

</Directory>

Finally, reload apache2  with this command!

sudo systemctl restart apache2

Next we need to install a program called phpmyadmin

sudo apt install phpmyadmin

When it runs you'll get a screen like this

Hit space, then enter

You'll get this screen next

Hit enter!!

Then you'll be prompted to choose a password. Type one out and hit enter! (remember to save it!)

Now, see if your phpmyadmin is installed correctly by going to <ip address>/phpmyadmin

You should see this:

Next we need to create a user specifically for PHPmyadmin! Type the following command:

sudo mysql -p -u root

You’ll get a new prompt onscreen, now you need to type the following, but remember to replace pmuser and passward_here with a new username and password! Also Save both of them!

CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'password_here';

Now paste this in there too. Remember, replace pmuser with the same one you just created!

GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost' WITH GRANT OPTION;

Now type quit; to quit the prompt! Now return to the site and type the username you just created for the username, then the password you picked for the password! If you are having problems signing in, go down to troubleshooting for a way to reset your  password.

Once you sign in, click on the Databases link at the top and you should see a page like this:

Pick a name for the database(1) and hit create!(2)

Now, remember to write down the name of your database somewhere AND the port highlighted here, then switch back to putty

Next we should further secure our phpmyadmin page with an additional password! There’s actually a fantastic tutorial on how to do it here: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04#step-3-%E2%80%94-securing-your-phpmyadmin-instance

If you choose not to it should still be fine, it’s just something you should keep in mind for security reasons!

One thing I should mention is imo you should choose a different name than the “phusar” you chose before!! The password can be the same though, just Make sure to Save This As Well!!

Now, restart the apache with this command:

sudo service apache2 restart

Now we gotta install a program called composer!  Installing this is a little different than before, but bear with me!

Navigate to your www/ folder

cd ~/sitename.com/www

Run the following command under Command-line Installation section of this page:

https://getcomposer.org/download/

Now run these commands to make sure you have enough memory to run it

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024

$ sudo /sbin/mkswap /var/swap.1

$ sudo /sbin/swapon /var/swap.1

Next, run this command!

php composer.phar install

This will take a while! While it installs we can set up some api keys!

API keys

There are other authentication methods besides DA! You can find them and how to set them up here.


Below is the DA specific set up.

Deviant Art Setup

First, go to deviantart’s developer portal

Hit register application

Copy this into notepad or another text editor, make sure there are no line-breaks (they have to be one long line separated only by spaces!) and replace the site-name with your actual site names!

https://site-name/ http://site-name/ https://www.site-name/ http://www.site-name/ https://site-name http://site-name https://www.site-name http://www.site-name

You’ll get this message, but that’s totally okay!

It will look like this!

Scroll down and select the options like so, and hit save!

You'll now see a page like this

Save the secret and id somewhere safe!

Cloudflare Setup

Next we need to get our nameservers on cloudflare! Go there, and create a new account!

After you create your account, you need to transfer your nameservers to cloudflare from your domain registrar. Since every domain registrar has different ways of doing this, I can't cover them all here. Instead, after you make your account if you’re having problems following their automated instructions (they should be pretty clear once you enter your domain name!) go here and follow the instructions for your domain registrar if it's listed.

https://support.cloudflare.com/hc/en-us/articles/205195708-Changing-your-domain-nameservers-to-Cloudflare

Once you’re done and your site’s nameservers have been successfully ported over, you’ll see a screen like this:

First turn on development mode(1) while you’re setting up the site, then hit dns! (2)

If this pops up, its okay! Just hit confirm!

You will see something similar to this (I have already filled out some of this for my own projects, don't mind me) On your end, if you aren’t using your registrar's email options or anything, feel free to delete all of these records (except the www CNAME, if it exists)

Fill out the information as follows, and hit save!

Now, let’s go to sendgrid and get the email set up! Don’t close out your cloudflare tab yet though, we’ll be returning here momentarily to add some more domain records

Make a new account, but be sure to select the free option. This should be good enough for smaller sites!

Once you’re done you should get to this page!

On the left, hit settings(1), and hit Sender Authentication(2)

Select Domain authentication!

Next, select your dns host (that would be cloudflare)

Then be sure to hit Yes on this, that way the emails will correctly say they’re from your site!

Fill out your domain name here and hit Next

You will now see these domain-names that you need to install into cloudflare! I recommend having both sites open in two windows side-by-side so you can easily copy-paste between them.

First, hit copy on the one in the host column.

Then, change type from A to CNAME

Paste what you just copied into the Name box

Now copy the the address in the value column here

Paste the value to the target box, then hit save!

Now you have it added! Now you need to dp the same for every other item in the hosts and value columns!

Once they’re all added, make sure to click on the Proxied orange clouds, and make them gray and say DNS only!

Now that that’s done, scroll down and hit verify! This may take a few minutes to work, so even if it says an error try again in a few minutes!

Next, hit API keys under settings and hit create new

Hit create and view!

Once your api key is created, be sure to save it!! It will never be shown to you again. If you lose it somehow, you’ll just have to generate a new apikey!

Once you’re ready, hit done and now we’re ready to return to putty!

Installing the site

Next, we need to add a file to the www folder

Let's return to your site’s folder!

cd ~/site-name/www  

Create a file called .env

nano .env

Copy and paste this into the .env file, but be sure to only edit the lines indicated!

APP_NAME=site_name_with_no_spaces

APP_ENV=

APP_KEY=

APP_DEBUG=

APP_URL=

CONTACT_ADDRESS=your_contact_address@site-name.com <Replace with your email>

DEVIANTART_ACCOUNT=your-dA-group-account-username <replace with your da group username if you use it>

LOG_CHANNEL=stack

DB_CONNECTION=mysql

DB_HOST= localhost

DB_PORT= < Put the database port you saved earlier>

DB_DATABASE= <Put your database name!>

DB_USERNAME= <Put the database user you created earlier>

DB_PASSWORD= < Put your database user’s password!>

BROADCAST_DRIVER=log

CACHE_DRIVER=file

QUEUE_CONNECTION=sync

SESSION_DRIVER=file

SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1

REDIS_PASSWORD=null

REDIS_PORT=6379

MAIL_DRIVER=smtp

MAIL_HOST=smtp.sendgrid.net

MAIL_PORT=587

MAIL_USERNAME=apikey

MAIL_PASSWORD=your_sendgrid_api_key

MAIL_FROM_ADDRESS=noreply@site-name.com < replace with noreply@<yoursiteurl> >

MAIL_FROM_NAME=mail_sender_name < replace with whatever you want! They’ll be the one who sent the one who “sent” the email, so if you have a main OC you can put their name here! >

AWS_ACCESS_KEY_ID=

AWS_SECRET_ACCESS_KEY=

AWS_DEFAULT_REGION=us-east-1

AWS_BUCKET=

PUSHER_APP_ID=

PUSHER_APP_KEY=

PUSHER_APP_SECRET=

PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"

MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

DEVIANTART_CLIENT_ID= < replace with your DA client ID>

DEVIANTART_CLIENT_SECRET= < Replace with your DA Secret! >

DEVIANTART_CALLBACK_URL=/

Hit ctrl+X, y and Enter to save!

Now run the following commands:

$ php artisan key:generate

$ php artisan migrate

$ php artisan add-site-settings

$ php artisan add-text-pages

$ php artisan copy-default-images

Now we need to create our admin user with this command!

php artisan setup-admin-user

Now you need to change some permissions!

$ sudo chmod 777 -R /home/username/site-name.com/www/

$ sudo chown www-data:www-data /home/username/site-name.com/www/public -R

The 777 permissions are actually a bit too lenient, so we’re using it to test first!

Now, the moment we’ve been waiting for, go to your site’s url and see if it works! If it does, great! You’re almost done!!!!

Now we need to correct the bad permissions by running this script created by Paws

It needs to be run in the site-name.com folder, so lets cd there (replacing site-name.com with your actual folder’s name)

cd ~/site-name.com

Then run the script, and one more command

$  wget https://wychwitch.neocities.org/scripts/fixfolderperms.sh && sudo chmod +x fixfolderperms.sh && sudo sh fixfolderperms.sh

Doublecheck the site to make sure it works with the new permissions!

Next we need to test a few things

Log in with your admin account and password, then click on the little crown by your name

Click on request another email

Now make sure to check your spam folder!! with the two sites I've set up thru this, I have always had the initial email get stuck in spam.

Verify, then log out!

Next you need to create a new user. This can be your main, non-admin account, or it can just be a test account! Either way, sign up as a new user and verify if everything is working correctly on that end.

If that works, then you’re almost done! Now we need to install https!!

Go back to putty (i promise this will be the last time)

Run these commands

$ sudo apt-get install certbot python-certbot-apache

$ sudo certbot --apache

Enter your email address, type A to agree, select yes or no to the next prompt (it doesn’t matter what you choose), then finally enter your site name (no www!)

Enter email address (used for urgent renewal and security notices) (Enter 'c' to

cancel): wychwitchcraft@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Please read the Terms of Service at

https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must

agree in order to register with the ACME server at

https://acme-v02.api.letsencrypt.org/directory

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(A)gree/(C)ancel: a

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Would you be willing to share your email address with the Electronic Frontier

Foundation, a founding partner of the Let's Encrypt project and the non-profit

organization that develops Certbot? We'd like to send you email about our work

encrypting the web, EFF news, campaigns, and ways to support digital freedom.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

(Y)es/(N)o: n

No names were found in your configuration files. Please enter in your domain

name(s) (comma and/or space separated)  (Enter 'c' to cancel): wychwitch.monster

After it completes the challenges, type 2

Next go to cloudflare and change the ssl to Full

Return to your site and make sure it still connects like before.

If it does, great! Now we need to enable automatic renewal with the following command:

sudo certbot renew --dry-run

Next, we need to install the auto-scheduler so it will run laravel-related tasks.

Run this command:

crontab -e

Then copy and paste this in, changing site-name.com to your domain-name

* * * * * cd ~/site-name.com/www && php artisan schedule:run >> /dev/null 2>&1

Save it once you’re done!

If so, you’re finally done!!

But Please continue reading this tutorial for some important tips!

How to use Git

If this is your first time using git, it’s important to understand how it works. Here are some great resources

Here’s a pretty easy to understand writeup on how git works! If you’re more of a visual/audio learner, here's a good video too.

This is a great interactive git tutorial. While it focuses on the command line, it’s actually how sourcetree works in the background!! This is the one I recommend for complete beginners since it has a easy to understand example of git branches.

Another interactive tutorial, only this one lets you actually use it with github! I suggest this after you do the above one.

Now that you understand how git generally works, here are a few more examples!

This will be a short example of how to use git to customize your site!!

For some things, making a .css file and uploading through your https://site-name.com/admin/images page is perfectly fine and preferred, but for things that it can't change you’ll have to go into your git files and edit directly! Here’s one example

Open your git directory on your local computer, and go to public\css and open lorekeeper.css in notepad++ and scroll down to line 138

.sidebar .sidebar-header {

   background-color: #343a40;

}

Change background color to any color you want! Just make sure it’s a hexcode (im picking #9500ff, obviously)

Save the file and open sourcetree up!

You’ll see uncommitted changes be there yet again, and that’s normal! Hit the commit button in the top left

Just like before, stage the files (1), make a comment(2) and hit commit(3)! Click on history and push the changes to your site’s server!

Installing Extensions

If you want to install an extension view this page here!

Troubleshooting

First, here are the locations of error logs that will eventually become useful to know! If you run into an error, especially laravel errors, an important part of troubleshooting (or even getting help) is looking at the error logs! Here are two of the most often access error log directories:

Laravel error logs - www/storage/logs

Apache error logs - /var/log/apache2/

Note you might need to use sudo when opening some of these in nano! Or log into ftp as root if you wanna download and read them in a more comfortable text editor (highly recommended!)

404  Forbidden Error when visiting the site

First, make sure you’ve correctly followed the configuration specified here! Remember that the directory needs to be to the correct location in order to work.

If it still doesn’t seem to work, go to your www/public folder and create this file for testing

nano phpinfo.php

Then paste this in there.

<?php

phpinfo();

Save it, and go to <url>/phpinfo.php

If you see something like this

Then the problem is probably in your /etc/apache2/apache2.conf ! If you don’t get this page, the problem is probably with your document root in the /etc/apache2/sites-available/000-default.conf file!

Forgot the Your Database Password

If you forget your database’s password, here are the steps I used to reset it.

First, run the following commands.

killall -9 mysqld mysqld_safe

sudo mysqld_safe --skip-grant-tables --skip-networking &

mysql -u root

Then,  run the following, replacing the PASSWORD with an actual password and USERNAME with the username (you can even type root if you forgot the root password!)

flush privileges;

update mysql.user set password=password('PASSWORD') where user='USERNAME';

flush privileges;

update mysql.user set plugin='mysql_native_password' where user='USERNAME';

flush privileges;

Then shut down the safe-database and launch it again!

killall -9 mysqld mysqld_safe

mysql

Problems Pushing changes to the server

If you try to push something, and it doesn’t change on the site, there are several things that could be wrong. But first, it’s good to make sure that development mode is turned on in cloudflare! It makes sure that you always get the latest version of your site, but it turns itself off after only 3 hours. So make sure it’s still on!

If it is on and you’re still not seeing any changes,  the most common issue I’ve found is that you changed something on the site’s www folder directly that is then in conflict with something you’re trying to push! A way to test this is to type the following command in your www folder:

git pull hub master

If you get something like this

From ../site_hub

* branch            master     -> FETCH_HEAD

Updating e59ceaf..73c71db

error: Your local changes to the following files would be overwritten by merge:

        GitTest.txt

Please commit your changes or stash them before you merge.

Aborting

Then you have a file conflict! If you don’t care about the server-side settings, you have a couple options

1: You can stash the file so you could possibly bring them back (replacing the text that are written <like this>:

git stash save <conflicting file(s)>

Then run git pull hub master again and it should work!

2: If you made a mistake and really want to reset to your current computer’s git version, run this command. Warning, this WILL reset EVERYTHING to the current git status, which will delete stuff such as composer.phar, and any other files that haven’t been committed. If you want to see what would be deleted, run git status. This will show you all the modified or untracked that will be deleted.

If you’re sure about it, run the following command.

$ git fetch --all

$ git reset --hard hub/master

Your git should now automatically update as normal!