Welcome to WebmasterWorld Guest from 54.162.151.77

Forum Moderators: coopster & jatar k

Composer install command error

     
12:02 pm on May 15, 2019 (gmt 0)

New User

5+ Year Member

joined:Aug 19, 2013
posts: 17
votes: 0


Hello all,
I have a script and i have to install it with "composer install" so when i do this i get this error.

All my script files are in my virtualserver (public_html)

root@vmiserver:~# composer install
Do not run Composer as root/super user! See [getcomposer.org...] for details
Composer could not find a composer.json file in /root
To initialize a project, please create a composer.json file as described in the [getcomposer.org...] "Getting Started" section
5:26 pm on May 17, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2637
votes: 5


You can run it as root and usually there is no real consequence, however......

Best practice would be to have your directory permission set up to run for a "user"

For example. You have a server and you are running a project on it called "blog", you would want to create a new user on the server to "own" the app and it's files.

To do that run this:
root@vmiserver:~# adduser blog

Then set the owner of the blog application directory to be the new blog user. If this application is going to be using apache to run then set the group to be www-data, if not you can set the group to be blog as well

To do that run this:
root@vmiserver:~# chown blog:blog -R /path/to/app/blog
**Or for Apache**
root@vmiserver:~# chown blog:www-data -R /path/to/app/blog

Now when you are running composer commands for the blog app you want to become that user

To do that run this:
root@vmiserver:~# sudo -u blog -s

Now from the blog folder you can run composer commands as the blog user for the blog app.

blog@vmiserver:~# cd /path/to/app/blog
blog@vmiserver:/path/to/app/blog$ composer install

Hopefully that makes sense.
5:33 pm on May 17, 2019 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2637
votes: 5


Oh also make sure that /path/to/app/blog contains a composer.json file.