Hey buddies, this is my first post in this web development series. Through this blog, I will be posting the tutorials on web developments. So, I am here with my very first post in which I will start with the setup and configuration of PHP in the Windows and Linux operating system with the XAMPP server. In this post, you will learn how to install a server in the local system and make it ready for the PHP development.
XAMPP and Localhost
XAMPP is open-source software and free to use. It creates a server on the local system which is called localhost. A server allows us to see the live updates of the website that is being changed.
Installation of XAMPP on Windows
You can download, install and configure XAMPP by following the below steps-
- Download the latest version from the official website of the Apache Friends.
- Double click on the executable file.
- It will open a warning message, click on OK to continue the warning.
- Click the Next button.
- In the next step, you will see the various components that are inbuild with the XAMPP. Actually, it offers the different types of components which you can install as per the requirements. It is recommended to install all the components as the default. So just click on the Next to continue the installation process.
- The default installation path in Windows is C:\ but you can change the installation directory. In my case, I am leaving everything to as default. So, just click on the Next button.
- In the next step, you no need to check for Learn more about Bitnami for XAMPP.
- Click on Next to continue for the next step.
- For the security purpose, the Windows Firewall will ask to allow access. So, allow access (if applicable).
- Now, click finish to over the installation process.
How to Configure and Start XAMPP Server
Once you have completed the installation process, just open the XAMPP control panel after clicking on the Finish button. For, the first time, it will ask you to choose the language (English or German).
- Choose your language and save it.
- Now, the XAMPP control panel will appear you.
Configure XAMPP Server
In the XAMPP Control Panel, there are three main sections. In the Modules, you will find all the available services which you have installed during the installation. You can run each service by just clicking on the Start button.
In my case, I have started the Apache and MySQL. You can see in the right side of each module services there is process ID, Port(s) and the Actions. Every module services have it’s own process Id and the Port on which it will run. By default, the Apache uses TCP/IP port 80 and 443, and MySQL uses TCP/IP port 3306 which is shown below.
How to Run PHP in Localhost
If the installation and configuration process has been done and you have started the Apache and MySQL services in the control panel. Now, it’s time to check PHP is working is running and everything is working correctly or not.
- Open your favorite browser and type localhost in the URL.
- An index page of the XAMPP will open.
- Click on phpMyAdmin.
- The phpMyAdmin is the database panel of the MySQL. This is an inbuilt service which you have installed.
- In the phpMyAdmin, you can create a Database and the tables. (We will see it in upcoming posts)
How to Create a PHP File
For creating a PHP file you will need a text editor in which you will write the PHP scripts. I recommend you to choose some advanced editor apart from Notepad and Notepad++.
Download some advanced editor which supports the plugins and library of multiple languages like Sublime, Atom, PHP Storm, VS Code, etc.
<?php echo "Hello PHP" ; ?>
- Paste the above code inside the C:\xampp\htdocs.
- PHP scripts always required to save inside its installation directory. So, save your PHP scripts in the htdocs folder.
- In my case, I am going to save it inside a new folder named php-examples inside the htdocs.
- Save the file with any name but with .php extension.
- In my case, I am going to save it with the name index.php.
How to Execute PHP Scripts
PHP scripts always run into a web browser.
So to run the above-saved file you will need to open your browser then just type-
In my case, I have saved my file inside the php-examples folder so, I will put this folder name before the file name.
- This will print the following result in the browser.
Install XAMPP On Ubuntu 18.04
You can install XAMPP in Linux Ubuntu by following these steps. But before starting the installation on Ubuntu 18.04 you must have a non-root user account on your desktop with the Sudo privileges.
You will need to install the
netstat required by XAMPP. Open the terminal and type the below command.
sudo apt install net-tools
Download and Install XAMPP
First, of all download the latest version of XAMPP script from the official website.
For downloading XAMPP, run the following command in the terminal:
sudo wget https://downloadsapachefriends.global.ssl.fastly.net/7.3.7/xampp-linux-x64-7.3.7-0-installer.run?from_af=true
Now you will need to make the downloaded file to executable by setting the permissions to the file:
sudo chmod +x xampp-linux-x64-7.3.7-0-installer.run
Once, you have set the file permission, run the install file by entering the following command –
- It will prompt the installation screen as shown below.
- Proceed with the installation by clicking on Next.
- In the next step, It will ask you to select the component/services which you want to install. I recommend you to leave all these options to default and click on Next.
- The next step will give information about the default installation directory of the XAMPP where it is going to install.
- In the next, It will ask to select the other free application to install such as Drupal, Joomla, and WordPress. If you don’t want to install then just ignore this and click on Next.
- Here, setup is now ready to install so click on Next.
- Now, the installation process has started. It will take few seconds to install so let it complete.
- Once the installation has been completed it will prompt you a setup wizard to launch XAMPP. Click on Finish.
Start and Verify the XAMPP in Ubuntu
Open the terminal and type the below command to check whether the installation has been completed successfully or not.
$ sudo /opt/lampp/lampp start
Now open your browser and type
http://localhost/ to see the result.
If you want to open phpMyAdmin then type the following URL in the browser.
Now, I am wrapping up this post here. I hope this tutorial will help you in the installation and configuration of the localhost/server in the Windows and Linux system. If you stuck in the installation then please let me know by doing comments in the comment box below. I will definitely help you. In the next post, I will be here with some advanced feature of Ajax PHP Form Handling with jQuery. So, please stay tuned here for the latest posts. Thank you.