Installing Composer on a Dreamhost VPS, or perhaps other VPS's

By: (plus.google.com) +David Herron; Date: January 12, 2018

Tags: PHP

Modern PHP software development has been modernized by Composer. My exposure to Composer is because the Drupal team adopted the Symfony framework, which in turn is based on Composer. Installing Drupal any longer seemingly requires to first install Composer. Which isn't installed by default on Dreamhost VPS's, but it's not too hard to get it going.

Fortunately it's a lot simpler than it was the first time I tried this a couple years ago.

Because Dreamhost VPS's don't allow root access, you must install Composer and its dependencies in your home directory. The sticking point I had a couple years ago was to install the PHAR extension.

Installing PHAR

The first thing is to verify whether PHAR is installed:

$ php -m | grep Phar
Phar

If you get this output, then skip this next step.

SKIPPABLE STEP: The corresponding Dreamhost Wiki page says to create a PHPRC file, /home/USERNAME/.php/VERSION/phprc, and add these lines:

extension = phar.so 
suhosin.executor.include.whitelist = phar

On my VPS I found the PHPRC file to already exist and to already contain those lines.

Once you add those lines to your PHPRC, the above command should work. END SKIPPABLE STEP

Switching PHP version for command-line use

Another thing you may wish to do is to change the default PHP version used at the shell command line. What you do is enable this PATH variable change:

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

On Dreamhost VPS's, they have multiple PHP versions installed as so:

$ ls -d /usr/local/php*
/usr/local/php53  /usr/local/php54  /usr/local/php55  /usr/local/php56	/usr/local/php70  /usr/local/php71

So, pick your poison. And after switching the PHP version, make sure the PHAR extension is enabled for that version.

Installing Composer

Now that the dependency has been squared away we can install Composer.

There are two modes to consider :- 1) an installation local to a given project, 2) a global installation.

For a local installation:

$ cd ~/<path-to-your-project>
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar composer
$ ./composer

The last command should produce a long bit of USAGE output. What this does is download the Componser installer, and run it using PHP. That creates composer.phar in your current directory. For convenience you can rename that file to just composer, and because the PHAR extension is installed you can simply run the PHAR archive.

A global installation is extremely similar but that you'll add a directory to the PATH variable.

For example I keep ${HOME}/bin in my PATH variable on my VPS and install scripts there. The Dreamhost Wiki says to install it in ~/.php/composer, however. The process is the same:

$ cd ~/bin
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar composer
$ ./composer

What will be different is to follow this up with adding a line to your ~/.bashrc:

export PATH=/home/<username>/.php/composer:$PATH

In this case it is for installation in ~/.bin/composer, and if you've done as written above you would use ${HOME}/bin in the PATH variable instead.

Once the PATH variable is set up correctly:

$ composer

Should work

Links

Source: (help.dreamhost.com) https://help.dreamhost.com/hc/en-us/articles/214899037-Installing-Composer-overview

Source: (help.dreamhost.com) https://help.dreamhost.com/hc/en-us/articles/214202148-How-do-I-change-the-PHP-version-my-shell-uses-

Source: (getcomposer.org) https://getcomposer.org/

« Google possibly dooms YouTube by explicitly cancelling monetization for channels with low viewership These github alternatives give you powerful git hosting, on your own terms »
2016 Election Acer C720 Ad block AkashaCMS Amazon Amazon Kindle Amazon Web Services America Amiga and Jon Pertwee Android Anti-Fascism AntiVirus Software Apple Apple Hardware History Apple iPhone Apple iPhone Hardware April 1st Arduino ARM Compilation Artificial Intelligence Astronomy Astrophotography Asynchronous Programming Authoritarianism Automated Social Posting AWS DynamoDB AWS Lambda Ayo.JS Bells Law Big Brother Big Data Big Finish Big Science Bitcoin Mining Black Holes Blade Runner Blockchain Blogger Blogging Books Botnets Cassette Tapes Cellphones China China Manufacturing Christopher Eccleston Chrome Chrome Apps Chromebook Chromebox ChromeOS CIA CitiCards Citizen Journalism Civil Liberties Clinton Cluster Computing Command Line Tools Comment Systems Computer Accessories Computer Hardware Computer Repair Computers Conservatives Cross Compilation Crouton Cryptocurrency Curiosity Rover Currencies Cyber Security Cybermen Cybersecurity Daleks Darth Vader Data backup Data Formats Data Storage Database Database Backup Databases David Tenant DDoS Botnet Department of Defense Department of Justice Detect Adblocker Developers Editors Digital Photography Diskless Booting Disqus DIY DIY Repair DNP3 Do it yourself Docker Docker MAMP Docker Swarm Doctor Who Doctor Who Paradox Doctor Who Review Drobo Drupal Drupal Themes DVD E-Books E-Readers Early Computers Election Hacks Electric Bicycles Electric Vehicles Electron Eliminating Jobs for Human Emdebian Encabulators Energy Efficiency Enterprise Node EPUB ESP8266 Ethical Curation Eurovision Event Driven Asynchronous Express Face Recognition Facebook Fake News Fedora VirtualBox Fifth Doctor File transfer without iTunes FireFly Flash Flickr Fraud Freedom of Speech Front-end Development G Suite Gallifrey git Github GitKraken Gitlab GMAIL Google Google Chrome Google Gnome Google+ Government Spying Great Britain Green Transportation Hate Speech Heat Loss Hibernate Hoax Science Home Automation HTTP Security HTTPS Human ID I2C Protocol Image Analysis Image Conversion Image Processing ImageMagick In-memory Computing InfluxDB Infrared Thermometers Insulation Internet Internet Advertising Internet Law Internet of Things Internet Policy Internet Privacy iOS Devices iPad iPhone iPhone hacking Iron Man iShowU Audio Capture iTunes Janet Fielding Java JavaFX JavaScript JavaScript Injection JDBC John Simms Journalism Joyent Kaspersky Labs Kext Kindle Kindle Marketplace Large Hadron Collider Lets Encrypt LibreOffice Linux Linux Hints Linux Single Board Computers Logging Mac Mini Mac OS Mac OS X Machine Learning Machine Readable ID macOS macOS High Sierra macOS Kext MacOS X setup Make Money Online March For Our Lives MariaDB Mars Mass Violence Matt Lucas MEADS Anti-Missile Mercurial MERN Stack Michele Gomez Micro Apartments Microsoft Military AI Military Hardware Minification Minimized CSS Minimized HTML Minimized JavaScript Missy Mobile Applications Mobile Computers MODBUS Mondas Monetary System MongoDB Mongoose Monty Python MQTT Music Player Music Streaming MySQL NanoPi Nardole NASA Net Neutrality Network Attached Storage Node Web Development Node.js Node.js Database Node.js Performance Node.js Testing Node.JS Web Development Node.x North Korea npm NVIDIA NY Times Online advertising Online Community Online Fraud Online Journalism Online Photography Online Video Open Media Vault Open Source Open Source and Patents Open Source Governance Open Source Licenses Open Source Software OpenAPI OpenJDK OpenVPN Palmtop PDA Patrick Troughton Paywalls Personal Flight Peter Capaldi Peter Davison Phishing Photography PHP Plex Plex Media Server Political Protest Politics Postal Service Power Control President Trump Privacy Production use Public Violence Raspberry Pi Raspberry Pi 3 Raspberry Pi Zero ReactJS Recaptcha Recycling Refurbished Computers Remote Desktop Removable Storage Republicans Retro Computing Retro-Technology Reviews RFID Rich Internet Applications Right to Repair River Song Robotics Robots Rocket Ships RSS News Readers rsync Russia Russia Troll Factory Russian Hacking Rust SCADA Scheme Science Fiction SD Cards Search Engine Ranking Season 1 Season 10 Season 11 Security Security Cameras Server-side JavaScript Serverless Framework Servers Shell Scripts Silence Simsimi Skype SmugMug Social Media Social Media Networks Social Media Warfare Social Network Management Social Networks Software Development Software Patents Space Flight Space Ship Reuse Space Ships SpaceX Spear Phishing Spring Spring Boot Spy Satellites SQLite3 SSD Drives SSD upgrade SSH SSH Key SSL Stand For Truth Strange Parts Swagger Synchronizing Files Tegan Jovanka Telescopes Terrorism The Cybermen The Daleks The Master Time-Series Database Tom Baker Torchwood Total Information Awareness Trump Trump Administration Trump Campaign Twitter Ubuntu Udemy UDOO US Department of Defense Virtual Private Networks VirtualBox VLC VNC VOIP Vue.js Walmart Weapons Systems Web Applications Web Developer Resources Web Development Web Development Tools Web Marketing Webpack Website Advertising Weeping Angels WhatsApp William Hartnell Window Insulation Windows Windows Alternatives Wordpress World Wide Web Yahoo YouTube YouTube Monetization