WAMP is acronym for Windows OS + Apache + MySQL and PHP. It is a solution for mostly amateur PHP developers to develop scripts locally.
It is a widely understood fact that if you are building a PHP app, then it is most likely a web-based app which will most likely run on a Linux server when in production, but still most of the professional developers prefer to use Windows OS for themselves probably because it gives them more “stability” and it is more “familiar”.
Let me remind that building apps on Windows OS that are meant to later run on linux environment is not ideal. It might not matter for “simpler scripts” but it will definitely create troubles if you are using advanced PHP libraries and extensions.
I recommend using IaaS cloud platform like DigitalOcean and create a separate VM for every project, configure your IDE to sync with it live. It is a little more work to setup but this one-time effort is definitely worth it!
Nevertheless, based on my own experience it is still absolutely vital to have PHP installed and running on your Windows OS for reasons varying from minor tests to several others.
This article covers 3 possibilities:
- You might not need Nginx or Apache web server
- OR… Choosing a right WAMP platform
- OR… Installing Nginx/Apache with PHP 7.1 directly
1. You might NOT need Nginx or Apache web server:
As a professional developer, sooner than later you will realise that using packages like XAMPP or WampServer or any other is just an unnecessary overhead especially if components like MySQL, Apache, etc… are installed as a service because it has direct impact on windows startup and performance.
If your app is deployed remotely and your IDE is properly configured with it, you will rarely ever find a need of executing a PHP script locally. In this case, you do not really need a fully loaded web server like Nginx or Apache at all. All you need is PHP since it comes with its own built-in web server since PHP 5.4.
Here is how to install and run PHP 7.1 on Windows 10:
- Download latest PHP binaries package from official PHP downloads page.
- Extract ZIP archive on a relevant location. (i.e. c:\PHP 7.1 )
- Identify your document root. (i.e. If you keep all your work files in D:\Work)
- Run following command in command prompt:
- cd c:\PHP 7.1
- php.exe -S localhost:80 -t D:\Work
- Open browser and navigate to “http://localhost”, It works!
ctrl+cto stop PHP built-in web server.
Note: You may also use a different port number i.e., 8080 or 9000 or some other.
As this works for you, I recommend creating a blank new file named PHP.bat on desktop or anywhere you prefer and save the command above that starts PHP’s built-in web server but use absolute paths instead. For example:
c:\PHP 7.1\php.exe -S localhost:80 -t D:\Work
Now you can double-click on this batch file to start PHP server and it will open a command prompt window of its own. Simply closing this window stops this built-in PHP server. That’s it!
Here is how I have done this:
I created a simple phpinfo file, and here are the results:
* Note that PHP binaries are pre-complied with all necessities like BcMath, Mcrypt, OpenSSL, SQLite3, PDO and several other extensions. You pretty much don’t need anything else!
2. XAMPP/WampServer/etc.. for Windows OS
XAMPP is basically a package of Apache + MySQL + PHP and Perl that can be installed on any OS (they have separate packages for every OS). I used to use XAMPP and I must say that so far I had flawless experience performance vise. It didn’t disappoint me, and comes with a control panel GUI to start/stop different services.
You will find several resources on comparison of different WAMP platforms online and almost all of them are based on personal opinions of authors. There are really no concrete points that makes one better than other. However I have a vital piece of information that you will hardly encounter elsewhere:
XAMPP is NOT available for 64-bit windows. You can still install it but it will behave as a 32-bit application therefore PHP will also run in 32-bit environment. So if your PHP application involves working with 8-bit integers, XAMPP is definitely the wrong choice here.
3. Install Apache/Nginx + PHP directly
Instead of choosing a WAMP platform (i.e. XAMPP, WampServer, etc…) you can also consider installing Apache or Nginx web server directly and make PHP work with it. It is in fact a better choice if you don’t want to install these as “service” and just intend to run when/as necessary.
I did a bit of “googling” myself and almost all of the information that I found were outdated and/or obsolete. Anyway, I will show you how to install Apache or Nginx web server on Windows 10 and make PHP 7.1 work with it in separate articles: