Skip to content

Instantly share code, notes, and snippets.

@zgulde
Last active June 29, 2016 19:46
Show Gist options
  • Save zgulde/d3bd3757f2b18418746147e6f83b764e to your computer and use it in GitHub Desktop.
Save zgulde/d3bd3757f2b18418746147e6f83b764e to your computer and use it in GitHub Desktop.

Deploy your adlister as a subdomain of your site

Overview

  1. configure a CNAME record for the subdomain through digital ocean
  2. create the site through warpspeed
  3. push your code up
  4. log into your server and create a database, env file and do any steps neccessary to initialize your site

Steps

  1. Make sure you are configured with your domain registrar to use digital ocean's nameservers for the domain name you purchased

  2. create cname record in digital ocean

    1. Go here and select view (the magnifying glass) for your site
    2. under select record type choose 'CNAME'
    3. for the 'Enter Name' input enter the subdomain name you would like
      • for example adlister
    4. for the 'Enter Hostname' input enter the name of your site with a '.' at the end.
      • E.g. zgulde.com.
      • Note the dot at the end, you will get an error if you don't include it.
  3. in warpspeed.io create a new site

    1. from warpspeed.io click on my servers
    2. click on the name of your server
    3. add a new site that is named in accordance with the CNAME record you just configured with digital ocean
      • here do not include the '.' at the end
      • e.g. adlister.zgulde.com
      • DO NOT check the box for 'Allow wildcard subdomains'
      • the site type will be 'PHP', unless you got crazy and rewrote your adlister in ruby or python
  4. activate push deploy

    1. Click on the big green button that says 'Activate Push Deploy'
  5. add warpspeed remote to your adlister repo

    1. After activating push deploy copy the line that starts with git remote add warpspeed

    2. go to your adlister repo and run the command

      cd ~/vagrant-lamp/sites/adlister.dev
      git remote add warpspeed ...
  6. push your code to warpspeed

    # from adlister.dev
    git push warpspeed master
  7. ssh into your server and create a database for your adlister

    ssh warpspeed@YOUR_SERVER_IP_ADDRESS
    • all commands from this point forward will be run from your warpspeed server

    • make sure you choose names for the database and user that match up with your .env.php, but choose a strong password here

    warpspeed mysql:db adlister_db adlister_user superstrongpw

    warpspeed will ask you for your database password, this was in the email warpspeed sent you when your server was provisioned

  8. cd into your adlister site

    cd ~/sites/adlister.zgulde.com
  9. create your .env.php file

    1. open your .env.php in sublime and change the database password (DB_PASS) to match up with the one you created for the database in the last step

    2. Now would be a good time to change the user password to something more secure if it is not already

    3. copy the entire contents of the file

    4. on your server in the adlister site directory (eg ~/sites/adlister.zgulde.com) create the file with nano

      nano .env.php
    5. paste the file

    6. exit from nano (ctrl + x)

    7. nano will ask you if you want to save, say yes and hit enter when prompted for the filename (it should be prefilled in as .env.php)

  10. run the seeders migrations and seeders

    cd database/migrations
    php ...
    cd ../seeds
    php ...
  11. go to your site and rejoice!

Notes

  • it is very important to change the DB_PASS and USER_PASS in your .env.php file before copying it to production.
  • DB_PASS is what is used to log into the mysql database on your server and is the value you give warpspeed when creating the database with warpspeed mysql:db
  • USER_PASS is what you will use to actually log in to your adlister site

Troubleshooting

If you can't access your site in chrome take note of the error message

if it says 'received an empty response from the server' (or something to that effect) than something is either not configured correctly with you digital ocean dns settings or the site was not properly created with warpspeed

if it says 500: internal server error (or something to that effect) than the problem has something to do with your site

  • did you create an .env.php?
  • are your sure the values in your .env.php are configured correctly?
  • did you run the migrations and seeders successfuly?

to see more detail of what caused the error you can look in the php log file for that site on your server

Accessing the PHP error log file on your server

Because your warpspeed server is in a production environment it is configured not to show any errors (as it should be). If something goes wrong, we'll have to check out the log files to see what's up.

  1. to access the log file you will need to open up a root shell

    sudo -s
  2. the file will be /var/log/php/yoursite.com-error.log

  3. look at the contents of this file to see what went wrong

  4. note this file could potentially be very large, so it is generally usefull to look at the end of it, check out the tail command

@rrapstine
Copy link

Awesome guide! Worked perfectly for me. If I may though, you may wish to add something before the migrations to composer install. I encountered an error when I tried to install composer with Laravel 5.2 as the default _.gitignore_ file ignores the _bootstrap/cache_ folder. This folder needs to exist for php artisan optimize to run correctly, so performing a mkdir bootstrap/cache might be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment