Closed jasperf closed 7 years ago
I haven't tested on Ubuntu 17, so no guarantees there... but this should work the same whether using root or another user.
This task: https://github.com/geerlingguy/ansible-role-composer/blob/master/tasks/global-require.yml#L13-L18
Uses this template: https://github.com/geerlingguy/ansible-role-composer/blob/master/templates/composer.sh.j2
To put composer paths in the global $PATH settings.
Note, however, that if you do this in one terminal session, you would need to then log out and log back in to see the updated $PATH
. Otherwise the new global environment variables won't be read in.
I think the issue I am having is that I just need to have composer available for the web user. And as I install it as root composer and laravel become available for root and are added to the global path for root. I just need it to work for either both root
and web
or just for web alone.
To have composer installed at /usr/local/bin/composer
root access is needed or sudo
. The user web
will not be sudo as I want that user only to work in the webroot. So in this case I have to install the role as root.
Doing a new installation now and reading some on adding composer to path like https://stackoverflow.com/questions/25373188/laravel-installation-how-to-place-the-composer-vendor-bin-directory-in-your once again. Will do some more trials with perhaps additional commands as tasks.
Solved it by adding
- name : Add Composer to path
lineinfile: dest=/home/web/.bashrc state=present line='export PATH="$PATH:$HOME/.composer/vendor/bin"'
to user web. And for composer I am using these variables:
composer_global_packages:
- { name: laravel/installer }
composer_home_path: '/home/web/.composer'
composer_home_owner: web
composer_home_group: www-data
composer_add_to_path: true
Trying to set up composer so I can use my web user to install Laravel. So I added
but composer does not get added to the web user's path:
When I only added
it did get added to the root user path:
I only thought it would get added to the system path as stated in the readme: