I've tried other posts I found online but none seemed to work correctly. I'm working with this. And I make my way to the root of it, which is /var/www/
. So then I do composer install
and I have a composer.json
file in there. I get
[RuntimeException]
vendor does not exist and could not be created.
Here's the file
{
"name": "panique/php-login",
"type": "project",
"description": "A PHP login system embedded in a simple MVC framework",
"keywords": ["login", "auth", "user", "authentification", "mvc"],
"homepage": "https://github.com/panique/php-login",
"license": "MIT",
"authors": [
{
"name": "Panique",
"homepage": "http://careers.stackoverflow.com/panique",
"role": "Developer"
}
],
"support": {
"issues": "https://github.com/panique/php-login/issues",
"source": "https://github.com/panique/php-login"
},
"require":{
"php": ">=5.3.7",
"ircmaxell/password-compat": "1.0.*",
"phpmailer/phpmailer": "5.2.*",
"gregwar/captcha": "dev-master",
"facebook/php-sdk": "@stable",
"raveren/kint": "dev-1.0.0-wip"
}
}
I'm not really sure where to go from here....
Googlers, do not use composer with sudo:
Add your user in the www-data group (this action require you to logout and login again)
sudo usermod -a -G www-data `whoami`
Give the right permissions to /var/www
sudo chown root:root /var/www
sudo chmod 755 /var/www/
Give these permissions to your project
sudo chown -R www-data:www-data /var/www/<project>
sudo chmod -R 774 /var/www/<project>
instead of modifying permissions on any folder, and when using command line (CLI) simply use "sudo" and it will ask for a password, input the password for your root user and all should go well. :) much more secure.
Edit it is no longer considered good practice to use sudo for composer. Installing composer globally will fix the issue. The error with permissions are usually caused whrn you are editing files dirrctly on the server. Web deving on your live server is not the way to go.
@Etienne Gautier 's approach is fine.
Another solution is just to change the mode and owner/group of /vendor
.
e.g.
sudo chown -R 775 /root-of-your-app/vendor/
sudo chown -R $USER:$USER /root-of-your-app/vendor/
Etienne Gautier's answer is alright. You can try it also. Just give the right permission to your project directory by using your terminal:
sudo chmod -R 0755 /var/www/<your_project_name>/public
and also give a permission to vendor dir. Use it while you don't want to give permission to your /var/www
directory.
This happens because we do not have administrator permissions, we just have to put the word sudo, it would look like this: sudo composer install