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 some 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 ๐Ÿ‘€

Comments (1)

Add a comment
Donny Vรกsquez's photo

Hello, thanks for this post. Really you've save my day.
Trying to instal AMP library composer is killed and i get this:

> 
Cannot load Zend OPcache - it was already loaded

error_composer_zend_opcache.png

My phprc has:

; {{{ The following lines were automatically added by DreamHost

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

; }}} That's all from DreamHost

Can you help me?