Which permissions should be for symfony 3 folders and files? - php

I've reinstall Ubuntu 16.04 and after getting pull my symfony 3.4 project from git, it loads but without CSS and JS. I think that the problem with the permissions for folders and files.

If it's permissions related, then first make sure of which user is your web user.
If you never changed it, then it's www-data
As for the permissions, do this (replace www-data if needed):
chown -R www-data:www-data /var/www/
find /var/www/ -type d -exec chmod 0775 "{}" \;
find /var/www/ -type f -exec chmod 0664 "{}" \;
find /var/www -type d -exec chmod g+s "{}" \;
[Warning]
In some projects like symfony, some files have the execution permission.
Doing this will remove the permission.
Thus, I recommand to move all your projects out of the /var/www folder before doing this.
When done with permissions, just copy (not move) your projects in the /var/www folder, they will inherit web user and web group (www-data in this case) and keep execution permission.
[Side note]
You're using too many tags.
file-permissions, symfony, ubuntu should have been enough... ;)

Related

Raspberry Pi 3, browser permissions on apache2 php script

Having a nightmare with permissions on RP3, apache2, php
I can run my php api script from terminal with no problems. I use the browser for debugging and get the 'permission denied' when trying to edit text files from the browser.
I have temporarily set permissions to 777 on /var/www but this is insecure, and i can no longer remember the original permissions that were on /var/www
Can i somehow give the broswer (chromium) permission to edit files in /var/www?
I have tried setting inheritance, but to no avail, as i am copying files over all the time, i have to keep resetting the permissions to 777 (which is not ideal), so i can debug the code in a browser.
Any help would be greatly appreciated
Rgds
Mike
Usually, the permissions for folders are 0755 and for folders are 0644.
To set the permissions for folders:
sudo find /var/www -type d -exec chmod 0755 {} \;
To set the permissions for files:
sudo find /var/www -type f -exec chmod 0644 {} \;
Now about the user/group, Apache is probably using the user www-data with group www-data.
To set the user/group for write permissions:
sudo chown www-data:www-data /var/www -R
A note about security: opening up the option to edit the files from the browser is insecure without any login, allowing anyone to edit your files. Also, the write permissions should only be allowed in a directory where the users upload files and NOT for all your /var/www files.

I can't delete the folder generated/code in Magento 2.2.6

I use Docker for my project. After installing the 2.2.6 package with sample data, it gives me problems like the following when I execute php bin/magento cache:clean
The file "/var/www/html/src/generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php" cannot be deleted Warning!unlink(/var/www/html/src/generated/code/Magento/Backend/App/Request/PathInfoProcessor/Proxy.php):
No such file or directory
The generated/code folder can not be deleted and I have to restart my computer then it does let me delete the folder
I use php 7.1.22 , percona 5.6.39 and docker Version 18.06.1-ce-win73 (19507)
This happens due to insufficient permissions on the project folder and files.Also www-data must be owner of the project if using Apache as web-server.
Please execute commands given below:--
sudo chown -R www-data:www-data [path to magento directory]
navigate to root of your magento project
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod u+x bin/magento
An important mania for people who offer their help is to think that all systems are the same.
www-data is the user as long as there are conditions, which many will not meet, because they prefer to use nginx + php-fpm instead of the generalist model.
Other times, included in that model is not the user running Appache, nginx or in the end, php, is www-data.
So the most correct answer is not:
Change the owner of the entire magento folder to www-data
Neither give permissions 777, this is the most common of all the aberrations in the network.
Lo mas correcto sería
Who executes the process you write in the magento directory?
PHP writes as user or globally?
I have consulted the configuration of my php (php, php-fpm, etc.) to verify which user is the one that executes the operations?
Once we have that data then if we can execute
sudo chown -R <user_correct>: <group_correct>
And please, stop paying attention to those who always write chmod -R 777
Or one day they will wake up without their site in a normal way but full of infections that are hardly curable.
Installing magento 2 from the command line of the container in Docker solves the problem of writing permissions in Windows for me
You may need to adjust the parameters:
bin/magento setup:install --base-url=http://local.shop.magento2.com \
--db-host=db_magento2 --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=magento --admin-lastname=magento --admin-email=user#example.com \
--admin-user=admin --admin-password=admin123 --language=en_US \
--currency=USD --timezone=Europe/Madrid --use-rewrites=1
Just in case anyone stumbles upon this:
Add the following to your docker file
RUN echo "root:root" | chpasswd
This will allow you to switch to root and run chown
su root
password:root
chown -R user:group /folder

AWS - Changed Permission of All files to ec2-user and wordpress is not uploading or owning any files now

I was not able to upload any files in filezilla.. so i changed permission of all files under /var/www/html to ec2-user
I ran this command - chown -R ec2-user /var/app/current
After that Filezilla was working but it burnt the apache.
Now wordpress doesnt create any files in wordpress directory. It says it doesnt have any permission. I guess i killed permission of apache on those files. How can revert back the changes? or atleast how can i give the permissions back as it was?
Add ec2-user to apache group :
sudo usermod -a -G apache ec2-user
Logout and Re-login to instance
Change the group ownership of /var/www and its contents to the apache group.
sudo chown -R ec2-user:apache /var/www
To add group write permissions and to set the group ID on future subdirectories, change the directory permissions of /var/www and its subdirectories.
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:
find /var/www -type f -exec sudo chmod 0664 {} \;
Pleae Refer to this AWS Documentation

wordpress could not create directory

Good day folks,
I was trying to update my wordpress site and i have this error:
Unpacking the update… Could not create directory. Installation Failed
After googling, i have found a solution that says:
Web Server Ownership
The first level is actually to make sure that your web server has ownership over the directories:
chown -R www-data:www-data your-wordpress-directory
Directory Permissions
The second level is also required – you must make sure that the directory permissions are properly set:
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;
Could anyone guide me how to perform those tasks?
Regards

Enabling write permissions Ubuntu Server in var/www/image directory

I'm trying to get my php test upload script to work and was wondering what the command would be to allow files to be uploaded in ubuntu server in the var/www/image directory
What username will be uploading the files? Usually on Ubuntu the Apache web server username is www-data. You can check for sure by finding the web server process in a process list command and seeing which username under which it is running.
ps aux | grep apache or ps aux | grep httpd should give you that answer.
Then you will usually want to make that Apache username the owner of the directory and all files and directories within it:
cd /var/www/image
# recursively (all subdirs & files) set owner to www-data for current directory
chown -R www-data .
Ordinarily, the above should be enough, but if for some reason the directory, files or subdirectories do not have write permission for the owner username, that's easily fixed by changing the permissions to add that write access, like this:
cd /var/www/image
# recursively add "w"rite permissions for the "u"ser (owner) to current directory
chmod -R u+w .
cd /var/www/image
For file like image you don't need execution permission :
sudo chmod 664 *
If you have directories inside image and you want to apply permission :
sudo find . -type d -exec chmod 755 "{}" \;
This will recursively search your directory and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
sudo find . -type f -exec chmod 644 "{}" \;
File name with space case (thanks to Nicklas B)
find . -type f -print0 | xargs -0 chmod 644
Change edit group to www-data
chown -R (owner):www-data (folder)
And folder permission to 775
cd /var/www
sudo chmod 775 image
You'll be prompted to enter the admin password - do so, and hit [return].
Change edit group may solve most of the problems of permissions.
Changing do www-data and set permission to 775.

Categories