Using composer on a Dreamhost shared server

I'm starting yet another project (but this one I intend to finish, I swear πŸ™) and I'm using Symfony to develop it. But when you deploy to Dreamhost, you can't use composer by default (unless you are the proud owner of a VPS server).

I configured my site to use PHP 7.3 and with that I learned that that is the version for the webserver. When you connect via ssh it uses another version (7.2 in my case). That said, let's start:

Step 1: Updating the CLI version

Just update your .bash_profile file

export PATH=/usr/local/php73/bin:$PATH

Reload you bash using . ~/bash_profile. You can check if it worked using php -v.

Step 2: Installing composer

Install it globally by creating a folder at .php/composer and go into it:

mkdir ~/.php/composer
cd ~/.php/composer

Install composer:

curl -sS https://getcomposer.org/installer | php

And rename it (optional but useful):

mv ~/.php/composer/composer.phar ~/.php/composer/composer

And add it to your bash to make your life easier:

export PATH=/home/your_username/.php/composer:$PATH

Do not forget to reload your bash as before. πŸ‘

Step 3: Tweaking PHP

Create or update you phprc file at /home/your_username/.php/7.3/phprc

extension = phar.so
suhosin.executor.include.whitelist = phar
pcre.jit=0

extension = phar.so is just in case your phar is disabled. And pcre.jit is because of come strange error related to symfony console happening on 7.3. It happened to me but may not happen to you 😁

Step 4: Run composer

If everything is ok, you can navigate to your domain folder and run composer:

composer install

Assuming you already uploaded your files or cloned your repository, of course πŸ‘€

Cleiver

I'm Cleiver, I'm 35, I'm a software developer and I'm too lazy to write a better description

Write your comment…

Be the first one to comment