XAMPP Installation and Usage | Running PHP Codes on Localhost

In this video, I’ll explain what needs to be done for your PHP files to work on your computer. PHP files don’t work like HTML files on your computer. In order to run PHP files on your computer, you need to run your computer as a server. What does that mean, with the help of an application, we need applications like MySQL to use databases and applications like Apache to run PHP files. We need applications. We don’t need to install them one by one. We can download them as a package and have all these applications installed on our computer with a single installation.

What is XAMPP Program? How to Install?

There are several apps that serve this purpose. One of them is XAMPP. You can install this application for Windows, Linux, and Mac computers. This is XAMPPs website. You can also find it by searching on Google. The website addresses apachefriends.org. Click on the button with the operating system on which operating system you will install. Since I will install on Windows, I click the Windows button and let’s download the installation file to our computer. After downloading the application, let’s run it and start the installation. We will perform the standard installation procedures here. It’ll ask in which folder we want to install it. We can leave it as standard. It will open a folder under the C drive and open a folder called XAMPP. It’ll install these files inside that folder.

Is XAMPP Free?

I’m starting the installation. With XAMPP, as you can see here, you can install open source systems, such as WordPress, Drupal, Joomla on your computer and edit them, enter content and use them as if you were using them on a regular website. Since these systems, these content management systems, our PHP based systems, you need programs such as XAMPP to use these systems on your computer. You may encounter such a message during installation. Let’s grant this permission by clicking Allow Access. Our installation process is complete. There is a control panel in XAMPP. To open this control panel, let’s mark here and click the finish button to open the control panel. XAMPP’s control panel.

Now I am recording this video so that you can run PHP based content management systems on our computer. So what we need is 1- Apache 2- MySQL. Because if you go over WordPress, WordPress is a content management system that needs MySQL. So what we need here is both Apache and MySQL.

First, let’s run the MySQL system, the database system. I click to start button right next to it. And you may need to give firewall such permission again. I click to Allow Access button and you will see a green color behind this MySQL word. This green color means that the MySQL system is running successful and stably.

Now let’s do the same for the Apache option. I click to start button. And if you see the green color in the background of Apache, it means that the Apache application is running successfully.

Running PHP in Windows with XAMPP

We installed the XAMPP file. Installed the set up file and thus installed Apache and MySQL, which you need to run PHP files. Now let’s see if all these applications are working properly. I come to the address bar. I’m typing Localhost here, and if you see such a page, when you type Localhost, it means you can run PHP files as well.

Let me show you how to run a sample PHP file. You cannot simply run any PHP file on your computer. You need to copy or move these files to another folder under where we installed this installation. If you remember, we made this installation in a XAMPP folder under C drive. Let’s get to that folder right away. I open Run with Win + R and write C:/xampp here. That means access the XAMPP folder inside the C folder. When I click the Enter button, as you can see, there are various folders here.

In order for you to run the PHP files we have created, we need to go under htdocs. We have nothing to do with other folders. When we go under that, you will see a file named index.php here. If you look at its relationship to Localhost, it means something like this, the place it says Localhost is actually this folder of ours. In other words, we will be able to see any file we put in this folder in our browser. There is a code in index.php that redirects those entering Localhost to the dashboard. Therefore, when we type Localhost, it automatically enters the dashboard. So it goes to this page. I open index.php. We come across such a page. Here is the direction I’m talking about. We can delete these codes in this file. We can also delete this file, I delete this file and create a new index.php file. And let’s go inside this file. Write our first line and save it. Now I’m reentering to Localhost. We just entered by deleting the dashboard section and automatically defining the index name as the homepage, it shows us the index in this folder by simply typing Localhost. If I type another name here. If I type ekin.php, it won’t show me that. It’ll show the folders themselves, because it is looking for a file named index as the main page and cannot find it. When I manually type the name of the file here, it’ll appear again. Actually, what I want to show here is how our PHP files work on our computer. You can install WordPress in this folder. You can also install other PHP based content management systems. If you are interested in PHP scripting, you can run your own PHP files without installing these content management systems. In addition to all these, if you are going to work on the database by clicking the admin button on the MySQL’s line, you can access phpmyadmin’s page, where you can create new databases and make any edits you want.

If you restart your computer, you will need to run these applications again, because these are applications in themselves. Under the XAMPP folder, you can click this Control to open this panel. You can also import this control.exe file into startup. You can also put it in the Windows startup folder. So when your computer is turned on, this application will also open automatically. It might be helpful to know where the origin of this app is. Since we installed it inside the C drive, the control.exe file of the control panel under the XAMPP folder under the C drive. Let me say that too.

XAMPP Installation Error and Solutions

Fix XAMPP Apache / Localhost Not Working Problem: If the Apache option doesn’t appear in green, there is likely a port conflict. Look, here it sees 80 as port, a general port value of 80. And if you experience such a conflict, let’s click the Config button. Let’s choose the Apache, httpdconf option. When we select it a notepad like this will open. We will have to search. We search as Listen 80, and we can change the port value here ourselves to another value. We can avoid this port conflict when we change this value, save and close the file. And then click, stop and start again.

Fix MySQL Shutdown Unexpectedly Error: If you get an error like MySQL shutdown unexpectedly, after closing XAMPP, delete the ibdata1 file in the C:\xampp\mysql\data folder and restart XAMPP.

Popular Tutorials

Activating WordPress Maintenance Mode with WP-CLI

In this tutorial, I’ll show you how to activate WordPress Maintenance Mode…

Wordpress Zamanlama Kaçırıldı (Missing Schedule) Hatası Çözümü

Wordpress’in en iyi özelliklerinden biri yazdığınız yazıları önceden planlayabilmek ve vakti geldiğinde…

Wordpress ve Custom Post Type / Taxonomy Oluşturma

WordPress bir blog içerik yönetim sisteminden öte özelliklere sahip. WordPress ile portfolyo…

What is the Difference Between WordPress Posts and Pages?

If you’re just getting started with WordPress, you might be wondering what…

Admin Panel Menülerini Devre Dışı Bırakma

WordPress süper özelliklerle gelen güçlü bir içerik yönetim sistemi. Profesyonel olarak müşterilerinize…

WordPress Eski Yazı Editörüne (Klasik Düzenleyici) Dönme

WordPress 5.0 versiyonu ile gelen Gutenberg block editörden eski yazı editörü olan klasik düzenleyiciye eklentiyle ve eklenti kullanmadan nasıl dönülür?