When learning WordPress, I encourage you to use localhost first because you do not need to buy a domain name and host quickly to get a complete website and bring it to the Internet environment after finishing the website.
What is localhost?
Localhost is a compound word for “local” and “host“. Local translates in the sense that IT is your computer, Host means IT as a server. So localhost means a server is operated on your computer.
Localhost includes many applications that come together and all of them will work together to create an environment that can run WordPress source code on your own computer including:
- Webserver software named Apache, this is the most common webserver.
- PHP software for handling PHP code because WordPress is written in PHP language.
- MySQL Server software for storing and processing databases, because WordPress uses MySQL as a database platform. The database is usually written in English as a database.
- PHPMyAdmin software for viewing and managing MySQL databases
Thus, compared to the basic requirements of a WordPress website, localhost has completely met.
How localhost works
When installing Localhost on the computer, your computer already has a Webserver software to run the website application with the address http://127.0.0.1. This is a localhost IP address, in addition, you can also run localhost with the path http://localhost.
Normally when installing Localhost, every time you need to use you will need to open the control panel of localhost and enable it to launch the accompanying applications.
Note before installing
If you have installed localhost-related software such as PHP, MySQL, then delete them all. And you should not install XAMPP on Windows Server that has IIS installed.
Note if you use Skype
If your machine is installed Skype software then localhost will not work because Skype accounted for the right to use the network port 80, which is the default port of the webserver. Therefore, open Skype -> Tools -> Connection Options -> and uncheck “Use port 80 and 443 … ..” and enter any port for Skype to use.
After fixing, reboot the computer to finish.
Turn off the firewall
If your computer has a firewall installed from Windows or from other Antivirus software, turn it off as it may block port 80 or webserver applications.
Turn off UAC on Windows
If your computer is using Windows and has User Account Control turned on, please turn it off when using localhost to avoid issues with restricted permissions.
Instructions to install Xampp for localhost
To install Localhost we have many ways and software, but if you are new, I encourage you to use XAMPP software to install localhost because:
- XAMPP is completely free.
- Easy to use.
- Supports popular operating systems such as Windows, Mac, Linux.
However in this article I only guide for Windows operating systems.
To download XAMPP, first go to https://www.apachefriends.org/download.html and select the XAMPP version appropriate to the operating system of the computer you are using, and you should choose the latest version. Note that XAMPP is only available for 32bit operating systems but 64bit still works normally.
After downloading the installation file, run it, then select Next.
In the path selection section, select the path to save the settings of XAMPP. Note that this path you must remember because when you install the web on localhost, you must access this directory. You should leave the default at c:\xampp. Continue to click Next.
On the next page, uncheck the “Learn more about Bitnami for XAMPP” section. And click Next 2 more times to start the XAMPP installation process.
After installation, press the Finish button to finish the installation and open the XAMPP control panel. However, please restart the computer after the installation is completed to avoid the situation of not being able to start localhost.
Now go to the directory c:\xampp and open the file xampp-control.exe to turn on the control panel of XAMP
You’ll notice that the Apache and MySQL applications have a Start button, which is a sign that they are not started, click the Start button of each application to start the Apache Webserver and MySQL Server to run. get localhost.
If both applications turn green, the image below has successfully started.
After the boot process is complete, visit the website with the address http://localhost and it will show the XAMPP introduction page as shown below.
Operation on localhost
Working with folders and files
One thing that is quite basic but very important when you work with a website, regardless of whether it is localhost or hosting, is to understand the directory classification mechanism of WordPress.
Now go to the directory C: \ xampp \ htdocs \ and create a directory called “designthing”, this directory will contain your website.
As above, I have instructed you to create a directory named designthing in the htdocs directory and you can use the path http: // localhost / designthing to run. So now I can say, the directory C: \ xampp \ htdocs \ designthing is the root of the domain name http: // localhost / designthing
Now try to copy a certain file into the directory C: \ xampp \ htdocs \ designthing and then run the domain name http: // localhost / designthing, you should see it listing the file you just copied.
If you click on the image file, the browser will display the image with the link http: // localhost / designthing / filename. This is considered a picture link in your website.
Similarly, try to create any directory and then copy a file in, now you can access the image view with the path http: // localhost / designthing / folder / filename
So you can understand, the link on the website will be sub-hierarchical according to the directory and file structure in it.
Create a MySQL database (Database)
This task you will have to do in the WordPress installation step on localhost, but here I will guide you in advance so you can try it out.
When referring to the database, you must remember that it consists of 3 main components:
- Database user name.
- Password of user database.
- Database name.
- Database Host (usually the name is localhost, regardless of whether you use it at localhost or normal host).
Imagine that the user of the database will have the task of reading and writing data to the database, so when using the PHP source code, you must declare both the user of the database and the database name at the same time.
For localhost, you do not need to create users for the database but will use the following user information:
- User database name: root
- Password: left blank
Therefore, we only need to create the database. To create the database, visit localhost with the link http: // localhost / phpmyadmin. Then you click on the Databases menu.
Then in the Create databsae section, enter the database name to create in the Database name box, the Collation section you choose is utf8_unicode_ci as shown below and then press the Create button next to it.
Once created, look at the left hand menu, if it appears the database name just created is successful. So now, we have a temporary databse with information like:
- Database Host: localhost
- Database user: root
- Database password: blank
- Database name: designthing
And how to use it, I will say in the step of installing WordPress on localhost for reality.
How to change the network port for Localhost
By default, Localhost will use port 80, because when you type a domain name like http: // localhost, it uses port 80 to read web data in localhost. However, if you have used port 80 for another application, or simply cannot start Apache, you should set up Apache in Localhost to use another port, such as 8080.
Before changing, I need you to note that after changing, you must access the website with the domain name http: // localhost: 8080 instead of just http: // localhost.
To change the port, open up the XAMPP control panel and select the Apache Config button, then select Apache (httpd.conf).
You then find this line:
After that, Stop the Apache and Start again and then try to access localhost at the link http: // localhost: 8080, if you have access, you have succeeded. And also note that, after changing the port, every time you access you must use the path with the port number you just changed to because by default if not filled, it will use port 80.
If you use the virtual domain name as instructed above, you should also edit the file C: \ xampp \ apache \ conf \ extra \ httpd-vhost.conf so that it uses port 80 instead of 8080.
Can I send to my friends the website at localhost?
No, you can’t
Can I transfer data from localhost to an Internet host later?
Is localhost slow?
Hardly, unless your computer is too weak.
Does localhost have a website hack?
Hardly if your computer is not accessed by someone else.
The above is all you need to know about localhost and it will follow you throughout the process of working with the website because the host should only be used to run the main website on the internet, and localhost should be used for testing or needing adjustment. Fix something on your website without having it affect the main website directly.