I first started using DreamHost shared hosting in college, as an affordable means of hosting web projects. It includes domain management, no hassel SSL certs, MySQL databases, and more. It’s a great solution for most PHP projects.
My largest frustration was being unable to host more interesting projects; due to the restrictive nature of shared hosting, I had no installation privileges on the server. Without these, running composer is next to impossible. I recently pieced together the process for getting Laravel on DreamHost, and I wanted to share my findings.
Note: I’m assuming that you, the reader, have experience with DreamHost and Laravel, and I won’t bog down this walkthrough with every minute step of the process.
Create a new domain/subdomain.
/public to the end of the web directory field. This is because Laravel’s index.php file is located here, and is the entry point for all requests.
If you’re not using another database provider, create a database through DreamHost (it’s included). On the DreamHost admin menu, under “Advanced”, you’ll see “MySQL Databases”. Create a new database, and note the Hostname URL, database name, database username, and database user password.
N.B. If you’re doing local development, you’ll have to add your IP address to the database user’s allowed IP address field. You can find it by clicking the username in the table at the bottom of the databases page. Any DreamHost domains are added by default.
Preparing Your Laravel Files (locally)
Create a new Laravel project locally, or get into the parent directory of your existing project.
Option A (No Source Control)
Zip the directory, and upload it to DreamHost. For Mac/Linux users, you can use SCP to quickly upload from the command line. Otherwise, use DreamHost’s in browser FTP service.
Unzip on the server. Y̵o̵u̵’̵l̵l̵ ̵n̵e̵e̵d̵ ̵t̵o̵ ̵S̵S̵H̵ ̵i̵n̵ ̵f̵o̵r̵ ̵t̵h̵i̵s̵ ̵s̵t̵e̵p̵.̵ You can now do this via DreamHost’s in browser FTP service.
Configure your .env file with the APP_URL and database values you noted down earlier.
Option B (Using Source Control)
Initialize a git repository in your Laravel project if you don’t have one already. I would recommend using Laravel’s .gitignore to filter out sensitive files, but it’s your choice. Publish your repository.
Clone that git repo in your domain directory on DreamHost.
git clone https://url-to-git-repo.git . That period is important, as it tells git to pull files to current directory, and not create a new directory.
Upload any missing files via SCP or DreamHost’s in browser FTP. You might find a hint as to what files are missing in your repo’s .gitignore file.
Finalizing Your Deployment
- Before you run any migrations, update
public function boot()
This will allow migrations to work with DreamHost’s older MySQL database system.
- Make sure you run your Laravel migrations (locally, or on the remote server. You’ll have to mess with specifying what version of php to use on DreamHost, so I would recommend running them locally.)
- Run through your .env file to make sure you have all the necessary fields filled out.
- Read Laravel’s deployment documentation, it’s always a good idea to read that information from the source.
And that’s it! Now you’re ready to start developing and deploying Laravel applications for dirt cheap.