Preparing the htdocs folder for your first PHP project – Here’s how I did it.

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:

  1. Open your terminal
  2. navigate to the parent folder that contains the “htdocs” like this:

    cd /opt/lampp

  3. 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!

Start/Stop XAMPP – Here’s how I did it.

Maybe the very next thing you would like to know after successfully installing XAMPP on your Linux is: How to start and stop XAMPP and its services. Here is how:

  1. Open Terminal by clicking on it in the quick lunch bar or choose it from menu.
  2. To start the XAMPP server type:
    sudo /opt/lampp/lampp start
  3. Now you should see the following message:
    Starting XAMPP 1.8.2...LAMPP: Starting Apache...

    LAMPP: Starting MySQL...

    LAMPP started.

To stop XAMPP server do the following:

  1. While inside the Terminal type:
    sudo /opt/lampp/lampp stop
  2. You would see the following messages:
    Stopping XAMPP 1.8.2...
    LAMPP: Stopping Apache...
    LAMPP: Stopping MySQL...
    LAMPP stopped.

Using the XAMPP graphical tool

There is a very simple but yet affective graphical tool that comes with XAMPP, and if you prefer to use it do the following:

  1. Open the Terminal.
  2. Navigate to the folder where you installed your XAMPP by typing:
    cd /opt/lampp
  3. run the tool using the super user privileges by typing:
    sudo ./manager-linux.run
    or if you are using 64bit computer type:
    sudo ./manager-linux-x64.run

That’s all for now … have fun, and.. happy coding

Installing XAMPP on Linux – Here’s how I did it.

Since I am using Linux Mint 17.1 ‘Rebecca’, Cinnamon Edition, “XAMPP” was the right choice for me to configure an Apache server and continue building PHP apps but on Linux platform this time. My problem was that I used to be a Microsoft windows user for more than 15 years, and naturally “WAMP” (Windows, Apache, MySQL, PHP) used to be my favorite choice to configure a full PHP development environment.
Anyway, I found no problem configuring XAMPP on my localhost though since everything I needed is out there on the Internet. All the documentations, instructions, and even visual tutorials are there for any new comer.

However, here’s how I did it step by step:

1- I went to : www.apachefriends.org and navigated to the download link.

2- I found my suitable version of XAMPP (Mine was: 5.6.8 / PHP 5.6.8 32Bit) and clicked on it to start downloading.

3- After the download was finished, I navigated to the downloaded file, and cut it from there to my “Desktop” just to be easy to deal with.

4- I opened the “Terminal” window and change directory to the Desktop like this:
cd Desktop
5- I changed the permissions for the installer by typing the following command:
chmod 755 xampp-linux-*-installer.run
6- Then I ran the installer by typing:
sudo ./xampp-linux-*-installer.run
7- Everything went just fine, and XAMPP was installed under /opt/lampp directory.
8- At this point it was time to start the XAMPP and all its services (Apache, PHPMyAdmin ..etc.) so again inside the ‘terminal’ I typed:
sudo /opt/lampp/lampp start
9- That’s all, now I have XAMPP installed and running on my Linux Machine (Trust me if you did the same you will get the same result).But.. (yes there’s always but..) what about putting my new project folder in the action area (htdocs) … this is gonna be my next “Here’s how I did it” Tip.