Installing a local web server on your PC is the first step in setting up a local development environment. This will turn your machine into a system capable of displaying web pages and handling all of the responsibilities associated with locally producing a WordPress website.
There are several advantages of having a local web server:
- Because all information is processed locally, it provides a quick response to the frequent page refreshes that are made as plugin code is written, tested, and refined.
- It also eliminates the need to constantly upload new plugin file versions to a remote web server to validate code changes.
- It also allows development to take place when no Internet connection is available (for example, when traveling on an airplane).
- Provides a worry-free development environment in which a programming error or endless loop cannot bring a live website down.
There are several free packages online that include all of the web server components required to host a WordPress installation. This article will teach you how to install one of these packages quickly and effectively.
- Go to the XAMPP website and get the proper XAMPP package for your machine (http://www.apachefriends.org/en/xampp.html).
XAMPP may be used on Windows, Mac OS X, and Linux systems. XAMPP version 1.7.5 for Windows was used to create the screenshots in this recipe. Depending on your OS, the installation methods and precise dialog contents may differ significantly.
- Optional on Windows: Disable the Windows User Access Control (UAC) function to provide XAMPP complete access to install itself on your machine (for more details, see http://windows.microsoft.com/en-US/windows7/Turn-UserAccount-Control-on-or-off).
- On the Windows platform, run the XAMPP installer (xampp-win32-1.7.5-VC9-installer.exe).
- Choose your preferred language and accept the User Access Control warning notice (UAC).
5. If at all possible, leave the default settings alone.
- If at all possible, do not change the default installation location of c:xampp, as this folder will be mentioned in this article and others.
- If you don’t want a web server icon on your desktop, uncheck the Create a XAMPP Desktop icon option.
- Select the Install Apache as service option to have the web server start automatically when your machine boots up.
- Select the Install MySQL as service option to have the database server start automatically when your machine boots up.
- Uncheck the option to install Filezilla as a service because you won’t require a local FTP server when developing WordPress plugins.
- To complete the web server installation, click the Install button.
- When the installation is finished, click Finish. Based on the parameters specified during the installation process, the XAMPP installer will register the relevant services with Windows.
- Use the Start Menu shortcut to open the XAMPP Control Panel and check the status of the web and database servers. In the XAMPP Control Panel Application, both the Apache and MySql services should be listed as running.
- Open a web browser and go to http://localhost to see the welcome page for your local web server.
- In a text editor, open the c:xamppapacheconfhttpd.conf file (for example, Notepad).
- To prevent retaining your project files under the original installation directory, look for the DocumentRoot configuration option and set its value to a new place on disk. For example, DocumentRoot “C:/WPDev” might be changed to a new directory built to store your local development installation of WordPress. In this route, you’ll see that forward slashes are employed. If you copy and paste a path from a file explorer window, be cautious.
- Find the Directory option and set it to the same path as the DocumentRoot, that is.
- Save and exit the httpd.conf configuration file.
- If the DocumentRoot directory does not already exist on your machine, create it.
- Go to the XAMPP Control Panel and log in.
- To make the updated settings take effect, stop and restart the Apache service.
The XAMPP package includes everything you’ll need to set up a web server on your PC that can host a WordPress website. The following are some of the components:
- Apache web server
- PHP interpreter
- MySQL database server
FileZilla Server is an FTP server included in the XAMPP package. We don’t need to deploy this service because we can access the web server files locally. The operating system recognizes the term localhost that we write in the web browser as a request to speak with the web server on the local machine after XAMPP is installed and launched, and the Apache web server shows the welcome page from its instructions.
While XAMPP is a full-featured local web server software that runs on all three major operating systems, there are a plethora of alternatives accessible online. Here’s a rundown of some of the most well-known:
- WampServer (http://www.wampserver.com/en/) and EasyPHP (http://www.easyphp.org/) for Windows.
- MAMP (http://www.mamp.info/en/index.html) for Mac OS X