Laravel site update

I needed to deploy the updates to the live site.

Edited (12/4/2019)
This has been the third time to update the site. I found the better and faster way to update.

Step 1: Create a database

Export database from the current database. Create a new empty database. Import the database you just exported.

Step 2: Create a zip file on the local computer

Create a copy of the project, change the name of the folder, and then edit code: database info, “/font” -> “../font” in css files. I deleted the .git file and old migration files (because I will use the new database I have just created). Create a zip file.

Step 3: Upload the zip file through ssh and unzip

Open terminal. Upload the zip file and unzip.

Step 4: Run migration

Go to the project directory and run “php artisan migrate” to update any changes in the database. (make sure to delete old migration files that the current database has created from)

Step 5: Create a symlink

This post is my personal study notes. Not intending to share with other people, so that people can solve their coding problems by reading this.

Lessons learned: Shared hosting (I use Dreamhost) doesn’t allow you to download composer, so to deploy a laravel project, you’d have to upload EVERYTHING to the server.

To do that, there are mainly two ways: 1. Source control (use GitHub); 2. No Source control (upload zip file).

After struggling and failing to do method 1 (using GitHub), I ended up uploading a zip file and it worked well (after encountering a couple of more problems..)

Lessons learned: the name of the unzipped zip file won’t be changed if you rename the zip file. You have to duplicate the original file first, rename it, and create a zip file off of it.

What happened to me was that when I unzipped the uploaded zip file on the server, it started overwriting the existing files of the live site that were essentially under the folder that’s the same name as the one I was unzipping (even though I renamed the zip file). This, later on, broke the live site.

Lessons learned: Use ssh to deal with large files (uploading, unzipping etc.) Don’t count on FTP to do this.

This is well-known. But really, Yes.

Database. I created a new database for a test site so that any changes will not affect the live site. To create, I used a sql file exported from the live site. Also, one thing I wanted to be careful is that update for this time involves migration files, so I wanted to make sure these changes won’t affect the existing database negatively.

Ok, so the database is ready. I hit php artisan migrate. I got the error message “..table already exists”. Hmm.. I don’t want to change migration files at this point. I dropped all the tables, then migrated tables again. Worked this time. To insert data, I manually edited the sql file (I know I’m not supposed to. But figured it’s ok. It’s only one column). Imported the file, and then I got “foreign key constraint”

Lessons learned: to temporarily disable a foreign key constraint, run:


Make sure to set it back to 1 after importing the data.

Symbolic link. What is it? It is also called soft link (Refer to a symbolic path indicating the abstract location of another file) as opposed to hard link (Refer to the specific location of physical data.)

Lessons learned: type the following command in ssh will create a symbolic link:

$ ln -s file1 link1

To verify a new soft link, run:

$ln -l file1 link1

For me, to make this work, I went to the home directory of link1 and ran the command. link1 would be the URL that appears in the address bar and file1 is where all the laravel files are.

Edited (9/18/2019)

file 1 would be home/username/project/public and link 1 would be home/username/public_html(domaine name for dreamhost)/subfolder

It works, but then it adds ‘public‘ after subfolder in url. Tried home/username/project/public/index.php it kinda worked except it was missing css file and all the images. I wonder how I can get rid of ‘public‘ in url..

Reference: How to Deploy Laravel Projects to Live Server: The Ultimate Guide (last updated Oct 2, 2018) – very detailed. Not everything was applicable to my case because this is specifically for VPS hosting.

Reference: Deploying Laravel on DreamHost (last updated Apr 10, 2019)

Leave a Reply

Your email address will not be published. Required fields are marked *