Ubuntu: apache2,php and mysql - facing problem in editing the files and loading them in browser



Question:

friends, I have installed apache2 , php and mysql but now the problem is I don't know where to write the programs and put them back into the server folder so that I can access them back.My file i.e html and php file should be place in /var/www folder but when I try to create new document I'm not able to create it it's showing access denied. Please help me....


Solution:1

If you are not allowed access to a file, precede the command you are typing with sudo, this should prompt you for your password. The sudo command basically means "superuser do". So you have privileges of the root user when you use it. Example: sudo vi index.html.

Hope that sorts that part of the problem out for you.


Solution:2

The easiest way is to add your user to the group that owns /var/www/, usually www-data

Check the group of /var/www

ls -la /var/ | grep www  

where the output will be something like

drwxrwxr-x  3 www-data www-data 4096 ago  1 16:10 www  

on my output the second www-data position indicates the group is actually www-data

so now you have to add yourself to that group

sudo usermod -a -G www-data yourUserName  

ensure that users belong to www-data can write to that dir

sudo chmod -R 0775 /var/www/  

Logout and login again to refresh permissions. Now you should be able to write with your user on that under that dir.

Note : if the group is different from www-data, you should check which group is running apache and makes changes according to it

grep GROUP /etc/apache2/envvars   

The output is something like this

export APACHE_RUN_GROUP=www-data

To change the ownership of /www/data use

sudo chown -R useOwner:groupOwner /var/www/


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »