After installing XAMPP server on your Linux computer, you may wonder: What next? Well, it’s time to create your first PHP project folder.
Your project folder and all your upcoming projects should typically reside inside the “htdocs” folder which can be located -by default- in /opt/lampp/htdocs
But once you’ve tried to save a file or a folder inside the “htdocs” you will receive an error message stating that you don’t have suffecient privileges to change the content of that folder!
OK! it’s very clear that this is not a regular folder that can be normally changed by anyone .. though, you should change the permissions of the “htdocs” to allow changes.. here’s how:
- Open your terminal
- navigate to the parent folder that contains the “htdocs” like this:
cd /opt/lampp
- Now let’s change the “htdocs” to grant access to everyone (including your code editor):
sudo chmod 755 htdocs
That’s all! Now you can create a new folder inside “htdocs” either manually or using a code editor. But before you go let’s understand what sudo chmod 755 file_name
really means.
Simply: sudo can be read like this: “Super User Do”..Obvious isn’t it? You are using the root authority to force a change.
“chmod” is a short for: “Change Mode” .. now it’s even clearer!
Finally: 755 file_name
needs a little explanation. Have a look on the following table of permissions:
0 – no permission
1 – execute
2 – write
3 – write and execute
4 – read
5 – read and execute
6 – read and write
7 – read, write, and execute
For each of the “Owner”, the “Group”, and the “Other”, you should grant a specific permission respectively.
Thus if you want to grant read, write, and execute permission for the owner.
Read permission for the group.
Read permission for other.
You should choose: 744.
And if you want to grant read, write, and execute for owner. Read, and write for group and only read for other you should type: 764.. and so on.
Maybe it worthy to discuss Unix systems (including Linux and Mac OS X) “File Control Mechanism” in greater details in its own post later .. I hope : )
That’s all for now… Happy coding!