Deploy Drupal
Back to home
On this page
Deployment
Now you have your configuration for deployment and your app set up to run on Platform.sh.
Make sure all your code is committed to Git
and run git push
to your Platform.sh environment.
Your code is built, producing a read-only image that’s deployed to a running cluster of containers.
If you aren’t using a source integration, the log of the process is returned in your terminal.
If you’re using a source integration, you can get the log by running platform activity:log --type environment.push
.
When the build finished, you’re given the URL of your deployed environment. Click the URL to see your site.
If your environment wasn’t active and so wasn’t deployed, activate it by running the following command:
platform environment:activate
Post-install (new site)
If you are creating a new site, visiting the site in your browser will trigger the Drupal installer.
Run through it as normal, but note that you will not be asked for the database credentials.
The settings.platformsh.php
file added earlier automatically provides the database credentials
and the installer is smart enough to not ask for them again.
Once the installer is complete you are presented with your new site.
Migrate your data
If you are moving an existing site to Platform.sh, then in addition to code you also need to migrate your data. That means your database and your files.
Import the database
First, obtain a database dump from your current site, such as using the
Drupal has a number of database tables that are useless when migrating and you’re better off excluding their data.
- If you’re using a database cache backend then you can and should exclude all
cache_*
table data. On Platform.sh we recommend using Redis anyway, and the template described on the previous pages uses Redis automatically. - The
sessions
table’s data can also be excluded.
While you can trim the data out of these tables post-migration, that’s wasteful of both time and disk space, so it’s better to exclude that data to begin with.
Next, import the database into your Platform.sh site by running the following command:
platform sql < dump.sql
That connects to the database service through an SSH tunnel and imports the SQL.
Import files
First, download your files from your current hosting environment. The easiest way is likely with rsync, but consult your host’s documentation.
This guide assumes that you have already downloaded
all of your user files to your local files/user
directory and your public files to files/public
, but adjust accordingly for their actual locations.
Next, upload your files to your mounts
using the platform mount:upload
command.
Run the following command from your local Git repository root,
modifying the --source
path if needed.
platform mount:upload --mount src/main/resources/files/user --source ./files/user
platform mount:upload --mount src/main/resources/files/public --source ./files/public
This uses an SSH tunnel and rsync to upload your files as efficiently as possible. Note that rsync is picky about its trailing slashes, so be sure to include those.
You’ve now added your files and database to your Platform.sh environment. When you make a new branch environment off of it, all of your data is fully cloned to that new environment so you can test with your complete dataset without impacting production.
Go forth and Deploy (even on Friday)!