Limit permissions again from a folder

0

I have my PHP in the following path: OPT / LAMPP / HTDOCS / PAGE WEB ... For the language to allow me to create documents with a function called FOPEN I had to give total permissions to the LAMPP folder, with the following code:

sudo chmod -R 777 lampp

Everything went well, I was able to create the documents from php with fopen. But today, I want to practice with a database, and I enter phpmyadmin, I get the following message: Incorrect permissions in the configuration file, anyone should not be able to modify it! ... I guess I have to the solution is to remove the total permissions back to my lampp folder, but I do not know how to invert the commands .

    
asked by rai 30.10.2017 в 20:45
source

1 answer

0

The important thing is that the user that uses your server (which executes the php interpreter) has the permissions to access those files. now if you use apache2 usually said users is www-data so first what you need to do is change the group of files.

sudo chown -R :www-data  OPT/LAMPP/HTDOCS/PAGINA

here what we are doing is that the files of the page belong to the group www-data . Now, as the php myadmin tells you with 777 permissions you are telling the computer that these files can be read, written and executed by anyone (total disaster) so you must change to a permission format where only the owner of the files or members of the same group can edit them. for this we do

sudo chmod -R 774  OPT/LAMPP/HTDOCS/PAGINA 

There we are giving total permissions to both the owner of the file (the first 7), the group of files (in this cases www-data , with the second 7) and 4 indicates that the rest of the users only have Read permission. Here your application should work well. but in some cases the group should not have all the privileges either.

To clarify the permissions I recommend you read this document wikipedia

  

Octal notation

     

Another very common way to represent Unix permissions is the notation   octal, which consists of a value of three or four digits in base 8.

     

With the three-digit octal notation, each number represents a   different component of the permission set: user class, class   of group and class of the rest respectively.

     

Each of these digits is the sum of the bits that make it up   (see also binary numbering system). The weight of each bit in   one digit is as follows:

El bit de lectura suma 4 al total.
El bit de escritura suma 2 al total.
El bit de ejecución suma 1 al total.
     

These values never produce an ambiguous combination: every sum   Represents a specific set of permissions.

     

Here are the examples in the symbolic notation section above in   its octal notation:

"-rwxr-xr-x" se representa como 755 en notación octal de tres dígitos.
"-rw-rw-r--" se representa como 664 en notación octal de tres dígitos.
"-r-x------" se representa como 500 en notación octal de tres dígitos.
    
answered by 30.10.2017 в 20:55