Magento httpd permissions issues - apache

I am trying to install magento2 on a CentOS server. I am continuously getting permissions issue, the magento diretory is owned by apache and I set permissions to 777 (i know it is bad but just to test) but I still get permissions denied on file write. the path to magento dir is /var/www/html. I set permissions to /var/www/ and all sub-folders to 777 and file owner to apache still same.
also
egrep -i '^user|^group' /etc/httpd/conf/httpd.conf (returns)
User apache
Group apache
any suggestions or ideas, please?
Kind Regards
Sajid

Try following steps
sudo /usr/sbin/groupadd wwwrun
sudo usermod -g wwwrun test
cd /var/www/html/magento2 && sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R apache:apache . && sudo chmod u+x bin/magento
where test is the current logged-in user and then restart the http server.

Related

file permission magento2 app/etc

Hi I am trying to install magento2 on a vps centos
I followed the instructions about file permission in magento documentation
http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html
I got the same erorr while installing :
/var/www/html/magento2/app/etc" Not writable, change the permissions.
Do I need to restart apache after I change some permissions.
Thanks for help.
If you are using the setup wizard, it will ask you for permission to write to the app/etc/env.php
I would advise you to use the bin/magento cli tool to setup the app:
php bin/magento setup:install
But it is fine to temporary allowing the web server to write to your env.php, after the UI wizard finished you can change it back to the correct file permission.
For this you need to clear cache.
php bin/magento cache:flush
or you can switch to the developer mode
php bin/magento deploy:mode:set developer
Use below commands to set permissions and then restart apache:
sudo usermod -g wwwrun <yourusername>
cd /var/www/html/magento2 && sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R apache:apache . && sudo chmod u+x bin/magento
You need run this code:
chcon -R -t httpd_sys_rw_content_t /var/www/html/magento2/
chmod -R a+w /var/www/html/magento2/
Note: Magento2 is folder where you was install magento

Apache File permissions issue in Ubuntu

I'm trying to use Apache to access a file on my Documents folder.
I tried the following:
sudo chown -R www-data:www-data /home/$USER/public_html
sudo adduser $USER www-data
sudo chmod -R 775 /home/$USER/public_html
As suggested by this post:
https://askubuntu.com/questions/26848/permissions-issue-how-can-apache-access-files-in-my-home-directory
Although this works, now I cannot edit or the files directly as the user (without using sudo), despite being a member of the www-data group. The only solution that seemed to work is using chmod -R 777 (which I rather not do).
Turns out all I had to do is restart the OS and it was sorted!

ubuntu : can't cd to /var/www despite being in www-data group

Am trying to set up a web site in an apache2 www folder on ubuntu 12.04 LTS.
Installed the LAMP as per the manual: sudo apt-get install lamp-server^
Then have done:
$ usermod -g www-data myuser
$ sudo chown -R www-data:www-data /var/www
$ sudo chmod -R go-rwx /var/www
$ sudo chmod -R g+rw /var/www
$ sudo chmod -R o+r /var/www
So, was going to copy files into www..
But when I (as myuser) try to
$ cd /var/www
I get :
-bash: cd: /var/www: Permission denied
Not sure what to do now...myuser is in the www-data group...
But, one thing that might not be right is that my user is only in sudo and www-data... should it be in users as well?
Thanks
You need to add executable permissions to a folder in order to be able to cd into it.
So, you should have done:
$ sudo chmod -R g+rwx /var/www

Recursive write permissions for Apache user

Hello I am trying to install Prestashop on my LAMP server via SSH but when run the installation process. I got these error.
The Prestashop files are located in /var/www/html What should I do?
Thanks Morris Mukiri,
I tried all the chmod, chown, chgrp , but the prestashop error message still there .
Your suggestion of "allow apache do writes" worked !
setsebool -P httpd_enable_cgi on
setsebool -P httpd_unified on
setsebool -P httpd_builtin_scripting on
These few lines did the magic.
Find the Apache user and change the owner of the folders recursively.
E.g., if the Apache user is apache then:
chown -R apache:apache /var/www/html/config /var/www/html/cache...
Change the permissions for the document root folder
sudo chmod -R 755 /var/www/html/
You might want to add yourself to the same group as apache using
useradd -G {group-name} username
Try adding a rule in Selinux to allow apache do writes
sudo setsebool -P httpd_enable_cgi on
sudo setsebool -P httpd_unified on
sudo setsebool -P httpd_builtin_scripting on

permission in var/www on ubuntu

I was able to access and view the files when i first set it. i then realize that my css sheet was not running so i check the source code in Firefox and realize that i didn't have permission to view this file. so i decided to run a permission on the entire www folder.
Now im getting a 403 error. i tried changing back the permission but still having the same problem. i tried
find /var/www/ -type d -exec chmod 755 {} \;
find /var/www/ -type f -exec chmod 644 {} \;
these didn't work, please help
sudo chmod 0777 -R /var/www
-R is recursive, I assume that your web files are located in /var/www.